May 28 2020 12:04 PM - edited May 28 2020 12:05 PM
Hello
I am trying to use IPtables and it's NAT functionality in a Linux VM in Azure to make a network connection work. I have a RHEL Linux VM in Azure. It has two interfaces eth0 & eth1. I have a Windows Server VM behind this linux box with their route pointing to eth0.
My goal here is for the traffic entering my Linux VM through eth0 targeting a DEST IP ADDRESS should be forwarded to eth1 of the Linux VM and the traffic should be applied a Source NAT with the eth1 IP address
I added the below iptables rule to forward all the traffic entering through eth0 to eth1 and made sure this is in the top of the FORWARD chain
$iptables -A FORWARD -i eth0 -d DEST IP ADDRESS -o eth1 -j ACCEPT
I used the below command to enable the IP forwarding in my linux box
sysctl -w net.ipv4.ip_forward=1
I used the below command so that, all the traffic leaving through eth1 will be applied a Source NAT with the eth1 IP address
$iptables -t nat -A POSTROUTING -d DEST IP ADDRESS -o eth1 -j MASQUERADE
Now when I start testing, I see the traffic that I am generating to the DEST IP Address hitting the eth0 interface but I do not see that traffic being forwarded to eth1. Packet capture on eth1 doesn't show any traffic I also have my default route on the Linux machine pointing to eth1
Can anyone please help me understand where I went wrong and how can I make this work?