ubuntu 上不了网:配置DNS域名解析服务

 Ubuntu 16.04.1 LTS

ubuntu@ubuntu-W760-G20:~$ ping www.baidu.com
ping: unknown host www.baidu.com
ubuntu@ubuntu-W760-G20:~$ ping 192.168.205.122
PING 192.168.205.122 (192.168.205.122) 56(84) bytes of data.
64 bytes from 192.168.205.122: icmp_seq=1 ttl=64 time=0.107 ms

ubuntu@ubuntu-W760-G20:~$ ping 114.114.114.114
PING 114.114.114.114 (114.114.114.114) 56(84) bytes of data.
64 bytes from 114.114.114.114: icmp_seq=1 ttl=84 time=9.00 ms
64 bytes from 114.114.114.114: icmp_seq=2 ttl=75 time=8.62 ms

---ping通114,ping不通baidu. ping通内网


配置dns:

ubuntu@ubuntu-W760-G20:~$ cat /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
ubuntu@ubuntu-W760-G20:~$ cat /etc/network/interfaces
# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback
auto ens2f1
iface ens2f1 inet static
address 192.168.205.11
netmask 255.255.255.0
gateway 192.168.205.254

ubuntu@ubuntu-W760-G20:~$ sudo nano  /etc/network/interfaces
增加如下行:
dns-nameservers 192.168.1.100

sudo nano  /etc/resolv.conf
增加如下行:
nameserver 192.168.1.100

启动interface 需要重启网卡生效; resolv.conf 不需要重启网卡就能够生效。

  

ubuntu@ubuntu-W760-G20:~$ ping www.baidu.com
PING www.a.shifen.com (220.181.38.150) 56(84) bytes of data.
64 bytes from 220.181.38.150: icmp_seq=1 ttl=48 time=4.76 ms
64 bytes from 220.181.38.150: icmp_seq=2 ttl=48 time=26.5 ms

  

posted @ 2019-12-11 15:02  星回中道  阅读(912)  评论(0编辑  收藏  举报