Ubuntu

使用 bind9 問題設置 DNS 伺服器:創建 TCP 套接字:地址不可用

  • April 20, 2022

我正在嘗試在 ubuntu 上設置一個 dns 伺服器。和

sudo systemctl status bind9

我明白了

Apr 17 10:14:21 dns named[1002]: no longer listening on fe80::9903:2b67:b230:aaaa%3#53
Apr 17 10:14:21 dns named[1002]: listening on IPv6 interface eno2, fe80::9903:2b67:b230:aaaa%3#53
Apr 17 10:14:21 dns named[1002]: creating TCP socket: address not available
Apr 17 10:15:06 dns named[1002]: no longer listening on fe80::9903:2b67:b230:aaaa%3#53
Apr 17 10:15:06 dns named[1002]: listening on IPv6 interface eno2, fe80::9903:2b67:b230:aaaa%3#53
Apr 17 10:15:06 dns named[1002]: creating TCP socket: address not available
Apr 17 10:15:51 dns named[1002]: no longer listening on fe80::9903:2b67:b230:aaaa%3#53
Apr 17 10:15:51 dns named[1002]: listening on IPv6 interface eno2, fe80::9903:2b67:b230:aaaa%3#53
Apr 17 10:15:51 dns named[1002]: creating TCP socket: address not available
Apr 17 10:16:36 dns named[1002]: no longer listening on fe80::9903:2b67:b230:aaaa%3#53

我不明白從哪裡來

fe80::9903:2b67:b230:aaaa%3#53

來自,它不在我的配置或ansible劇本中。

dig 和 nslookup 工作,但不能 ping:

$ 挖 gitlab.bobby

探勘 gitlab.bobby

; <<>> DiG 9.16.1-Ubuntu <<>> gitlab.bobby
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 151
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 65494
;; QUESTION SECTION:
;gitlab.bobby.      IN  A

;; Query time: 439 msec
;; SERVER: 127.0.0.53#53(127.0.0.53)
;; WHEN: Du apr 17 13:43:40 EEST 2022
;; MSG SIZE  rcvd: 44




ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
   link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
   inet 127.0.0.1/8 scope host lo
      valid_lft forever preferred_lft forever
   inet6 ::1/128 scope host 
      valid_lft forever preferred_lft forever
2: wlp0s20f3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
   link/ether dc:41:a9:a0:e4:43 brd ff:ff:ff:ff:ff:ff
   inet 192.168.1.138/24 brd 192.168.1.255 scope global dynamic noprefixroute wlp0s20f3
      valid_lft 71048sec preferred_lft 71048sec
   inet6 fe80::a7fb:95aa:eceb:644e/64 scope link noprefixroute 
      valid_lft forever preferred_lft forever
3: tun0: <POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UNKNOWN group default qlen 100
   link/none 
   inet 10.9.100.6/16 brd 10.9.255.255 scope global tun0
      valid_lft forever preferred_lft forever
   inet6 fe80::801:28e7:2f5b:5191/64 scope link stable-privacy 
      valid_lft forever preferred_lft forever

該設置使用 ansible playbook 執行,我在測試伺服器中對其進行了測試,並且可以正常工作。systemd-resolved 也在使用套接字 53,被殺死,重新啟動等沒有變化。

有什麼我可以嘗試的嗎?

問題不是埠被阻塞,而是 systemd 解決了。

我解決了這裡描述的問題:

https://kifarunix.com/configure-openvpn-clients-to-use-specific-dns-server/

apt install openresolv

將此添加到您的客戶端 ovpn 文件中:

script-security 2
up /etc/openvpn/update-resolv-conf
down /etc/openvpn/update-resolv-conf

在客戶端啟動 openvpn:

openvpn client-1.ovpn

檢查它是否有效 cat /etc/resolv.conf

引用自:https://unix.stackexchange.com/questions/699351