Network restart and additional routes
I have two routes that are added to my routing table upon boot. I have commands in rc.local that add these routes.
When I restart networking on this machine, these routes dissappear. Duh right? Where can I put them such that they will reappear when I restart networking on my machine? I am using a RH machine... |
Put'em in the networking script. On Slack, they're called rc.inet1 and rc.inet2.
|
u can use /etc/sysconfig/static-routes file in redhat. (from /etc/rc.d/init.d/network file)
but adding static routes in this file a tille defference. if u want to add a route u type in terminal like this: #route add -net 192.168.20.0 netmask 255.255.255.0 gw 192.168.0.1 but if u wanna add same touting by using this file, use the following syntax any net 192.168.20.0 netmask 255.255.255.0 gw 192.168.0.1 it will read the static routes file when u restart network. |
awesome, thanks guys!
|
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 with the contents ADDRESS0=xx.xx.xx.xx NETMASK0=255.255.xxx.yyy GATEWAY0=192.168.30.24 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. Hope it helps, mlp |
thnx mlp68
your suggest is better than mine. |
All times are GMT -5. The time now is 12:56 AM. |