我有新的 ubuntu 安装。我的网络是使用 dhcp 配置的。
$ ifconfig
enp5s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.2 netmask 255.255.255.0 broadcast 192.168.1.255
inet6 fe80::428d:5cff:fe4d:7c4a prefixlen 64 scopeid 0x20<link>
ether 40:8d:5c:4d:7c:4a txqueuelen 1000 (Ethernet)
RX packets 60 bytes 5812 (5.8 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 126 bytes 11851 (11.8 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1 (Локальная петля (Loopback))
RX packets 2877 bytes 177223 (177.2 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 2877 bytes 177223 (177.2 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
我尝试为该接口指定静态配置
# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback
auto enp5s0
iface enp5s0 inet static
address 192.168.1.2
netmask 255.255.255.0
gateway 192.168.1.1
dns-nameservers 8.8.8.8
但
nmcli device show enp5s0 | grep IP4.DNS
不打印任何内容。
互联网可以访问,并且站点可以 ping 成功。
那么该怎么做呢?
更新:我已经能够检测到 8.8.8.8 dns 已被使用。
host -v www.news.com | grep Received
Received 89 bytes from 8.8.8.8#53 in 56 ms
Received 100 bytes from 8.8.8.8#53 in 101 ms
Received 100 bytes from 8.8.8.8#53 in 98 ms
但我不明白为什么
nmcli device show enp5s0 | grep IP4.DNS
什么也没显示。