[xfox@fedora ~]$ ssh v6.home.xfox.fun
ssh: Could not resolve hostname v6.home.xfox.fun: No address associated with hostname
[xfox@fedora ~]$ nslookup v6.home.xfox.fun
Server: 127.0.0.53
Address: 127.0.0.53#53
Non-authoritative answer:
Name: v6.home.xfox.fun
Address: 2408:8220:94b:e720:9eb6:bee8:b52c:6250
这一问题已经困扰我很久,我发现当我使用Clash TUN Mode 时可以正常执行,所以这似乎和DNS有所关联。
但是很快我排除了DNS的问题,因为本地默认的域名解析是正常的,并且我发现这种情况似乎只对*xfox.fun这个域名生效,其他域名的IPv6访问并没有问题。
到底为什么会出现这种情况?
通过DeepSeek我获得了输出SSH完整连接过程的指令:ssh -v v6.home.xfox.fun
然后我看到了这个:
[xfox@fedora ~]$ ssh -v -6 v6.home.xfox.fun
OpenSSH_9.9p1, OpenSSL 3.2.6 30 Sep 2025
debug1: Reading configuration data /home/xfox/.ssh/config
debug1: /home/xfox/.ssh/config line 5: Applying options for *
debug1: /home/xfox/.ssh/config line 8: Applying options for v6.home.xfox.fun
debug1: /home/xfox/.ssh/config line 16: Applying options for *.xfox.fun
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Reading configuration data /etc/ssh/ssh_config.d/20-systemd-ssh-proxy.conf
debug1: Reading configuration data /etc/ssh/ssh_config.d/50-redhat.conf
debug1: Reading configuration data /etc/crypto-policies/back-ends/openssh.config
debug1: configuration requests final Match pass
debug1: re-parsing configuration
debug1: Reading configuration data /home/xfox/.ssh/config
debug1: /home/xfox/.ssh/config line 5: Applying options for *
debug1: /home/xfox/.ssh/config line 16: Applying options for *.xfox.fun
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Reading configuration data /etc/ssh/ssh_config.d/20-systemd-ssh-proxy.conf
debug1: Reading configuration data /etc/ssh/ssh_config.d/50-redhat.conf
debug1: Reading configuration data /etc/crypto-policies/back-ends/openssh.config
ssh: Could not resolve hostname home.xfox.fun: No address associated with hostname
那么问题显而易见了,我曾经为了连接方便更改过/home/xfox/.ssh/config
Host 198.23.254.212
HostName 198.23.254.212
User root
Host *
ServerAliveInterval 60 # 每5秒发送一次活动信号
ServerAliveCountMax 3 # 连续3次无响应后断开
Host v6.home.xfox.fun
HostName home.xfox.fun
User xfox
AddressFamily inet6
Port 22
# IdentityFile /dev/null
IdentityAgent $SSH_AUTH_SOCK
Host *.xfox.fun
User xfox
AddressFamily inet
Port 22
# IdentityFile /dev/null
IdentityAgent $SSH_AUTH_SOCK
按照DS的说法,SSH的配置解析是后项优先级高于前项。
所以上面这个配置文件实际使得所有xfox.fun的子域名默认使用了IPv4协议连接,而我的家庭服务器根本没有公网IPv4地址并且
域名也仅存在IPv6的AAAAAA记录;另一个问题是我要求访问v6.home.xfox.fun时实际访问的地址是:home.xfox.fun。
后续处理
我的配置文件原初目的不存在问题,为了让实际效果也符合我的目的:让v6.home.xfox.fun使用ipv6其他xfox.fun的子域名记录都使用ipv4, 我只需要颠倒v6.home.xfox.fun和*.xfox.fun两个配置块的顺序,确保对v6.home.xfox.fun的条目优先生效。
不得不感慨,这个错误由于我更换操作系统时对用户主目录的备份而发现的很晚,也一定程度上误导了我对错误原因的判断。
在AI时代,不懂就问,想好怎么问是好文明。