linux修改dns

linux修改dns

ifconfig -a
一般来说,eth0就是第一块网卡了,而lo是localhost的缩写。

然后编辑 /etc/network/interfaces 添加下面的信息

1
2
3
4
5
auto eth0		// 开机自动挂载这张网卡
iface eth0 inet static // 使用静态ip
address 192.168.1.233
netmask 255.255.255.0
gateway 192.168.1.1

如果使用DHCP,将”iface eth0 inte static”改为”iface eth0 inet dhcp”

配置DNS服务器

编辑/etc/resolv.conf

nameserver 114.114.114.114

然后重启机器或者重启网卡,附上重启网卡的指令:

/etc/init.d/networking restart