Just wanted to add my $0.02 to say that jrwsod has the correct answer (and, IMHO, is correct for chastising those who use the rc files to do this.)
|
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 ADDRESS0=0.0.0.0 GATEWAY0=192.168.1.1 NETMASK0=0.0.0.0 |
add it to /etc/rc.local
Ad your commandline to /etc/rc.local and it be run each time the computer starts
|
NO! NO! NO!
This does NOT belong in the rc files! It belongs in /etc/sysconfig/network-scripts/route-{interface} If you put it where it belongs, it will get executed when the interface is initialized, which is when it is supposed to happen. |
Quote:
|
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. |
the right way to add/delete a permanent route
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. |
thank you for the great discussion
googling on static routes and found some useful documentation, hopefully it will be useful for other. https://www.centos.org/docs/5/html/5...ic-routes.html Regards, auroraflame |
If it's just the default gateway, you can add a GATEWAY statement in the ifcfg-eth<N> file.
|
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 eth0I know this thread is ancient but I found it when I need a hand and hope the above helps someone else. MarkyD |
Of course, assuming that your ethN device doesn't change...
|
Que?
|
route-eth9
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 . |
All times are GMT -5. The time now is 01:25 AM. |