可以 ping 但不能 ssh - eth0 lan

可以 ping 但不能 ssh - eth0 lan

纠结该从哪个方向去排查......

Server1 可以通过 ssh 连接到任何计算机,但其他计算机无法通过 ssh 连接到 Server1。即使 Server1 ssh 到 Server2 -> Server2 也无法通过相同的开放 ssh 端口 ssh 返回到 Server1。

Server1 可以 ssh 到 Server3,然后通过 ssh 隧道 ssh 到 Server2

服务器1=>服务器3=>服务器2

为什么 Server1 可以通过 Server2 隧道到 Server3,但不能通过 Server3 返回到 Server1?

如果通过交叉电缆连接,Server1 可以直接连接到 Server2,但无法通过隧道从 Server2 返回到 Server1。

服务器1=>服务器2=>[X]服务器1

如果连接到路由器

# ssh 192.168.4.1
# ssh: connect to host 192.168.4.1 port 22: Connection refused
# nc 192.168.4.1 22   (does not connect)
# nc -l 22  (on 192.168.4.1)
# nc: Address already in use

服务器1:192.168.4.2

服务器2:192.168.4.1

服务器3:192.168.4.3

测试时禁用防火墙。 IP表接受所有。怀疑路由表配置错误......

Server1 内核IP路由表

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.1.1     0.0.0.0         UG    0      0        0 wlan0
192.168.1.0     0.0.0.0         255.255.255.0   U     0      0        0 wlan0
192.168.4.0     0.0.0.0         255.255.254.0   U     0      0        0 eth0
192.168.4.0     0.0.0.0         255.255.252.0   U     0      0        0 eth0

编辑:查看旧的工作保存的“#route -n”输出,192.168.4.0(服务器的子网)的度量为 100 。路由 -n 显示的度量设置是否可能阻止 ssh 隧道?

编辑:

# tcpdump -c 25 -i eth0 -v 
tcpdump: listening on eth0, link-type EN10MB (Ethernet), capture size 262144 bytes
19:19:37.121131 IP (tos 0x10, ttl 64, id 19952, offset 0, flags [DF], proto TCP (6), length 176)
    homie.ssh > 192.168.4.6.38360: Flags [P.], cksum 0x89fb (incorrect -> 0xecf8), seq 3089869718:3089869842, ack 4078834853, win 271, options [nop,nop,TS val 11868537 ecr 3677449774], length 124
19:19:37.121627 IP (tos 0x10, ttl 64, id 22362, offset 0, flags [DF], proto TCP (6), length 52)
    192.168.4.6.38360 > homie.ssh: Flags [.], cksum 0x8577 (correct), ack 124, win 501, options [nop,nop,TS val 3677449895 ecr 11868537], length 0
19:19:37.135066 IP (tos 0x10, ttl 64, id 19953, offset 0, flags [DF], proto TCP (6), length 184)
    homie.ssh > 192.168.4.6.38360: Flags [P.], cksum 0x8a03 (incorrect -> 0xe8ff), seq 124:256, ack 1, win 271, options [nop,nop,TS val 11868540 ecr 3677449895], length 132
19:19:37.135254 IP (tos 0x0, ttl 64, id 37912, offset 0, flags [DF], proto UDP (17), length 70)
    homie.57077 > gateway.domain: 17930+ PTR? 6.4.168.192.in-addr.arpa. (42)
19:19:37.135317 IP (tos 0x10, ttl 64, id 22363, offset 0, flags [DF], proto TCP (6), length 52)

答案1

路线

192.168.1.0     0.0.0.0         255.255.255.0   U     0      0        0 wlan0
192.168.4.0     0.0.0.0         255.255.254.0   U     0      0        0 eth0
192.168.4.0     0.0.0.0         255.255.252.0   U     0      0        0 eth0
  1. 同一子网不能有两个不同的网络掩码

  2. 如果两个不同的子网都指向同一网关 0.0.0.0 内部网关的流量绑定将“丢失”

    # sudo route del -net 192.168.4.0 gw 0.0.0.0 netmask 255.255.255.0 dev eth0

现在尝试分别使用两个网络。路线是自动生成的,因此它“可以”自行工作。如果没有,手动添加路由到远程ip(服务器),192.168.4.0/24似乎不起作用,也许有人可以解释为什么......

`# route add -net 192.168.4.0 netmask 255.255.254.0 gw 192.168.4.2 eth0'

花了几天时间才解决这个问题,所以在这里发帖供我参考,也许它会帮助有类似问题的人寻找 ping 但没有 ssh 的故障排除步骤。

相关内容