k

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 192.168.1.0/24 -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 169.254.169.254 via 192.168.1.1 dev eth0;
ip route replace default via 192.168.1.2

Make persistent:

nano /etc/network/interface

auto eth0
iface eth0 inet static
    address 192.168.1.3
    gateway 192.168.1.2

.