Asstance with a persistent static route - Ubuntu 8.04

Bob24

Member
Joined
Oct 14, 2008
Messages
11
Reaction score
0
Hi

I need to add a persistent route in Ubuntu. Just adding a static route is easy - ususally something along the lines of "route add -net <ip address> netmask <subnet ip> gw <gateway ip>...

Now making it persistent in Windows merely means adding a "-p" to the string. Not so in Ubuntu it seems. One forum suggested going to /etc/network/if-up.d and adding a file named static-route and inserting the following data

#!/bin/sh
# Set static routes
#
# /sbin/route add -net 1.1.1.1 gw 1.1.1.2 netmask 255.2.2.2.2

This is exactly how mine looks apart from modding my actual ip addresses before posting. Now this doesn't work. Is my format correct or is there another way (a better way) of doing this?

Thanks
 
in your /etc/network/interfaces file.

add this line under the desired interface

up /sbin/route add -net 1.1.1.1 gw 1.1.1.2 netmask 255.2.2.2.2

this is example of my /etc/network/interfaces ...
auto eth0
iface eth0 inet static
address 172.18.63.34
netmask 255.255.255.240
network 172.18.63.32
broadcast 172.18.63.47
up /sbin/route add -net 172.18.0.0/16 gw 172.18.63.46
down /sbin/route del -net 172.18.0.0/16 gw 172.18.63.46
 
Dade

My interfaces file currently has this:

auto lo
iface lo inet loopback

I connect through a Netgear USB WLAN device which I had to install using NdisWrapper - I don't use the regular NIC at all (im not even sure it's installed tbqh). Is that why my interfaces files doesnt list lan devices?

My network connections button has 2 names, "lo" and "wlan0" the latter I assume is the wireless device? So I should substiture eth0 for wlan0 when adding my line???

(Ive had Ubuntu for a 5 days now... Just to give you an idea of where I am.)
 
in the terminal ...

sudo -s

echo '/sbin/route add -net 1.1.1.1 gw 1.1.1.2 netmask 255.2.2.2.2' > /sbin/myroute

chmod +x /sbin/myroute

ln -s /sbin/myroute /etc/rc2.d/S99myroute

This is probably not the best way of doing it but will do what you want.
 
Ya, was gonna say you should make sure it's executable too
 
Top
Sign up to the MyBroadband newsletter
X