1、修改/etc/network/interfaces文件:
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
address 192.168.1.200
netmask 255.255.255.0
broadcast 192.168.1.255
gateway 192.168.1.1
2、更改DNS:修改/etc/resolv.conf
nameserver 114.114.114.114
不起作用,查看/etc/resolv.conf有以下提示:
# Dynamic resolv.conf(5) fileforglibc resolver(3) generated by resolvconf(8)# DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
新建一个文件,文件名必须为"tail"
sudo vim /etc/resolvconf/resolv.conf.d/tail
加入两行:
nameserver 8.8.8.8
nameserver 114.114.114.114
保存
sudo /etc/init.d/resolvconf stop && /etc/init.d/resolvconf start
3、重启网卡:sudo /etc/init.d/networking stop
sudo /etc/init.d/networking start
网友评论