Ubuntu配置和修改IP地址
原文链接:
https://www.baidu.com/link?url=KG7Kt1UCvADhrFOnh1gG1MX7XGikmpDWuTbvGye9EWTJz3G-o-9_Y9-yt4YMJ3h6Ol9sInyQ8BlnLVqWzUnI0K&wd=&eqid=b8cd45d90003835e000000065e9827b3
Ubuntu配置和修改IP地址
1、修改配置文件/etc/network/interfaces
root@ubuntu:~# sudo gedit /etc/network/interfaces
添加以下内容:
auto eth0 #设置自动启动eth0接口
iface eth0 inet static #配置静态IP
address 192.168.11.88 #IP地址
netmask 255.255.255.0 #子网掩码
gateway 192.168.11.1 #默认网关
2、修改DNS
sudo gedit /etc/resolve.conf
nameserver 127.0.0.1 #记得加上
nameserver 8.8.8.8 #当地dns服务器(用ipconfig /all 查看本地dns,第一个dns是默认的,共有2个dns)
注:#后面的注释信息不要加进去。
3、重启网络,使配置生效
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.88 Bcast: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配置成功。
如果网络无法启动或不稳定,可尝试如下操作:
gedit /etc/NetworkManager/NetworkManager.conf
managed=false设置成managed=true