OpenSSH 不连接到 IPv6 主机,除非“AddressFamily inet6”

Zor*_*che 7 ssh ipv6

我有一个 OpenSSH 客户端和服务器。两者都在带有 OpenSSH 6.0 的 Debian 7 上运行。我在两台机器之间建立了一个 VPN,该 VPN 具有功能性 IPv6。它没有任何 IPv4。

令人沮丧的问题是,如果我AddressFamily inet6在 ssh_config 中设置了该选项,我只能使用 IPv6 连接到服务器。我真的不想设置这个选项。 看起来我应该能够设置AddressFamily any并让我的连接正常工作。

我通过 IPv6 的工作连接看起来像这样。

工作 ssh_config

Host test-fw-01 test-fw-01.example.org
    HostKeyAlias test-fw-01.example.org
    HostName test-fw-01.example.org
    AddressFamily inet6 
Run Code Online (Sandbox Code Playgroud)

工作控制台输出

# ssh -v test-fw-01.example.org
OpenSSH_6.0p1 Debian-4, OpenSSL 1.0.1e 11 Feb 2013
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 122: Applying options for test-fw-01.example.org
debug1: /etc/ssh/ssh_config line 370: Applying options for *
debug1: Connecting to test-fw-01.example.org. [2607:fa78:1051:2001::1:26] port 22.
...
Linux test-fw-01 3.2.0-4-amd64 #1 SMP Debian 3.2.46-1+deb7u1 x86_64
root@test-fw-01:~#
Run Code Online (Sandbox Code Playgroud)

端口 53 的工作 tcpdump

# tcpdump -n port 53
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
17:05:27.294506 IP 10.2.4.5.59917 > 10.2.4.51.53: 34233+ AAAA? test-fw-01.example.org. (59)
17:05:27.295398 IP 10.2.4.51.53 > 10.2.4.5.59917: 34233* 1/0/0 AAAA 2607:fa78:1051:2001::1:26 (87)
17:05:27.295762 IP 10.2.4.5.42664 > 10.2.4.51.53: 42285+ AAAA? test-fw-01.example.org. (59)
17:05:27.295970 IP 10.2.4.51.53 > 10.2.4.5.42664: 42285 1/0/0 AAAA 2607:fa78:1051:2001::1:26 (87)
Run Code Online (Sandbox Code Playgroud)

当我使用AddressFamily anyAddressFamily inet我看到这个。

损坏的 ssh_config

Host test-fw-01 test-fw-01.example.org
    HostKeyAlias test-fw-01.example.org
    HostName test-fw-01.example.org
    AddressFamily any #supposed to use any?
Run Code Online (Sandbox Code Playgroud)

损坏的控制台输出

# ssh -v test-fw-01.example.org
OpenSSH_6.0p1 Debian-4, OpenSSL 1.0.1e 11 Feb 2013
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 122: Applying options for test-fw-01.example.org
debug1: /etc/ssh/ssh_config line 370: Applying options for *
ssh: Could not resolve hostname test-fw-01.example.org.: Name or service not known
Run Code Online (Sandbox Code Playgroud)

断开连接时端口 53 的 tcpdump

# tcpdump -n port 53
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
17:03:30.814876 IP 10.2.4.5.33824 > 10.2.4.51.53: 23711+ A? test-fw-01.esd189.org. (59)
17:03:30.815276 IP 10.2.4.5.33824 > 10.2.4.51.53: 65399+ AAAA? test-fw-01.esd189.org. (59)
17:03:30.815746 IP 10.2.4.51.53 > 10.2.4.5.33824: 65399* 1/0/0 AAAA 2607:fa78:1051:2001::1:26 (87)
17:03:35.819158 IP 10.2.4.5.33824 > 10.2.4.51.53: 23711+ A? test-fw-01.esd189.org. (59)
17:03:39.481119 IP 10.2.4.51.53 > 10.2.4.5.33824: 23711 ServFail 0/0/0 (59)
17:03:40.819636 IP 10.2.4.5.33824 > 10.2.4.51.53: 23711+ A? test-fw-01.esd189.org. (59)
17:03:45.824898 IP 10.2.4.5.51629 > 10.2.4.51.53: 63582+ A? test-fw-01.esd189.org.esd189.org. (70)
17:03:45.825252 IP 10.2.4.51.53 > 10.2.4.5.51629: 63582 NXDomain* 0/1/0 (137)
17:03:45.825423 IP 10.2.4.5.51629 > 10.2.4.51.53: 12711+ AAAA? test-fw-01.esd189.org.esd189.org. (70)
17:03:45.825669 IP 10.2.4.51.53 > 10.2.4.5.51629: 12711 NXDomain* 0/1/0 (137)
17:03:45.825874 IP 10.2.4.5.56246 > 10.2.4.51.53: 64150+ A? test-fw-01.esd189.org.nwesd.org. (69)
17:03:45.826062 IP 10.2.4.51.53 > 10.2.4.5.56246: 64150 NXDomain* 0/1/0 (139)
17:03:45.826177 IP 10.2.4.5.56246 > 10.2.4.51.53: 21391+ AAAA? test-fw-01.esd189.org.nwesd.org. (69)
17:03:45.826302 IP 10.2.4.51.53 > 10.2.4.5.56246: 21391 NXDomain* 0/1/0 (139)
17:03:49.621048 IP 10.2.4.51.53 > 10.2.4.5.33824: 23711 ServFail 0/0/0 (59)
Run Code Online (Sandbox Code Playgroud)

挖掘测试服务器的输出。

# dig -t aaaa @10.2.4.51 test-fw-01.example.org.

; <<>> DiG 9.8.4-rpz2+rl005.12-P1 <<>> -t aaaa @10.2.4.51 test-fw-01.example.org.
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 33798
;; flags: qr aa ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;test-fw-01.example.org. IN AAAA

;; ANSWER SECTION:
test-fw-01.example.org. 0 IN    AAAA 2607:fa78:1051:2001::1:26

;; Query time: 1 msec
;; SERVER: 10.2.4.51#53(10.2.4.51)
;; WHEN: Mon Sep 30 17:01:41 2013
;; MSG SIZE  rcvd: 87
Run Code Online (Sandbox Code Playgroud)

我将有大约 70 台主机使用这个 IPv6 VPN。我想简单地将 放在myAddressFamily anyHost *部分中ssh_config,然后建立我的连接。我不想在我的 SSH 配置中明确列出我所有的 IPv6 主机。不会有一致的命名模式,所以我不能做类似Host *.ipv6. 我不想输入-6通过 IPv6 连接。我错过了一些明显的东西吗?我必须做什么才能让 OpenSSH 使用 IPv6 地址进行连接,因为它可用?

San*_*ann 2

我看到 SERVFAIL 响应和 DNS 查询不一致地给出 NXDOMAIN 答案。我建议你修复你的DNS。这可能与 SSH 无关。