Score:0

Not connecting through SSH locally

ru flag

I have a private network linking 2 servers:

server 1: IP 10.0.0.2
server 2: IP 10.0.0.3

When server 2 is using a VPN, I want to be able to connect to server 2 through server 1 using the following command from server 1:

ssh 10.0.0.3

For that I created the following rules in server 2

ip rule add table 128 from 10.0.0.3 
ip route add table 128 to 10.0.0.0/8 dev ens10
ip route add table 128 default via 10.0.0.1

From the code above, the requests going away from server 2 should be handled by table 128 and routed through esn10 (interface for private network) through the gateway 10.0.0.1.

But the problem is that when ssh to server 2 from server 1, there is no response (even with no VPN connected)

I paste here my "ip route show table all" command output after aplying the above rules

default via 10.0.0.1 dev ens10 table 128
10.0.0.0/8 dev ens10 table 128 scope link
default via 172.31.1.1 dev eth0 proto dhcp src XXX.XXX.XXX.XXX metric 100
10.0.0.0/8 via 10.0.0.1 dev ens10
10.0.0.1 dev ens10 scope link
172.31.1.1 dev eth0 proto dhcp scope link src XXX.XXX.XXX.XXX metric 100
local 10.0.0.3 dev ens10 table local proto kernel scope host src 10.0.0.3
broadcast 10.0.0.3 dev ens10 table local proto kernel scope link src 10.0.0.3
broadcast 127.0.0.0 dev lo table local proto kernel scope link src 127.0.0.1
local 127.0.0.0/8 dev lo table local proto kernel scope host src 127.0.0.1
local 127.0.0.1 dev lo table local proto kernel scope host src 127.0.0.1
broadcast 127.255.255.255 dev lo table local proto kernel scope link src 127.0.0.1
local XXX.XXX.XXX.XXX dev eth0 table local proto kernel scope host src XXX.XXX.XXX.XXX
::1 dev lo proto kernel metric 256 pref medium
2a01:4f8:c0c:8500::/64 dev eth0 proto kernel metric 256 pref medium
fe80::/64 dev eth0 proto kernel metric 256 pref medium
fe80::/64 dev ens10 proto kernel metric 256 pref medium
default via fe80::1 dev eth0 proto static metric 1024 pref medium
local ::1 dev lo table local proto kernel metric 0 pref medium
local 2a01:4f8:c0c:8500::1 dev eth0 table local proto kernel metric 0 pref medium
local fe80::8400:ff:fe2f:2640 dev ens10 table local proto kernel metric 0 pref medium
local fe80::9400:1ff:fec0:456d dev eth0 table local proto kernel metric 0 pref medium
multicast ff00::/8 dev eth0 table local proto kernel metric 256 pref medium
multicast ff00::/8 dev ens10 table local proto kernel metric 256 pref medium

This is the output of ifconfig:

ens10: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1450
        inet 10.0.0.3  netmask 255.255.255.255  broadcast 10.0.0.3
        inet6 fe80::8400:ff:fe2f:2640  prefixlen 64  scopeid 0x20<link>
        ether 86:00:00:2f:26:40  txqueuelen 1000  (Ethernet)
        RX packets 4  bytes 738 (738.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 55  bytes 6675 (6.6 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet XXX.XXX.XXX.XXX  netmask 255.255.255.255  broadcast 0.0.0.0
        inet6 XXXXXXXXXX  prefixlen 64  scopeid 0x20<link>
        inet6 XXXXXXXXXX  prefixlen 64  scopeid 0x0<global>
        ether XXXXXXXXXX  txqueuelen 1000  (Ethernet)
        RX packets 709  bytes 448296 (448.2 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 464  bytes 70581 (70.5 KB)
        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 162  bytes 14038 (14.0 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 162  bytes 14038 (14.0 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
Zareh Kasparian avatar
us flag
when you start your VPN on server 2, all your traffic is going through VPN tunnel. Thus make a static route on server 2, mentioning server 1 IP address routing to your gateway and not tunnel interface.
DericS avatar
pl flag
Is ens10 a regular Ethernet interface on server2? How was it configured? The netmask seems a bit odd, and so does the MTU. Can you add the output of "ip addr show" (or ifconfig) from Server1?
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.