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?
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It only takes a minute to sign up.
Sign up to join this communityYou 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.
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.
exit 0
- appending to it does nothing. This is already a sign that this is more a general and not ubuntu specific answer that has been checked in practice. Next to that problem, adding the route into that file even if executed did not work for me. The route was not added on boot. The file is executable.