Configure SDN NAT Internet Gateway Server - UpCloud

In order to make this work, “source IP filtering” will need to be “disabled” on the private interface “SDN” gateway machine

1st Gateway machine:

Usefull packages:

apt update && apt install iptables net-tools

IP forwarding allows the VM to forward packets to target:

echo net.ipv4.ip_forward=1 >> /etc/sysctl.conf

sysctl -p

Find the networks private IP:

ip route

iptables -t nat -A POSTROUTING -s -o eth0 -j MASQUERADE

To persist these changes so that the NAT rule is automatically enabled when the VM:

apt install iptables-persistent

#iptables-save > /etc/iptables/rules.v4

2nd Configure Backend Machine:

Check gateway IP and add it to the VM routes:

ip route

ip route add via dev eth0;
ip route replace default via

Make persistent:

nano /etc/network/interface

auto eth0
iface eth0 inet static