Linux - NetworkingThis forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
All true, and it'll work, but it's not the whole story. The above method helps only if you shut down and restart the whole network, which you may not do (maybe you just shut down one interface by, say, "ifdown eth0" without going through the network script). You want to selectively set up and take down the routes that are specific to an interface.
The generic way, which is admittedly a bit obscure, is to have a file
/etc/sysconfig/networking/devices/<interfacename>.route
e.g.
/etc/sysconfig/networking/devices/eth0.route
and ADDRESS1/NETMASK1/GATWAY1 for the next route, and so on
For example
ADDRESS0=192.168.7.0
NETMASK0=255.255.255.0
GATEWAY0=192.168.30.24
will add a route to the 192.168.7 network through 192.168.30.24.
The nice thing that this is network-device dependent, so the routes aren't brought on unconditionally but only when the interface actually goes up, and does not depend on a particular method.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.