View previous topic :: View next topic |
Author |
Message |
Klavs Guru
![Guru Guru](/images/ranks/rank_rect_3.gif)
![](images/avatars/5492292243e8b08c7ba8ef.jpg)
Joined: 22 May 2002 Posts: 536 Location: Denmark
|
Posted: Mon Apr 19, 2004 6:51 am Post subject: [SOLVED]handling default routes - multiple interfaces |
|
|
Hi guys,
I have continued the last question in the proper the thread - https://forums.gentoo.org/viewtopic.php?t=122435
I have a portable computer, where I sometimes use my wireless network(wlan0), and sometimes my wired (eth0).
I would very much like to setup my routing (default route actually) so it prefers my wired (if it's there) and otherwise chooses my wireless. Or atleast, that it just maintains one default route.
Currently, when I up and then down my wired it looses the default route, which should have been restored/set to my wlan0 gateway, when downing.
How do you guys handle that?
p.s. I would like to use ifplugd to handle up/down'ing of my eth0 - but it uses the net.eth0 init-script and it does not do its job properly (as stated above).
IMHO its a bug - but perhaps I've just not configured it correctly? _________________ Best regards,
Klavs Klavsen
Denmark
Working with Unix is like wrestling a worthy opponent.
Working with windows is like attacking a small whining child
who is carrying a .38.
Last edited by Klavs on Tue Apr 20, 2004 6:57 am; edited 2 times in total |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
Klavs Guru
![Guru Guru](/images/ranks/rank_rect_3.gif)
![](images/avatars/5492292243e8b08c7ba8ef.jpg)
Joined: 22 May 2002 Posts: 536 Location: Denmark
|
Posted: Mon Apr 19, 2004 12:44 pm Post subject: |
|
|
Doesn't anybody have the same problem? If not - how do you handle several interfaces - where some of them may be unplugged at any time (ie. a wireless and a wired connection in your portable f.ex. ![Smile :)](images/smiles/icon_smile.gif) _________________ Best regards,
Klavs Klavsen
Denmark
Working with Unix is like wrestling a worthy opponent.
Working with windows is like attacking a small whining child
who is carrying a .38. |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
Klavs Guru
![Guru Guru](/images/ranks/rank_rect_3.gif)
![](images/avatars/5492292243e8b08c7ba8ef.jpg)
Joined: 22 May 2002 Posts: 536 Location: Denmark
|
Posted: Mon Apr 19, 2004 9:06 pm Post subject: |
|
|
nobody has a portable with wireless AND wired interface, which aren't both used all the time? _________________ Best regards,
Klavs Klavsen
Denmark
Working with Unix is like wrestling a worthy opponent.
Working with windows is like attacking a small whining child
who is carrying a .38. |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
Chris W l33t
![l33t l33t](/images/ranks/rank_rect_4.gif)
![](images/avatars/gallery/Simpsons/Simpsons_-_Ralph.jpg)
Joined: 25 Jun 2002 Posts: 972 Location: Brisbane, Australia
|
Posted: Mon Apr 19, 2004 11:33 pm Post subject: |
|
|
The recent update of net.eth0 has hooks for calling functions on start (postup()) or stop (predown()) of an interface. I think that they were added to better support wireless users (https://forums.gentoo.org/viewtopic.php?t=122435). I think the solution to your problem lies in these functions. If you add something like: Code: | ### Customised route manipulations
###
postup() {
case "${1}" in
eth0) # manipulate routes for wired
# remove default route through wireless
# add default route through wired
;;
wlan0) # manipulate routes for wireless
# remove default route through wired
# add default route through wireless
;;
esac
}
predown() {
case "${1}" in
eth0) # manipulate routes for wired disappearing
;;
wlan0) # manipulate routes for wireless disappearing
;;
esac
}
###
### end of customisation
| to the end of /etc/conf.d/net you can do whatever you like with the routes when you wired or wireless interfaces come up. I don't have the facility to test this, and the syntax might be slightly different (are runscripts essentially bash scripts or not?). _________________ Cheers,
Chris W
"Common sense: The collection of prejudices acquired by age 18." -- Einstein |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
Klavs Guru
![Guru Guru](/images/ranks/rank_rect_3.gif)
![](images/avatars/5492292243e8b08c7ba8ef.jpg)
Joined: 22 May 2002 Posts: 536 Location: Denmark
|
Posted: Tue Apr 20, 2004 6:50 am Post subject: |
|
|
I only added this to predown - and it works beautifully:
predown() {
wireless_down ${1}
case "${1}" in
eth0) #switch to backup routes through wireless
# add default route through wired
route add default gw 10.0.0.2 #ugly - needs to use the DHCP settings or something.
;;
wlan0) # manipulate routes for wireless
# remove default route through wired
# add default route through wireless
;;
esac
return $?
}
Thanks.
Now I have one ANNOYING problem left.
According to the latest wireless-config ebuild, my /etc/init.d/net.wlan0 is a symlink to /etc/init.d/net.eth0 - but if I restart /etc/init.d/ntp-client (it has need net) it ALWAYS starts up eth0.
Shouldn't net.wlan0 being started fullfill its need for net?
I want the init-system to be able to handle this correctly - as net is fullfilled as long as one interface is up.
any ideas? _________________ Best regards,
Klavs Klavsen
Denmark
Working with Unix is like wrestling a worthy opponent.
Working with windows is like attacking a small whining child
who is carrying a .38. |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
|