Summary: | no designated way to add static routes in gentoo(/etc/conf.d/local.start is kludgy) | ||
---|---|---|---|
Product: | Gentoo Linux | Reporter: | David Bryson (RETIRED) <mutex> |
Component: | [OLD] Unspecified | Assignee: | Aron Griffis (RETIRED) <agriffis> |
Status: | RESOLVED FIXED | ||
Severity: | enhancement | CC: | azarah, crook, m.debruijne, olivier.van.acker, rajiv, releng, spock, wes, williamh, xray |
Priority: | High | ||
Version: | unspecified | ||
Hardware: | All | ||
OS: | Linux | ||
Whiteboard: | |||
Package list: | Runtime testing required: | --- | |
Bug Depends on: | |||
Bug Blocks: | 44184 | ||
Attachments: |
adds static routes support to the net interface
patch adds possibility to define static routes to net.ethN /etc/conf.d/router /etc/init.d/router replacement net.eth0 script |
Description
David Bryson (RETIRED)
2003-04-20 17:40:46 UTC
please attach the patch here Created attachment 11196 [details, diff]
adds static routes support to the net interface
The method for adding a route to network interface is as follows
route_eth0="add -net 10.2.1.0 netmask 255.255.255.0 gw 10.1.1.2"
very similar to debian ;-) although debian's system is a bit more flexible
with being able to add keywords at the beginning of the line like
up,down,pre-up,post-down. For denoting when the following command should be
executed.
At any rate i have a preliminary patch, but couldn't figure out a clean way to
add more than one route, i thought about
route0_eth0="add -net 10.2.1.0 netmask 255.255.255.0 gw 10.1.1.2"
route1_eth0="add -net 10.3.1.0 netmask 255.255.255.0 gw 10.1.1.2"
but that didn't lend itself well to neat code. this patch at least starts
thing s in a good direction
I'll try to handle this in the soon-to-come gentoo-net, but I'm going on vacation next week. No telling if I will work on it or not :) In the mean time, it could be added to the regular boot scripts? Well? It's been over a month with no updates on this. I was going to file a bug (which is now this comment instead) on nfsmount being called before local.start (which was the recommended place to add static routes). So has there been any action? Well, the patch _is_ sitting there, I could try to come up with a different way of doing it. I was told that the network layer was going to be re-written, but that hasn't happened yet either. Would it be possible to either commit this patch, or add a similar one that maybe handles more than route per interface ? i'll see if I can whip something up I would really like to work on this, but I really don't have time until August. I'll reassign it until August, when I do have time. Wout. Created attachment 13013 [details, diff]
patch adds possibility to define static routes to net.ethN
with this patch it's possible to add more than 1 static route. config syntax:
stroutes_$IFACE="target/mask_gateway [...]"
if /mask is not present it's treated like /32
The first patch didn't work for me. Everything looks right, but it just gives: * Bringing eth0 down... [ ok ] * Bringing eth0 up... [ ok ] * Setting default gateway... [ ok ] * Setting static routes...... * Failed to add static routes on eth0 [ !! ] I'll try this new one. Any news on this? How about simply allowing pre and post configs? We now have /etc/conf.d/net with the usual syntax and functionality wich is enough for most people. The /etc/init.d/net.ethX script could easily be modified to honour /etc/conf.d/net_ethX_pre and net_ethX_post files if and only if they are present. Something like this would also be useful for people using wlan since one could put pre and post config stuff for wlan cards in there, too, and not just static routes. Actually I was thinking about this the other night. Maybe a 'routes' init script, that would set everything after 'net' is configured. Although your idea of some kind of dynamic interface up/down would be nice as well. Maybe add both ? see also bug #26811. Created attachment 19219 [details]
/etc/conf.d/router
support for device independant init.d/router script which should be started
right after the net.XXX scripts
this is a protype for the config file
Created attachment 19220 [details]
/etc/init.d/router
support for device independant init.d/router script which should be started
right after the net.XXX scripts
this is a protype for the init.d file
Created attachment 27047 [details] replacement net.eth0 script Regarding the attempts in this bug so far: - /etc/init.d/router is not the right solution because routes need to be recreated when an interface is restarted. - David's patch in comment 2 isn't flexible enough I have rewritten the net.eth0 script to provide full static route configuration, enhanced output, and a better configuration syntax. Please give this a try and report back in this bug. Here are the nitty-gritty details. eth0 is used for example but of course could be any interface. - Specify routes as an array per interface, for example: routes_eth0=( "-net 10.1.0.0 netmask 255.255.0.0 gw 10.0.0.5" "-net 10.2.0.0 netmask 255.255.0.0 gw 10.0.0.6" "-host 10.3.0.1 dev eth0" ) - You can optionally use the gateway variable or just put the default route in the routes variable. The following two are REDUNDANT: routes_eth0=( "default gw 10.0.0.5" ) gateway="eth0/10.0.0.5" - Old configuration variables in /etc/conf.d/net are fully supported and used transparently if ifconfig_eth0 is missing. In other words, this new script is fully backward-compatible. However you can get rid of iface_eth0, alias_eth0, broadcast_eth0 and netmask_eth0 if you want by using the new syntax: ifconfig_eth0=( "10.0.0.6 broadcast 10.0.255.255 netmask 255.255.0.0" "192.168.1.1 netmask 255.255.255.0" "123.456.789.1" ) - Additionally many small bugs in the old script were fixed. Please respond in this bug! I have tested this extensively, but your testing will grease the skids to get this into baselayout ASAP. Here is a non-exhaustive list of features added and/or bugs fixed by this rewrite: - Full backward compatibility so no danger to screwing up users relying on existing /etc/conf.d/net setup - NET_DEBUG can be set in the environment for copious debugging output - Deprecate [ ] in favor of [[ ]] which has fewer quoting issues and better functionality (and is even slightly faster) - Properly localize all variables, including variables returned by setup_vars - Allow full options for every ifconfig command, both base address and aliases via ifconfig_eth0, replacing the convoluted and less-functional iface_eth0, alias_eth0, broadcast_eth0, netmask_eth0 - Provide full support for static routes via routes_eth0 - Fix potential quoting problems in setup_vars by using better eval syntax instead of eval echo - Display IP addresses while configuring, both DHCP-retrieved and statically set addresses - Collapse redundant caching of $? since eend returns $? again - Report when keeping kernel configuration for an interface along with IP address gleaned - Don't reset the default gateway if it is already set correctly - Don't bind default gateway to particular interface when /sbin/route is called so that it can survive if there is more than one interface on the required subnet. (Old behavior can be obtained by setting routes_eth0="default gw 1.2.3.4 dev eth0" if you really want it) - Don't bomb if default gateway can't be set since that doesn't necessarily mean that the interface configuration is invalid. (Old behavior was completely broken, but commented section demonstrates how to do it right if necessary) - iface_stop no longer relies on configuration in /etc/conf.d/net AT ALL. This is very good because it means you can put new configuration in /etc/conf.d/net, then restart the interface and the old configuration will be properly shut down. - iface_stop reports when it is releasing the DHCP lease The very latest version of this can be found at http://gentoo.org/~agriffis/net.eth0 with extremely minor changes. I'm not updating the attachment since the changes are not substantial: - report IP address of default gateway - use grep instead of egrep in one spot - localize "counter" Aron, The rewrite looks great and I tested it as you requested. It seems to work flawlessly for me in almost all respects and addresses virtually every complaint I've had about the network scripts in the past. However, I did run into one small issue, although it seems relatively minor and may be specific to my setup. I get this (100% of the time) when I bring the interface down with your new script. luna init.d # /etc/init.d/net.eth0 stop * Bringing eth0 down * Releasing DHCP lease for eth0... * Timed out [ !! ] * Stopping eth0... [ ok ] I only have one interface, eth0, on this laptop. The script does work successfully at configuring everything and brings the interface down regardless, including the static route. In that sense this seems to be mostly cosmetic for me but might be symptomatic of some bug or difficulty. Thanks for the feedback, Jeff. I've fixed the problem and updated the version at http://dev.gentoo.org/~agriffis/net.eth0 I guess I forgot to close this. It's fixed in recent baselayouts, for example baselayout-1.8.11 |