1

I have a VM with two interface one interface is for management purpose and another is for sending the traffic to the internet.

eth0 10.50.243.141/24 --> Management

eth1 10.50.240.141/24 gw 10.50.240.57

I will be managing the VM from subnet 10.50.140.0/24 so I want to add one permanent route for the subnet 10.50.140.0/24 such that traffic goes through eth0. For that I have added on route in the /etc/network/

up route add -net 10.50.140.0/24 gw 10.50.243.75 dev eth0

But this is not working

If I add a route normally on the terminal it works.

route add -net 10.50.140.0/24 gw 10.50.243.75 dev eth0
Kalle Richter
  • 6,180
  • 21
  • 70
  • 103

2 Answers2

1

you can try by adding to /etc/network/interfaces

post-up /sbin/route add -net 10.50.140.0 netmask 255.255.255.0 gw 10.50.243.75 dev eth0

you can take help from another askubuntu question How to set static routes in Ubuntu Server?

pl_rock
  • 11,297
  • oh, you beat me to the answer. what is the difference between up and post-up - would you know? – hiro protagonist Oct 10 '15 at 15:20
  • up command i have not used still but i have used post-up many time and it works according to manual it say : post-up Run command after bringing the interface up. If this command fails then ifup aborts, refraining from marking the interface as configured (even though it has really been configured), prints an error message. http://manpages.ubuntu.com/manpages/saucy/man5/interfaces.5.html – pl_rock Oct 10 '15 at 15:38
0

you can edit your /etc/network/interfaces and add lines like

up route add -net  10.50.140.0/24 gw 10.50.243.75 dev eth0

to your static ip definition as described for example here.