请帮我找出问题所在以及如何解决它。我正在使用 Ubuntu 22.04。
问题是当我尝试克隆存储库时
~ git clone [email protected]:some_user/some_rep.git
Cloning into 'some_rep'...
ssh: Could not resolve hostname bitbucket.org.somehost.local.: Temporary failure in name resolution
ssh: Could not resolve hostname bitbucket.org.sh-dev.local.: Temporary failure in name resolution
Receiving objects: 100% (23/23), 8.21 KiB | 8.21 MiB/s, done.
Resolving deltas: 100% (8/8), done
我收到警告Could not resolve hostname
。据我了解,这是由于DNS 搜索域 .somehost.local
并.sh-dev.local
在进行 DNS 解析时附加到主机。
这些是我前雇主的搜索域,现在不再需要了。我不知道它们在哪里管理以及如何摆脱它们。
~ grep hosts /etc/nsswitch.conf
hosts: files mdns4_minimal [NOTFOUND=return] dns
~ clone nmcli connection show
NAME UUID TYPE DEVICE
myWifiName b81dd4e6-1bd3-4659-8a36-713bfe1fd7aa wifi wlp0s20f3
br-ce3f272b0bd1 8e917327-20e3-419d-8b2e-a22e86cbdc83 bridge br-ce3f272b0bd1
br-e3bb71106bfa d10a83ad-bb4e-4fed-88b9-15e8ac1a9483 bridge br-e3bb71106bfa
docker0 dfa05eee-2bae-4c49-afd8-7f5b5de0cdeb bridge docker0
enp0s31f6 54ec474d-eb2a-4eea-8f29-8f25fe325210 ethernet enp0s31f6
office_vpn 7eea950c-a520-423a-8804-9d1907f590ca vpn --
Wired connection 1 e2683831-e13a-3dd5-9db4-4f414fad75bf ethernet --
~ nmcli con show myWifiName | grep ipv4.dns
ipv4.dns: --
ipv4.dns-search: --
ipv4.dns-options: --
ipv4.dns-priority: 0
~ sudo lsof -i :53
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
systemd-r 23016 systemd-resolve 13u IPv4 164764 0t0 UDP localhost:domain
systemd-r 23016 systemd-resolve 14u IPv4 164765 0t0 TCP localhost:domain (LISTEN)
cat /etc/resolv.conf
# This is /run/systemd/resolve/stub-resolv.conf managed by man:systemd-resolved(8).
# Do not edit.
# blah-blah-blah ....
nameserver 127.0.0.53
options edns0 trust-ad
search .
更新:
我又发现了一些:当我打开 VPNnmcli con up myVPN
systemd-resolved[45936]: tun0: Bus client set search domain list to: somehost.local, sh-dev.local
事件时,这些搜索域由网络管理器注入
~ sudo resolvectl domain
Global:
Link 2 (wwan0):
Link 3 (enp0s31f6):
Link 4 (wlp0s20f3):
Link 5 (br-ce3f272b0bd1):
Link 6 (br-e3bb71106bfa):
Link 7 (docker0):
Link 15 (tun0): sj-dev.local sj-dev.ru
当我关闭 VPN 时,nmcli con down myVPN
systemd-resolved[45936]: tun0: Bus client reset search domain list.
事件被记录下来,
~ sudo resolvectl domain
Global:
Link 2 (wwan0):
Link 3 (enp0s31f6):
Link 4 (wlp0s20f3):
Link 5 (br-ce3f272b0bd1):
Link 6 (br-e3bb71106bfa):
Link 7 (docker0):
但不知何故,解析域名时仍使用这些 DNS 搜索域。可能是什么原因?如何解决?
更新2: 问题出在 ~/.ssh/config 中,删除此选项可解决问题
Host *
CanonicalDomains ...