我正在测试一个设置为使用 NGINX 作为反向代理的 dotnet core 应用程序。为了测试它,我设置了 Bind9 来将 example.com 解析为我的 LAN IP 地址。我已将 Ubuntu 18.04 右上角的网络管理器 DNS 设置为使用我的 IP 作为 DNS,并将 resolve.conf 主体设置为使用我的 IP 作为 DNS。当我挖掘 example.com 时,我得到了本地 IP 地址:
dig example.com
; <<>> DiG 9.11.3-1ubuntu1-Ubuntu <<>> example.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 54728
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 2
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
; COOKIE: c3f027023efb13f917866a635b0e8feaa95ff6a3a3be7227 (good)
;; QUESTION SECTION:
;example.com. IN A
;; ANSWER SECTION:
example.com. 604800 IN A 192.168.75.136
;; AUTHORITY SECTION:
example.com. 604800 IN NS ns.example.com.
;; ADDITIONAL SECTION:
ns.example.com. 604800 IN A 192.168.75.136
;; Query time: 0 msec
;; SERVER: 192.168.75.136#53(192.168.75.136)
;; WHEN: Wed May 30 04:50:02 PDT 2018
;; MSG SIZE rcvd: 117
但是当我在 Firefox 中搜索时,会加载在线 example.com。我使用以下命令刷新了 DNS:
sudo /etc/init.d/dns-clean restart
and
sudo /etc/init.d/networking force-reload
显然我做错了什么,因为我无法再在右上角的属性中编辑有线连接(它消失了)。我没有在 named.conf.options 中设置转发器,所以我无法解析互联网地址。
在/etc/networkManager/system-connections/Wired connection 1
[ipv4]
dns=192.168.75.136;
dns-search=
ignore-auto-dns=true
method=auto
生成的resolve.conf:
nameserver 192.168.75.136
nameserver 127.0.0.53
没有/etc/NetworkManager/NetworkManager.conf
说dns=dnsmasq
我还添加了/etc/network/interfaces
回送后(基于这邮政):
# The primary network interface
auto eth0
iface eth0 inet static
address 192.168.75.136
netmask 255.255.255.0
gateway 192.168.75.2
dns-nameservers 192.168.75.136
然后跑了
sudo ifdown eth0 && sudo ifup eth0
在撤消每个步骤时,我发现最后一步是导致 eth0 消失的原因,并使 Ubuntu 右上角的网络管理器有线设置在 18.04 中不再出现
sudo netstat -antup | grep LISTEN
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 1538/nginx: master
tcp 0 0 192.168.122.1:53 0.0.0.0:* LISTEN 1489/named
tcp 0 0 192.168.75.136:53 0.0.0.0:* LISTEN 1489/named
tcp 0 0 127.0.0.1:53 0.0.0.0:* LISTEN 1489/named
tcp 0 0 127.0.0.53:53 0.0.0.0:* LISTEN 566/systemd-resolve
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 1081/cupsd
tcp 0 0 127.0.0.1:953 0.0.0.0:* LISTEN 1489/named
tcp6 0 0 :::53 :::* LISTEN 1489/named
tcp6 0 0 ::1:631 :::* LISTEN 1081/cupsd
tcp6 0 0 ::1:953 :::* LISTEN 1489/named
NMCLI 出于某种原因根本不显示 DNS 服务器
nmcli dev 显示 eth0
GENERAL.DEVICE: eth0
GENERAL.TYPE: ethernet
GENERAL.HWADDR: 00:0C:29:05:33:F4
GENERAL.MTU: 1500
GENERAL.STATE: 10 (unmanaged)
GENERAL.CONNECTION: --
GENERAL.CON-PATH: --
WIRED-PROPERTIES.CARRIER: on
IP4.ADDRESS[1]: 192.168.75.136/24
IP4.GATEWAY: 192.168.75.2
IP4.ROUTE[1]: dst = 0.0.0.0/0, nh = 192.168.75.2, mt =
IP4.ROUTE[2]: dst = 169.254.0.0/16, nh = 0.0.0.0, mt =
IP4.ROUTE[3]: dst = 192.168.75.0/24, nh = 0.0.0.0, mt
IP6.ADDRESS[1]: fe80::20c:29ff:fe05:33f4/64
IP6.GATEWAY: --
IP6.ROUTE[1]: dst = fe80::/64, nh = ::, mt = 256
IP6.ROUTE[2]: dst = ff00::/8, nh = ::, mt = 256, table
var/运行/systemd/解决:
nameserver 192.168.75.136
nmcli -t 连接显示--active
virbr0:4239285a-844c-4ec0-b671-c145089b52f1:桥接:virbr0
nmcli con 显示'virbr0'|grep dns
ipv4.dns: --
ipv4.dns-search: --
ipv4.dns-options: ""
ipv4.dns-priority: 100
ipv4.ignore-auto-dns: no
ipv6.dns: --
ipv6.dns-search: --
ipv6.dns-options: ""
ipv6.dns-priority: 100
ipv6.ignore-auto-dns: no
sticker592@ubuntu:~$ nmcli con show 'eth0' | grep dns
Error: eth0 - no such connection profile.
答案1
非常简单的解决方案:我忘了清除 Firefox 中的缓存:
- 键入Ctrl+ Shift+Del并
- 选择删除所有内容。