Ubuntu配置和修改IP地址
1、修改配置文件/etc/network/interfaces
root@ubuntu:~#sudo gedit /etc/network/interfaces
添加以下內(nèi)容:
auto eth0 #設(shè)置自動(dòng)啟動(dòng)eth0接口
iface eth0 inet static #配置靜態(tài)IP
address 192.168.11.88 #IP地址
netmask 255.255.255.0 #子網(wǎng)掩碼
gateway 192.168.11.1 #默認(rèn)網(wǎng)關(guān)
2、修改DNS
sudo gedit /etc/resolve.conf
nameserver 127.0.0.1 #記得加上
nameserver 8.8.8.8#當(dāng)?shù)豥ns服務(wù)器(用ipconfig /all 查看本地dns,第一個(gè)dns是默認(rèn)的,共有2個(gè)dns)
注:#后面的注釋信息不要加進(jìn)去。
3、重啟網(wǎng)絡(luò),使配置生效
sudo /etc/init.d/networking restart
4、查看ip是否配置成功root@ubuntu:~# ifconfig
eth0 Link encap:Ethernet HWaddr 00:0c:29:2d:89:40
inet addr:192.168.11.88Bcast:192.168.11.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe2d:8940/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:223 errors:0 dropped:0 overruns:0 frame:0
TX packets:253 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:24219 (24.2 KB) TX bytes:22960 (22.9 KB)
Interrupt:19 Base address:0×2024
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:48 errors:0 dropped:0 overruns:0 frame:0
TX packets:48 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:3964 (3.9 KB) TX bytes:3964 (3.9 KB)
root@ubuntu:~#
注:紅字加粗“192.168.11.88”跟上面配置的ip一樣,表示ip配置成功。
如果網(wǎng)絡(luò)無(wú)法啟動(dòng)或不穩(wěn)定,可嘗試如下操作:
gedit /etc/NetworkManager/NetworkManager.conf
managed=false設(shè)置成managed=true
Ubuntu的網(wǎng)絡(luò)參數(shù)保存在文件 /etc/network/interfaces中,默認(rèn)設(shè)置使用dhcp,內(nèi)容如下:
# The primary network interface
auto eth0
iface eth0 inet dhcp
設(shè)置靜態(tài)ip的方法如下:
(1)編輯 /etc/network/interfaces
1.1)將dhcp 一行屏蔽
# The primary network interface
auto eth0
#iface eth0 inet dhcp
1.2)添加和靜態(tài)ip有關(guān)的參數(shù)
# The primary network interface
iface eth0 inet static
address 192.168.0.10
netmask 255.255.255.0
gateway 192.168.0.1
(2)編輯 /etc/resolv.conf,設(shè)置dns
nameserver 202.96.134.133
nameserver 202.106.0.20
(3)執(zhí)行下面兩個(gè)命令,啟用新設(shè)置
$sudo ifdown eth0
$sudo ifup eth0
總結(jié)
以上是生活随笔為你收集整理的Ubuntu配置和修改IP地址的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: iOS极光推送,两次Bundleid不一
- 下一篇: 计算机专业需要掌握的知识和技术