Ubuntu14.04设置静态IP上网
1、设置静态IP、子网掩码、网关
root@ubuntu:~# vi /etc/network/interfaces
auto eth0
iface eth0 inet static
address 172.18.198.210
netmask 255.255.248.0
gateway 172.18.192.2
2、设置DNS服务器
root@ubuntu:~# vi /etc/resolv.conf
nameserver 172.18.192.2
3、重启网络
root@ubuntu:~# /etc/init.d/networking restart
备注:直接修改文件/etc/resolv.conf ,重启后dns设置又被覆盖了,编辑/etc/resolv.conf文件时有提示:
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
# DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
应修改的文件是/etc/resolvconf/resolv.conf.d/base
nameserver 8.8.8.8
nameserver 172.18.192.2
保存后,执行:
root@ubuntu:~# resolvconf -u
然后重启网络:
root@ubuntu:~# /etc/init.d/networking restart