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.
Thanks jrwsod, your instructions were great. I finally got my default gateway to stick by adding the following to
/etc/sysconfig/network-scripts/route-eth2
It will work only if you have just one network interface and if you don't change what that interface is connected to AND (and this is the big one!) no one else will ever need to try to figure out what you did.
If you put it in the right place, than the route will activate with the interface, and any admin that knows Linux will know where to find the static route you added in case it ever needs to be changed later.
I don't like to make assumptions about network topology that are likely to come back and bite someone in the hiney, and I've had my fill of dealing with systems where someone made the invalid assumption and left the mess for someone else (ie, me) to clean up.
If this is a personal machine at home, then fine... just keep in mind what you did if you change your network later.
If this is a work machine at the office, then you should really take the time to figure out how to do this correctly.
I have tested with fedora 16 to add a route to the /etc/sysconfig/network-scripts/route-{network interface}
and it worked perfectly.
note that if you add the route by using the Gnome network setting window, you will have the same result and the /etc/sysconfig/network-scripts/route-{network interface} will be created if it wasn't exist.
wow who would have thought adding a static route in Linux would be such a pain in the arse! I mostly use Debian based stuff I get a little out of my comfort zone with RH & CentOS but FreePBX runs on CentOS so I have to play on the dark side of the force ;-)
Reading the above I think at some stage all was true but things have moved on, I read the above, got confused and carried on reading http://www.softpanorama.net/Net/Netu...in_linux.shtml that article proved the most useful and what this post is based upon.
My system is CentOS which is a host for FreePBX and I need a static route pointing to a private internal network. The way that worked for me was to add a new file to /etc/sysconfig/network-scripts called route-eth0 ... here are the contents:
default 192.168.0.1 dev eth0
192.168.2.0/24 via 192.168.0.254 dev eth0
I know this thread is ancient but I found it when I need a hand and hope the above helps someone else.
Here is what a /etc/sysconfig/network-scripts/route-eth8 file looks like using Stornext File System :
default via 17.218.184.174 dev eth8
17.218.184.179 via 17.218.184.174 dev eth8
17.111.120.5 via 17.218.184.1 dev eth8
17.111.120.133 via 17.218.184.1 dev eth8
17.218.184.172 via 17.218.184.174 dev eth8
17.111.120.6 via 17.218.184.1 dev eth8
17.111.120.134 via 17.218.184.1 dev eth8
17.218.184.173 via 17.218.184.174 dev eth8
Adding it here for comparison. Hopefully it helps get you what you are seeking .
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.