LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices



Reply
 
Search this Thread
Old 12-04-2012, 02:02 PM   #1
mudtoe
LQ Newbie
 
Registered: Mar 2009
Posts: 6

Rep: Reputation: 0
Question Bringing routes up only when link state is active


Hi folks:

I've got a Ubuntu 11.04 VM that I'm trying to setup a backup LAN route on. It's a migration of a physical machine onto a VMWare ESXi white box. I've got a backup LAN setup on the ESXi white box using wireless and I wanted to be able to allow this VM to use that backup network if the regular hardwired LAN is down for some reason.

The problem I'm having is that I can't seem to prevent the hardwired primary LAN default route from being active as long as eth0 is up, even if the link is down (i.e. no cable connected). When that happens if I try to connect to the system via the backup wireless lan subnet, the routing table sends the packets back over the primary default gateway route, which of course is down. I can fix this by doing "ifdown eth0" which clears the routing table of the primary lan default route, leaving the backup default route (which has a higher metric #) active, but I'd like that functionality to work simply by virtue of whether or not the link state is up versus having to do that manually. Is there any way to do that? I've tried using the post-up configuration settings in the interfaces file, but it looks like those only pay attention to whether eth0 is enabled or not, and based on the link state.

Suggestions welcome.

mudtoe

Last edited by mudtoe; 12-04-2012 at 02:06 PM.
 
Old 12-04-2012, 05:20 PM   #2
mmheera
Member
 
Registered: Oct 2012
Location: Germany
Distribution: Ubuntu, Debian, Fedora,Windows 7
Posts: 107

Rep: Reputation: 11
Are you looking for something like policy based routing in Linux? Then you may have a look at this:

http://www.lartc.org/howto/lartc.rpd...ple-links.html

Thanks!
 
Old 12-05-2012, 03:00 PM   #3
mudtoe
LQ Newbie
 
Registered: Mar 2009
Posts: 6

Original Poster
Rep: Reputation: 0
I'm already using that with a Vyatta router VM in this same box. I've got an internal subnet setup within the ESXi box. The internal subnet is 172.24.99.xx, the external hardwired subnet is 172.24.222.xx, and the external wireless subnet is 172.24.221.xx. The Vyatta router VM controls the internal subnet and can route traffic from that subnet to the wireless external subnet. The other VMs in the box have access to the internal subnet and the hardwired external subnet.

What I wanted to be able to do, for testing purposes, is access the VMs in the box from a computer on the external hardwired subnet via the internal subnet. This works with a windows VM as long as the external hardwired subnet is disconnected (i.e. nic cable disconnected) and you don't actually have to mark the nic as disabled. However, with Linux it looks like you have to actually disable the eth0 interface (ifdown), rather than just use VMWare to simulate disconnecting the cable, in order to get the routing table to remove the default routes for that interface.

What that basically means is that if the external hardwired network fails I will have to use VMWare to login to the Ubuntu VM via the local console and manually disable eth0 with ifdown in order to get the backup connection to fully work. While I will be able to do that because the Vyatta VM will allow me to access the VMWare interface using the backup wireless network, it won't work without manual intervention, which is what I'm trying to avoid.


mudtoe
 
Old 12-05-2012, 05:20 PM   #4
mmheera
Member
 
Registered: Oct 2012
Location: Germany
Distribution: Ubuntu, Debian, Fedora,Windows 7
Posts: 107

Rep: Reputation: 11
Sorry to say but, your scenario is not fully clear to me, guess with a network diagram it would be better understandable.
Anyway, maybe you need dynamic routing, something like OSPF. Then routing tables can be dynamically updated automatically. You can implement OSPF using zebra in linux, but all the connected router/machine need to support that. It's not only putting the interface down for the defaults route to go, but again you will need to bring the interface up again automatically when your primary link is up.
 
Old 12-05-2012, 08:29 PM   #5
mudtoe
LQ Newbie
 
Registered: Mar 2009
Posts: 6

Original Poster
Rep: Reputation: 0
Well, I guess what it boils down to is the question of whether or not there is a way to have a script triggered when the link state of an ethernet connection changes. All the stuff I've found (e.g. pre-up, post-down, etc.) which are in /etc/network/interface only seems to be triggered when the interface itself, from a software perspective, is enabled or disabled (e.g. ifup, ifdown), and they don't appear to be triggered when just the link state changes, which seems a bit strange to me. If there is a way to trigger a script when just the link state changes then I can put the route commands I need in that script.


mudtoe
 
Old 12-05-2012, 08:33 PM   #6
unSpawn
Moderator
 
Registered: May 2001
Posts: 27,744
Blog Entries: 54

Rep: Reputation: 2973Reputation: 2973Reputation: 2973Reputation: 2973Reputation: 2973Reputation: 2973Reputation: 2973Reputation: 2973Reputation: 2973Reputation: 2973Reputation: 2973
Quote:
Originally Posted by mudtoe View Post
What that basically means is that if the external hardwired network fails I will have to (..) manually disable eth0 (..) it won't work without manual intervention, which is what I'm trying to avoid.
There are daemons that check link state and respond by running scripts.
 
1 members found this post helpful.
Old 12-13-2012, 12:55 AM   #7
mudtoe
LQ Newbie
 
Registered: Mar 2009
Posts: 6

Original Poster
Rep: Reputation: 0
Thanks for the tip. I found something called netplug that looks like it might do what I need. I'll play with it a bit and report back.


mudtoe
 
  


Reply

Tags
link, network, route, state


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to get link state of interface avinash_ag1985 Linux - Networking 6 11-16-2010 03:52 PM
Static routes using routes/ifroutes-eth-id.. files and default gateway disabled TimtheEagle Linux - Networking 0 05-31-2008 08:08 PM
Active Routes not saving on Suse 10.0 after reboot krodwill49 Linux - Newbie 1 12-07-2006 03:07 PM
How do I retrieve the link state? bb002 Linux - Networking 1 10-31-2005 02:49 AM


All times are GMT -5. The time now is 02:41 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration