提问人:Weifeng 提问时间:11/16/2023 最后编辑:Weifeng 更新时间:11/16/2023 访问量:25
SSH 无法使用端口转发连接到具有两个网卡的主机 [已关闭]
SSH cannot connect to host with two network cards using port forwarding [closed]
问:
问题:
我有一台安装了 ubuntu 22.04 LTS 的服务器。此服务器有 2 个网卡,一个有线 (route1) 和一个无线 (router2)。网卡连接到不同的路由器。
我在路由器2(连接到无线网卡)上配置了端口转发,将流量从发送到路由器的端口25532转发到我的Ubuntu服务器上的端口22。
但是,我无法使用 router2 的公共 IP 连接到我的 ubuntu 服务器。请问如何处理这个问题?
一些配置:
fg@Lab-FG:~$ ifconfig
docker0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 172.17.0.1 netmask 255.255.0.0 broadcast 172.17.255.255
ether 02:42:22:1e:92:f5 txqueuelen 0 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
enp2s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.0.110 netmask 255.255.255.0 broadcast 192.168.0.255
inet6 fe80::1f58:41a5:f6a7:fb6e prefixlen 64 scopeid 0x20<link>
ether 80:e8:2c:dd:77:fd txqueuelen 1000 (Ethernet)
RX packets 57827 bytes 9572233 (9.5 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 63156 bytes 21393059 (21.3 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 190430 bytes 27015007 (27.0 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 190430 bytes 27015007 (27.0 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
virbr0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 192.168.122.1 netmask 255.255.255.0 broadcast 192.168.122.255
ether 52:54:00:c2:63:4c txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
wlp3s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.104 netmask 255.255.255.0 broadcast 192.168.1.255
inet6 fe80::93:e833:9872:7bb7 prefixlen 64 scopeid 0x20<link>
ether 28:cd:c4:b4:76:85 txqueuelen 1000 (Ethernet)
RX packets 7007 bytes 2709116 (2.7 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 2323 bytes 373715 (373.7 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
ENP2S0 是有线网卡,WLP3S0 是无线网卡。
fg@Lab-FG:~$ ip route
default via 192.168.0.1 dev enp2s0 proto dhcp metric 100
default via 192.168.1.1 dev wlp3s0 proto dhcp metric 600
169.254.0.0/16 dev virbr0 scope link metric 1000 linkdown
172.17.0.0/16 dev docker0 proto kernel scope link src 172.17.0.1 linkdown
192.168.0.0/24 dev enp2s0 proto kernel scope link src 192.168.0.110 metric 100
192.168.1.0/24 dev wlp3s0 proto kernel scope link src 192.168.1.104 metric 600
192.168.122.0/24 dev virbr0 proto kernel scope link src 192.168.122.1 linkdown
一些尝试
如果禁用有线网卡,则可以使用 route2 的公网 IP 成功连接到服务器。但是我不想禁用有线网卡,因为它所连接的网络具有更高的上传速度。不幸的是,我无权配置连接到有线网卡的路由器1。
另一个事实是,连接到 route2 的另一台机器可以使用我服务器的私有 IP 连接到我的 ubuntu 服务器。
答: 暂无答案
评论