I have two interfaces on server machine. The output of ip route
is next:
default via 192.168.100.1 dev enp1s0 proto static metric 100
10.8.0.0/24 dev tap0 proto kernel scope link src 10.8.0.1
192.168.100.0/24 dev enp1s0 proto kernel scope link src 192.168.100.201 metric 100
and ip address
is next (MACs are hidden):
...
1: enp1s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether **:**:**:**:**:** brd ff:ff:ff:ff:ff:ff
inet 192.168.100.201/24 brd 192.168.100.255 scope global noprefixroute enp1s0
valid_lft forever preferred_lft forever
inet6 fe80::1409:66c6:eb0d:22a1/64 scope link noprefixroute
valid_lft forever preferred_lft forever
2: tap0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UNKNOWN group default qlen 100
link/ether **:**:**:**:**:** brd ff:ff:ff:ff:ff:ff
inet 10.8.0.1/24 brd 10.8.0.255 scope global tap0
valid_lft forever preferred_lft forever
inet6 fe80::85:5fff:fe98:6cb7/64 scope link
valid_lft forever preferred_lft forever
The /proc/sys/net/ipv4/ip_forward
value is 1; firewall is disabled.
That I want is to access 192.168.100.1 from 10.8.0.100. Accessing web-server (which is listening all ports on this machine) through curl --interface 10.8.0.100 http://10.8.0.1
works fine. But curl --interface 10.8.0.100 http://192.168.100.201
output is Network unreachable
.
Curl initiates an tcp handshake and push packet to 10.8.0.100 interface. The packet then reaches server machine on 10.8.0.1. The server looks into packet dest and sees that it is 192.168.100.201. Then it look into routing table and sees that 192.168.100.201 is local.
Now the answer is going back. The sender was 10.8.0.100. Looking to the routing table we can found that it accessible through tap0
, which is local. So now it pushes into tap0
and reaches 10.8.0.100.
But actually - it isn't. Is this because my train of thought is wrong? I thought that the information provided by described table is enough to determine how to forward packets. Is this actually incomplete?