route is a command to let you view and change the contents of the
routing table.
See
AboutThesePages.
Contents
Notes
Examples
route add -net 192.168.0.0 netmask 255.255.255.0 dev eth0
route
route add default gw 192.168.0.1
Making Permanent Changes
(from a post 28 Apr 2003 post by Thomas Lamy to
debian-isp@listsPLEASENOSPAM.debian.org):
You can make changes to the routing table effectively permanent by adding lines like:
up route add -net 192.168.0.0 netmask 255.255.0.0 gw 1.2.3.4
to the /etc/network/interfaces file on some *nix computers (neither the file nor the man interfaces page exists on my Mandrake 9.0 system — the suggestion was made on a Debian mailing list IIRC). Lines should be added in the same interface block the gateway address is in (and indented with a <tab>).
Is that only if they are routed via the gateway? "All "up" commands are executed when the corresponding interface comes up. There are also "pre-up", "down" and "post-down", which you don't need here. man 5 interfaces is your friend."
Clearly the changes aren't really permanent, instead, the changes are made everytime the interface is activated (brought up).
Here's another post on the same subject, with more alternatives (with minor editing, more to be done):
Re: Re making routes permanent
Date: Thu, 1 May 2003 10:44:07 +1000
From: Craig Sanders <cas@taz.net.au>
> i currently have 2 route add -net statments in my inittab file..
inittab is the wrong place for route statements.
Unless you want to use a routing daemon like zebra (which is overkill for this job), look at the man page for interfaces(5), the "up" command is probably what you want.
E.g. something like this in /etc/network/interfaces:
iface eth0 inet static
address x.x.x.x
netmask 255.255.255.0
broadcast x.x.x.255
up route add -net y.y.y.y gw z.z.z.z
up route add -net a.a.a.a gw z.z.z.z
Alternatively, create a new script in /etc/init.d (and make sure it runs at the appropriate time during the desired run-levels with update-rc.d) or just make a simple script in /etc/rc.boot.
The above works for static interfaces like Ethernet cards. For dynamic interfaces (i.e. that are likely to go up and down between reboots) you need to make sure that the routes are re-established when the interface goes up.
If the routes go via a ppp (or pppoe) interface, then you need to add routing commands to a script in /etc/ppp/ip-up.d.
If the routes are via a tunnel then set the routes in the configuration of whatever tunneling software you are using (e.g. /etc/vtund.conf for vtun).
Resources
See
ResourceRecommendations. Feel free to add additional resources to these lists, but please follow the guidelines on
ResourceRecommendations including
ResourceRecommendations#Guidelines_for_Rating_Resources.
Recommended
Recommended for Specific Needs
<Currently, no significant content below this line.>
Recommended by Others
No Recommendation
Not Recommended
Contributors
- () RandyKramer - 23 Jul 2002
- <If you edit this page: add your name here; move this to the next line; and include your comment marker (initials), if you have created one, in parenthesis before your WikiName.>
[[Main.RandyKramer#23 Jul 2002][]]
Page Ratings