I am trying to provide L3 connectivity between two remote LAN networks (10.0.0.0/24, 10.0.1.0/24) using OpenVPN with the following setup:
+----------------+ +---------------------+ +---------------------+
|VM A | |VM B (OpenVPN Server)| |VM C (OpenVPN Client)|
|eth0:10.0.0.5/24|--|eth0:10.0.0.4/24 | |eth0:10.0.1.4/24 |
+----------------+ |tun0:10.8.0.1/32 |==|tun0:10.8.0.2/32 |
+---------------------+ +---------------------+
Providing following IP table rule:
iptables -t nat -A POSTROUTING -o eth0 -j SNAT --to-source 10.0.0.4
Pinging VMC->VMA(10.0.0.5) ICMP echo request's IP is SNATed correctly on VM B:
VM-B# tcpdump -i eth0 icmp
09:27:36.170555 IP 10.0.0.4 > 10.0.0.5: ICMP echo request, id 4049, seq 2, length 64
09:27:36.171201 IP 10.0.0.5 > 10.0.0.4: ICMP echo reply, id 4049, seq 2, length 64
But pinging VMA->VMC(10.0.1.4) echo reply's IP is NOT SNATed on VM B:
VM-B# tcpdump -i eth0 icmp
09:33:31.791095 IP 10.0.0.5 > 10.0.1.4: ICMP echo request, id 6590, seq 2, length 64
09:33:31.795299 IP 10.0.1.4 > 10.0.0.5: ICMP echo reply, id 6590, seq 2, length 64
which in my case results in dropping the packet by other underlying (VM's host machine) anti-spoofing iptables rules to prevent IP spoofing.
I don't understand why is the ICMP echo reply packet not being SNATed properly and how to make it happen. Thank you.