SSH 连接到错误的主机 (IPv6)

SSH 连接到错误的主机 (IPv6)

长话短说:

我有两个主机,opi并且bpi.

当我这样做时ssh bpi,我就会连接到opi.我已将问题追溯到ssh opi通过 IPv4 连接,但ssh bpi使用(错误的)IPv6 地址。我看到我的 OpenWRT 路由器认为与 相关bpi,但实际上它显示为 ( ip address show eth0) 而不是opi

我可以发布ip address show输出等,但我不确定什么是私有的,什么不是 IPv6。有问题的地址的范围为global mngtmpaddr noprefixroute.

我不想开始关闭我在路由器上看到的所有 IPv6,但我也不明白出了什么问题。

细节:

由于这个问题,我一直在尝试阅读有关 IPv6 的内容,但我通常对网络方面的内容敬而远之,因为它不是很令人满意,并且有很多困难的领域。

该行为会触发 SSH 主机密钥更改 DNS 欺骗警报,所以这是好事。它可能与 OpenWRT 的 IPv6 有关,但我找不到其他人或未解决的问题。另外我还没有设置任何与 IPv6 相关的东西。事情就是这样来的,路由器上个月刷了OpenWrt 21.02.1。

所有的机器都是基于 Debian 的 Linux。我尝试过的所有三台笔记本电脑都出现此问题。使用 OpenWRT 的 dnsmasq 服务为所有主机提供带有 DNS 名称的静态 DHCP 租约。每个主机上的文件都是库存的( ZeroTier 提供的地址别名/etc/hosts列表除外)。*.zt

如果我直接连接到 IPv4 地址或 ZeroTier 别名,那么一切都会按预期工作。

opi在 OpenWRT 中不显示为 IPv6 主机。 bpi确实显示,但地址为opi.两个盒子都有不同的 MAC,我将它们放在 dnsmasq 中用于静态 DHCP 分配,并将它们保留在我的配置文件中以用于 WOL。

我可以连接他们所有的 IPv6 地址(每个地址除外)。这可能是一些特殊的地址,我对 IPv6 几乎一无所知,除了几年前我做了一个 he.net 教程。

除了尝试完全关闭 IPv6 之外,我还能尝试什么?

我应该在 OpenWRT 中设置 IPv6 后缀吗?


/etc/nsswitch.conf根据要求,Ubuntu 10/Debian 11 按原样提供:

passwd:         compat systemd
group:          compat systemd
shadow:         compat
gshadow:        files

hosts:          files mdns4_minimal [NOTFOUND=return] dns
networks:       files

protocols:      db files
services:       db files
ethers:         db files
rpc:            db files

netgroup:       nis

还有/etc/hosts(或者至少是 IPv6 部分):

127.0.0.1   localhost
127.0.1.1   t460s

# Some IPv4 aliases here, nothing more
# 10.147.*.*    *.zt

# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

名称服务器127.0.0.53位于此笔记本电脑或192.168.3.1所有其他笔记本电脑上,包括opi/ bpi(192.168.3.1 是 OpenWRT 网关)。

$ nslookup opi.lan
Server:     127.0.0.53
Address:    127.0.0.53#53

Non-authoritative answer:
Name:   opi.lan
Address: 192.168.3.182
$ nslookup bpi.lan
Server:     127.0.0.53
Address:    127.0.0.53#53

Non-authoritative answer:
Name:   bpi.lan
Address: 192.168.3.160
Name:   bpi.lan
Address: fd26:256d:8eef::17f
$ ssh bpi.zt nslookup bpi
Server:     192.168.3.1
Address:    192.168.3.1#53

Name:   bpi.lan
Address: 192.168.3.160
Name:   bpi.lan
Address: fd26:256d:8eef::17f

在网关本身上uci show dhcp

dhcp.@dnsmasq[0]=dnsmasq
dhcp.@dnsmasq[0].domainneeded='1'
dhcp.@dnsmasq[0].localise_queries='1'
dhcp.@dnsmasq[0].rebind_protection='1'
dhcp.@dnsmasq[0].rebind_localhost='1'
dhcp.@dnsmasq[0].local='/lan/'
dhcp.@dnsmasq[0].domain='lan'
dhcp.@dnsmasq[0].expandhosts='1'
dhcp.@dnsmasq[0].authoritative='1'
dhcp.@dnsmasq[0].readethers='1'
dhcp.@dnsmasq[0].leasefile='/tmp/dhcp.leases'
dhcp.@dnsmasq[0].resolvfile='/tmp/resolv.conf.d/resolv.conf.auto'
dhcp.@dnsmasq[0].localservice='1'
dhcp.@dnsmasq[0].ednspacket_max='1232'
dhcp.lan=dhcp
dhcp.lan.interface='lan'
dhcp.lan.start='100'
dhcp.lan.limit='150'
dhcp.lan.leasetime='12h'
dhcp.lan.dhcpv4='server'
dhcp.lan.dhcpv6='server'
dhcp.lan.ra='server'
dhcp.lan.ra_flags='managed-config' 'other-config'
dhcp.wan=dhcp
dhcp.wan.interface='wan'
dhcp.wan.ignore='1'
dhcp.odhcpd=odhcpd
dhcp.odhcpd.maindhcp='0'
dhcp.odhcpd.leasefile='/tmp/hosts/odhcpd'
dhcp.odhcpd.leasetrigger='/usr/sbin/odhcpd-update'
dhcp.odhcpd.loglevel='4'

dhcp.@host[0]=host
dhcp.@host[0].name='xxx'
dhcp.@host[0].dns='1'
dhcp.@host[0].mac='x:x:x:x:x:x'
dhcp.@host[0].ip='192.168.3.x'

IPv6 路由:

::1 dev lo proto kernel metric 256 pref medium
fd26:256d:8eef::3b5 dev wlp3s0 proto kernel metric 600 pref medium
fd26:256d:8eef::d1c dev enp0s31f6 proto kernel metric 100 pref medium
fd26:256d:8eef::/64 dev enp0s31f6 proto ra metric 100 pref medium
fd26:256d:8eef::/64 dev wlp3s0 proto ra metric 600 pref medium
fd26:256d:8eef::/48 via fe80::9ade:d0ff:fe5e:534c dev enp0s31f6 proto ra metric 100 pref medium
fd26:256d:8eef::/48 via fe80::9ade:d0ff:fe5e:534c dev wlp3s0 proto ra metric 600 pref medium
fe80::/64 dev enp0s31f6 proto kernel metric 100 pref medium
fe80::/64 dev ztuku7oncs proto kernel metric 256 pref medium
fe80::/64 dev wlp3s0 proto kernel metric 600 pref medium

典型的resolv.conf

search lan
nameserver 192.168.3.1
nameserver fd26:256d:8eef::1

$ ssh bpi
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@       WARNING: POSSIBLE DNS SPOOFING DETECTED!          @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
The ECDSA host key for bpi has changed,
and the key for the corresponding IP address fd26:256d:8eef::17f
is unchanged. This could either mean that
DNS SPOOFING is happening or the IP address for the host
and its host key have changed at the same time.
Offending key for IP in /home/hari/.ssh/known_hosts:113
  remove with:
  ssh-keygen -f "/home/hari/.ssh/known_hosts" -R "fd26:256d:8eef::17f"
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that a host key has just been changed.
The fingerprint for the ECDSA key sent by the remote host is
SHA256:UdjpmN7FNjdrvUWRMXPDYW6wURx0BU3N/AeuZpf0oTc.
Please contact your system administrator.
Add correct host key in /home/hari/.ssh/known_hosts to get rid of this message.
Offending ECDSA key in /home/hari/.ssh/known_hosts:149
  remove with:
  ssh-keygen -f "/home/hari/.ssh/known_hosts" -R "bpi"
Password authentication is disabled to avoid man-in-the-middle attacks.
Keyboard-interactive authentication is disabled to avoid man-in-the-middle attacks.
Agent forwarding is disabled to avoid man-in-the-middle attacks.
  ___  ____  _    ___             
 / _ \|  _ \(_)  / _ \ _ __   ___ 
| | | | |_) | | | | | | '_ \ / _ \
| |_| |  __/| | | |_| | | | |  __/
 \___/|_|   |_|  \___/|_| |_|\___|
                                  
Welcome to Armbian 21.02.2 Focal with Linux 5.10.60-sunxi
...
$ ssh bpi.zt
 ____  ____  _ 
| __ )|  _ \(_)
|  _ \| |_) | |
| |_) |  __/| |
|____/|_|   |_|
               
Welcome to Armbian 21.02.3 Focal with Linux 5.10.60-sunxi
...

我稍后会看两件事:

  • 是否有任何resolve.conf有任何特殊的东西,比如resolve.conf.d也许......
  • 两者之间有一个托管交换机是否重要,这也是新的......
  • mDNS 是我可以做的吗,这可能会search local“隐藏”问题吗

但我想我真的必须深入研究 OpenWRT 并看看我是否应该骚扰那些家伙。

相关内容