1

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.8and 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)
1
  • 2
    What version of Ubuntu do you use? Recent releases have migrated to new network configuration system - netplan. Jun 3, 2019 at 14:49

3 Answers 3

0

You should add in file /etc/network/interfaces line like this:

gateway 172.0.1.8

(for VM1) and

gateway 172.0.1.13

for VM2 And then restart the network or reboot the VMs

2
0

Your /etc/network/interfaces file should looks like below after adding route.

auto eth0
iface eth0 inet static
      address <IP>
      netmask 255.255.255.0
      up route add -net 192.168.0.0 netmask 255.255.0.0 gw 192.168.1.1

After that

ifdown eth0
ifup eth0

Or restart your vm.

1
  • 2
    It didn't work. I tried the given modification above. i could not write it in a comment
    – Tim Luka
    Jun 3, 2019 at 14:33
0

You can try this,

on VM1

auto eth0
iface eth0 inet static
...
up route add default via 172.0.1.8 dev eth0

on VM2

auto eth0
iface eth0 inet static
...
up route add default via 172.2.1.13 dev eth0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .