longhtml@ubuntu:~
sudonano/etc/network/interfacesautoloifaceloinetloopbackautoeth0ifaceeth0inetstaticaddress192.168.1.251netmask255.255.255.0gateway192.168.1.254接下来添加DNSlonghtml@ubuntu:
cat /etc/resolv.conf
longhtml@ubuntu:~
sudonano/etc/resolv.confnameserver202.96.128.188//深圳电信nameserver202.96.134.133nameserver192.168.1.254(dns重启后会失效,需要改其它文件保证永久改变)longhtml@ubuntu:
sudo /etc/init.d/networking restart
或者
longhtml@ubuntu:~
sudoservicenetworkingrestart如果配置失败,可以使用手工配置方法:longhtml@ubuntu:
sudo ifconfig eth0 192.168.1.251 netmask 255.255.255.0 up
longhtml@ubuntu:~$ sudo route add default gw 192.168.1.254 eth0
我的Ubuntu15.10通过修改interfaces配置静态ip不起作用(原因未知)。只能通过手工配置方法生效。