I'am wondering how to forwarding traffic from a gateway to subnet.
I have this working setup, Host A behind tunnel can ping HOST B 10.151.0.1 but not HOST C 10.151.0.2.
If I TCPDUMP packet on HOST B 10.151.0.1 ( the subnet gateway ), I see the ping on the interface
tcpdump: listening on eno1, link-type EN10MB (Ethernet), capture size 262144 bytes
(host A)10.0.1.18 > (host c)10.151.0.2: ICMP echo request, id 21863, seq 7, length 64
So the packet arrive on ( host b) 10.151.0.1 but no forwarding to 10.151.0.2 host C. I see nothing come on the host C interface.
I have enable ip forwarding and add this iptables rules ( Host B):
iptables -t nat -A POSTROUTING -o eno1 -j MASQUERADE
iptables -A FORWARD -i eno1 -o eno2 -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A FORWARD -i eno2 -o eno1 -j ACCEPT
I also try to add this route to Host C:
ip route add 10.151.0.0/30 via 10.151.0.2 dev eno2
Maybe someone can help me ? thanks a lot
I try to avoid multiple host to host ipsec by adressing a whole subnet. By the way Host B 10.151.0.1 can ping 10.151.0.2 ;-)
UPDATE 1: I can now ping HOST A FROM HOST C with proxy ARP:
echo 1 > /proc/sys/net/ipv4/conf/eno2/proxy_arp
Magic happen:
root@hostC:/home/administrateur# ping 10.0.1.21
PING 10.0.1.21 (10.0.1.21) 56(84) bytes of data.
64 bytes from 10.0.1.21: icmp_seq=1 ttl=62 time=16.0 ms
64 bytes from 10.0.1.21: icmp_seq=2 ttl=62 time=16.0 ms
BUT i always cant ping host C from From Host A, but ping between Host A and B is ok
UPDATE2: Remove this from HOST B and all works:
/sbin/route add -net 10.0.1.0 netmask 255.255.255.0 gw 10.151.0.1
/sbin/iptables -t nat -A POSTROUTING -o eno1 -j MASQUERADE
All hosts can ping all host, subnet to subnet working :)