4

I want to add a route permanently.

I've tried route add -net @ip netmask mask gw "gw" but every time when I shut down, I have to re-enter the command.

How can I make this route permanently?

2 Answers2

8

You set static routes in /etc/network/interfaces An example entry would be

auto eth0
allow-hotplug eth0
iface eth0 inet static
        address 10.70.201.5
        netmask 255.255.255.192
        ### Ubuntu Linux add persistent route command ###
        post-up route add -net 10.0.0.0 netmask 255.0.0.0 gw 10.70.201.6

This sets a static address and mask and finally adds a static route.

Jan
  • 12,931
  • 3
  • 34
  • 39
0

Just add that command to /etc/rc.local.

It's pretty simple, just run this command: sudo echo "route add -net @ip netmask mask gw \"gw\"" >> /etc/rc.local.

Any commands in /etc/rc.local are automatically run towards the end of the boot process, though when you install a fresh, Ubuntu-proper installation it shouldn't have anything in it.