Ubuntu16.04设置ip,dns

Ubuntu16.04设置ip/dns

注意:在设置完ip/dns后,需要自己重新开启一下网络服务(有时甚至需要重启电脑):
sudo /etc/init.d/networking restart

设置ip

sudo gedit /etc/network/interfaces

打开的文件如下:

  • [注] 添加时,在终端先查一下自己想要设置的网卡的名称,不一定是eth0,将eth0替换为自己网卡的名称,然后将自己设置的地址等信息更换即可
# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet static
        address 192.168.0.88
        netmask 255.255.255.0
        network 192.168.0.0
        broadcast 192.168.0.255
        gateway 192.168.0.1
        # dns-* options are implemented by the resolvconf package, if instatlled
        dns-nameservers 192.168.0.1

设置DNS

sudo vi /etc/resolvconf/resolv.conf.d/base

打开文件写入:

search localdomain #如果本Server为DNS服务器,可以加上这一句,如果不是,可以不加
nameserver 8.8.8.8 #希望修改成的DNS
nameserver 114.114.114.114 #希望修改成的DNS

猜你喜欢

转载自blog.csdn.net/deep_kang/article/details/79599796