Correct place to put routing configuration

My question is two fold.

I have some computers which need to have some routes to reach remote officies thru a vpn.
Those computers run Debian Etch.
Our vpn networks are 192.168.x.0 where x is 1 to 8 because we have 8 offices.

I currently configure the routes by adding some lines into /etc/network/interfaces like that :

up route add -net 192.168.1.0/24 gw 192.168.4.254
up route add -net 192.168.2.0/24 gw 192.168.4.254
up route add -net 192.168.3.0/24 gw 192.168.4.254
#up route add -net 192.168.4.0/24 gw 192.168.4.254 not this one
up route add -net 192.168.5.0/24 gw 192.168.4.254
up route add -net 192.168.6.0/24 gw 192.168.4.254
up route add -net 192.168.7.0/24 gw 192.168.4.254
up route add -net 192.168.8.0/24 gw 192.168.4.254

Question : is this the 'right' place to specify routes ? Or any better place ?

If I replace the 8 routes by only one, everything is ok.
up route add -net 192.168.0.0/16 gw 192.168.4.254
Local and distant computers can be reached. End they can reache this computer too.

Question : is this second method okay ? It works, yes, but is it the 'right' method ?

0

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Correct place to put routing

On my system, I have /etc/rc.local, which is also a convenient place to run commands at boot time. Also, that file contains comments stating that it is the last thing executed after bootup, which is probably a good thing (for example your firewall would be up).

I think the answer to your second question is that the one line is more general. I don't know if there is any disadvantage to the 192.168.0.0 line, as long as all networks 192.168.x.0 networks have the same gateway, and you don't have any 192.168.x.0's that you want to exclude.

Syndicate content