I have 2 EC2 instances that run Ubuntu (VM1: 172.0.1.11
and VM2: 172.2.1.12
).
I want to make a default Gateway to my Routers R1which its addresses are the following respectively 172.0.1.8
and 172.2.1.13
.
In VM1: I did sudo ip route add default via 172.0.1.8
. On the other side, in VM2: sudo ip route add default via 172.2.1.13
. Both routes are working.
However, when I reboot the instances, I lose that default route.
Is there any way to permanently save the default route?
I tried in both sides the following code modifying /ect/network/interfaces?
auto eth0
iface eth0 inet static
address 172.2.1.10 (172.0.1.11 VM1)
netmask 255.255.255.240
up route add -net 172.2.0.0 (172.0.0.0) netmask 255.255.0.0 gw 172.2.1.13 (172.0.1.8)