Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[SOLVED] apply new static routes defined in /etc/conf.d/net
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
Vieri
l33t
l33t


Joined: 18 Dec 2005
Posts: 871

PostPosted: Fri Nov 09, 2012 2:53 pm    Post subject: [SOLVED] apply new static routes defined in /etc/conf.d/net Reply with quote

Hi,

I know how to manually delete old routes and add new ones via command line.
However, I was wondering if Gentoo has a way of doing it for me if I change the routes in /etc/conf.d/net.
Can Gentoo flush the current routing table and load the rules from the text config file without bringing down the interfaces thus losing connectivity?
ie. /etc/init.d/net.eth0 restart won't do.

Thanks,

Vieri


Last edited by Vieri on Sat Nov 10, 2012 5:49 pm; edited 1 time in total
Back to top
View user's profile Send private message
cach0rr0
Bodhisattva
Bodhisattva


Joined: 13 Nov 2008
Posts: 4123
Location: Houston, Republic of Texas

PostPosted: Sat Nov 10, 2012 6:06 am    Post subject: Reply with quote

/etc/conf.d/net is only utilized by the net.* init scripts

/etc/conf.d in general, exists solely to be used by init scripts

I don't think there's a way to do what you're looking to do. There would need to be something like e.g. a reload() function in the init script, and I don't think this exists.

Having said that, restarting the interface shouldn't kill connectivity. There is of course the danger that a broken config file could keep the script from restarting cleanly, so it's a proposition that isn't without risk, but in general:

Code:

bauer ~ # /etc/init.d/net.eth0 restart
 * Stopping syslog-ng ...                                                                                              [ ok ]
 * Stopping sshd ...                                                                                                      [ ok ]
 * Stopping FastCGI application php ...                                                                           [ ok ]
 * Stopping ntpd ...                                                                                                      [ ok ]
 * Stopping nginx ...                                                                                                    [ ok ]
 * Unmounting network filesystems ...                                                                           [ ok ]
 * Bringing down interface eth0
 *   Removing addresses
 *     192.168.1.80/24
 * Bringing up interface eth0
 *   192.168.1.80 ...                                                                                                     [ ok ]
 *   Adding routes
 *     default via 192.168.1.1 ...                                                                                     [ ok ]
 * Starting syslog-ng ...                                                                                                [ ok ]
 * Starting FastCGI application php ...
 * Starting sshd ...                                                                                                       [ ok ]
spawn-fcgi: child spawned successfully: PID: 30835                                                        [ ok ]
 * Starting ntpd ...
 * Mounting network filesystems ...                                                                                [ ok ]
 * Checking nginx' configuration ...                                                                                [ ok ]
 * Starting nginx ...                                                                                                      [ ok ]
bauer ~ # wall "I'm still connected"
bauer ~ #
Broadcast message from root@bauer (pts/0) (Sat Nov 10 00:01:49 2012):

I'm still connected

_________________
Lost configuring your system?
dump lspci -n here | see Pappy's guide | Link Stash
Back to top
View user's profile Send private message
Vieri
l33t
l33t


Joined: 18 Dec 2005
Posts: 871

PostPosted: Sat Nov 10, 2012 9:51 am    Post subject: Reply with quote

Thanks for pointing that out.
I'm going to have to continue doing it manually because I'd prefer not to bring a service down and back up just to modify the routing table (eg. network filesystems, etc.).
Or maybe customize the init.d/net* scripts and add a routes_reload function.
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54209
Location: 56N 3W

PostPosted: Sat Nov 10, 2012 10:00 am    Post subject: Reply with quote

Vieri,

Tell us about the problem you are trying to solve, rather than your perceived solution.

If we understood the problem, one of your readers may know a a solution.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
Vieri
l33t
l33t


Joined: 18 Dec 2005
Posts: 871

PostPosted: Sat Nov 10, 2012 12:09 pm    Post subject: Reply with quote

Hi,
Let me rephrase my first post if it wasn't clear enough but I think cach0rr0 got the picture (since he states what I was expecting: the lack of a "convenience" function to reload routes within the /etc/init.d/net* scripts).
Anyway the problem is simple:
users define static routes in /etc/conf.d/net for each interface in the host. In my case I have a Gentoo host running as a firewall with several physical interfaces and static routes for several of them (eth0, eth1, etc). I have quite a few route entries hence the need to find a quick way to apply them in the case I need to modify some entries.
Say I have around 7 route entries for eth0, 4 for eth1 and 2 for eth2 and they're all defined in /etc/conf.d/net.
Now imagine I modify them and would like to apply the new routes.
However, I would require not to stop/restart any services that depend on these interfaces because there's no point in doing so (I'm just changing some route entries, not bringing the interfaces down).
Even though "/etc/init.d/net* restart" may not interrupt active connections, it definitely does "restart" some network services and makes them unavailable to other clients for a short delay (the time it takes for the init.d script to run to its full extent - squid is an example of a slow init.d script to restart).
So it appears that a "reload_routes" function could be useful within the /etc/init.d/net* scripts. Basically, for each ethx this function would need to purge/delete all route entries for that device and load the new ones from "routes_ethx" in /etc/conf.d/net.
Anyway, it's not like I'm going to modify /etc/conf.d/net every day so this isn't critical of course. However, it could be useful and less error-prone if you had a lot of route rules on several devices and needed to update them on a "regular" basis.

Hope this clears any doubts.
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54209
Location: 56N 3W

PostPosted: Sat Nov 10, 2012 3:06 pm    Post subject: Reply with quote

Vieri,

Purge routes, then reload will drop exisitng links while the route vanishes.

tcp connections will do retries for a few seconds
udp will loose packets, recovery is up to applications.

It sound like what you need is leave unchanged routes alone, so you don't drop any packets then modify the routing table with deletions and additions.
Thats harder than purge and reload as you have to analyse the before and after states to work out the changes that are needed.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
Vieri
l33t
l33t


Joined: 18 Dec 2005
Posts: 871

PostPosted: Sat Nov 10, 2012 5:49 pm    Post subject: Reply with quote

Quote:
Purge routes, then reload will drop exisitng links while the route vanishes


so /etc/init.d/net* restart will also have the same effect (it will drop links).

OK, I understand what you mean.
I'll just keep doing it manually (that is, deleting and adding only the differences).
Thanks
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum