I cannot connect from my Ubuntu server (10.10.57.5) back to my personal PC (10.15.0.4) which is on a different local network.
The server has the following ifconfig:
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 9001
inet 10.10.57.5 netmask 255.255.255.0 broadcast 10.10.57.255
inet6 fe80::9b:3eff:feb0:d6a2 prefixlen 64 scopeid 0x20<link>
ether 02:9b:3e:b0:d6:a2 txqueuelen 1000 (Ethernet)
RX packets 10377 bytes 1620625 (1.6 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 10810 bytes 1148431 (1.1 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
eth1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 9001
inet 10.10.20.5 netmask 255.255.255.0 broadcast 10.10.20.255
inet6 fe80::21:19ff:fe16:76c0 prefixlen 64 scopeid 0x20<link>
ether 02:21:19:16:76:c0 txqueuelen 1000 (Ethernet)
RX packets 3319 bytes 181799 (181.7 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 3332 bytes 220914 (220.9 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 213405 bytes 116842426 (116.8 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 213405 bytes 116842426 (116.8 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
I connect to it through 10.10.57.5, and 10.10.20.0/24 is another network that cannot be reached externally.
This is the route info:
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default _gateway 0.0.0.0 UG 100 0 0 eth0
10.10.20.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1
10.10.57.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
_gateway 0.0.0.0 255.255.255.255 UH 100 0 0 eth0
If I try to ping my local machine from the server, it obviously does not return anything as it’s outside the network:
$ ping -c3 10.15.0.4
PING 10.15.0.4 (10.15.0.4) 56(84) bytes of data.
--- 10.15.0.4 ping statistics ---
3 packets transmitted, 0 received, 100% packet loss, time 2048ms
Then, I tried to configure the network like this:
ifconfig lo:100 10.8.0.1 netmask 255.255.255.0 up
And suddenly, the ping command suddenly works:
$ ping 10.15.0.4
PING 10.15.0.4 (10.15.0.4) 56(84) bytes of data.
64 bytes from 10.15.0.4: icmp_seq=1 ttl=64 time=0.018 ms
64 bytes from 10.15.0.4: icmp_seq=2 ttl=64 time=0.036 ms
64 bytes from 10.15.0.4: icmp_seq=3 ttl=64 time=0.035 ms
64 bytes from 10.15.0.4: icmp_seq=4 ttl=64 time=0.034 ms
^C
--- 10.15.0.4 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3079ms
However, I cannot see anything in my tcpdump in my local machine:
root@zldes:/tmp# tcpdump -i tun0 icmp
tcpdump: verbose output suppressed, use -v[v]... for full protocol decode
listening on tun0, link-type RAW (Raw IP), snapshot length 262144 bytes
Finally, if I host a server on my local machine:
root@zldes:~/tmp# python -m http.server 9090
Serving HTTP on 0.0.0.0 port 9090 (http://0.0.0.0:9090/) ...
It cannot be reached from the server:
$ wget http://10.15.0.4:9090/users.txt
--2022-04-22 10:23:02-- http://10.15.0.4:9090/test.txt
Connecting to 10.15.0.4:9090... failed: Connection refused.
If also tried to add a new route without success:
$ route add -net 10.15.0.0 netmask 255.255.255.0 gw 10.15.0.254
SIOCADDRT: Network is unreachable
What am I missing?