LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
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 04-09-2010, 09:33 AM   #1
Skaperen
Senior Member
 
Registered: May 2009
Location: center of singularity
Distribution: Xubuntu, Ubuntu, Slackware, Amazon Linux, OpenBSD, LFS (on Sparc_32 and i386)
Posts: 2,684
Blog Entries: 31

Rep: Reputation: 176Reputation: 176
2 or more ethernet ports - how to make the alternate work


I have 2 (some future machines will have 4) ethernet ports. I want to have them configured such that if any gets unplugged, as long as at least one of them is plugged in, it can reach the network (even if via a different IP address), and it can be reached (at least when trying a working IP address).

I tried this for /etc/network/interfaces:
Code:
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
        address 172.30.16.3
        netmask 255.255.0.0
        network 172.30.0.0
        broadcast 172.30.255.255

auto eth1
iface eth1 inet static
        address 172.30.20.3
        netmask 255.255.0.0
        metric 33
But that doesn't work. If eth1 gets unplugged, it can no longer reach the net or LAN ... except via IPv6 link-local addresses. Here is the output from "route -n" which looks wrong to me:
Code:
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
172.30.0.0      0.0.0.0         255.255.0.0     U     0      0        0 eth1
172.30.0.0      0.0.0.0         255.255.0.0     U     0      0        0 eth0
0.0.0.0         172.30.0.2      0.0.0.0         UG    1      0        0 eth1
At the time of that "route -n" command, eth1 is unplugged. How can I make the routes "go away" for that situation, and "come back" when it gets plugged back in?

What I believe SHOULD happen is:

1. There should be a default route for at least each of the working interfaces, if not all of them.

2. The metric for the interface not plugged in should be automatically set/faked at its highest possible value to effectively disable it, and restored to its configured value when that interface is plugged back in and working again.

If I unplug eth0 and plug the cable into eth1, then things start working.

Another factor in this: SOMETIMES, after a reboot, the situation is "reversed" where default route specifies eth0 instead of eth1. In that case, it works when eth0 is plugged in and eth1 is not.

Another symptom. When eth1 is unplugged, it takes 60 seconds for the system to shutdown to the point where pings (to the working IPv6 link-local addresses) stop. If both ethernets are plugged in, it only takes about 3 seconds. It appears the init scripts are stalled doing a "stop" of apache. Maybe apache is doing some DNS lookup that won't work ... during a shutdown?

Here's some more info. Note that eth1 does not have the RUNNING state and does not have an autoconfigured IPv6 Scope:link address, since it is the one without a cable plugged in. Also note how the ARP table only has entries for eth1, not eth0, and they are all incomplete (those addresses being router gateway and DNS servers in the LAN).
Code:
archimedes/root/x0 /root 6# ifconfig
eth0      Link encap:Ethernet  HWaddr 00:15:17:de:ca:28  
          inet addr:172.30.16.3  Bcast:172.30.255.255  Mask:255.255.0.0
          inet6 addr: fe80::215:17ff:fede:ca28/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:702 errors:0 dropped:0 overruns:0 frame:0
          TX packets:668 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:78528 (78.5 KB)  TX bytes:78601 (78.6 KB)
          Memory:ba820000-ba840000 

eth1      Link encap:Ethernet  HWaddr 00:15:17:de:ca:29  
          inet addr:172.30.20.3  Bcast:172.30.255.255  Mask:255.255.0.0
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
          Memory:ba800000-ba820000 

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:308 errors:0 dropped:0 overruns:0 frame:0
          TX packets:308 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:27736 (27.7 KB)  TX bytes:27736 (27.7 KB)

archimedes/root/x0 /root 7# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
172.30.0.0      0.0.0.0         255.255.0.0     U     0      0        0 eth1
172.30.0.0      0.0.0.0         255.255.0.0     U     0      0        0 eth0
0.0.0.0         172.30.0.2      0.0.0.0         UG    1      0        0 eth1
archimedes/root/x0 /root 8# cat /etc/network/routes
net 0.0.0.0/0 gw 172.30.0.2 metric 1
archimedes/root/x0 /root 9# arp -n
Address                  HWtype  HWaddress           Flags Mask            Iface
172.30.0.5                       (incomplete)                              eth1
172.30.0.6                       (incomplete)                              eth1
172.30.0.7                       (incomplete)                              eth1
172.30.0.4                       (incomplete)                              eth1
172.30.0.2                       (incomplete)                              eth1
archimedes/root/x0 /root 10# uname -a
Linux archimedes 2.6.31-20-server #58-Ubuntu SMP Fri Mar 12 05:40:05 UTC 2010 x86_64 GNU/Linux
archimedes/root/x0 /root 11#
That's Ubuntu 9.10 server, updated as of a couple days ago.
 
Old 04-09-2010, 09:45 AM   #2
Mr-Bisquit
Member
 
Registered: Feb 2009
Distribution: FreeBSD, OpenBSD, NetBSD, Debian, Fedora
Posts: 770
Blog Entries: 52

Rep: Reputation: 68
You know that this is easier with a BSD system. Each card is assigned according to the driver. If you have an amdtek, an intel, and a realtek the cards would be dc0, fxp0, and rl0 respectively.
 
Old 04-09-2010, 11:50 AM   #3
Skaperen
Senior Member
 
Registered: May 2009
Location: center of singularity
Distribution: Xubuntu, Ubuntu, Slackware, Amazon Linux, OpenBSD, LFS (on Sparc_32 and i386)
Posts: 2,684

Original Poster
Blog Entries: 31

Rep: Reputation: 176Reputation: 176
Quote:
Originally Posted by Mr-Bisquit View Post
You know that this is easier with a BSD system. Each card is assigned according to the driver. If you have an amdtek, an intel, and a realtek the cards would be dc0, fxp0, and rl0 respectively.
But would the routes be set to use all of the card ports that have working connections, without trying to ARP on an interface with nothing plugged in?

Long ago I did something like this in Linux and it worked fine. But that was Slackware and now I'm doing it with Ubuntu. Maybe I should try Debian, Fedora, or Gentoo, or go back to Slackware?
 
Old 04-10-2010, 07:49 AM   #4
TimothyEBaldwin
Member
 
Registered: Mar 2009
Posts: 249

Rep: Reputation: 27
Try changing "auto" to "allow-hotplug", if that doesn't work use ifplugd. You could use the same IP and Ethernet addresses on both interfaces.

But is just checking for a disconnected cable sufficient?
 
Old 04-12-2010, 08:39 AM   #5
Skaperen
Senior Member
 
Registered: May 2009
Location: center of singularity
Distribution: Xubuntu, Ubuntu, Slackware, Amazon Linux, OpenBSD, LFS (on Sparc_32 and i386)
Posts: 2,684

Original Poster
Blog Entries: 31

Rep: Reputation: 176Reputation: 176
Quote:
Originally Posted by TimothyEBaldwin View Post
Try changing "auto" to "allow-hotplug", if that doesn't work use ifplugd. You could use the same IP and Ethernet addresses on both interfaces.
I don't see any man page for ifplugd, and I don't want to install the package, yet (due to the tendency to start things just because they get installed, and I don't want to do that until after I know what exactly it does). Do you know if it can simply be configured to run any script (or must it use ifup/ifdown)? I have IP aliases and they are NOT configured for ifup to use (because ifup does it wrong). If I can just get ONLY the route entries changed when a cable is (un)plugged, that would do. I was thinking of having a cron script check interfaces and reload routes based on what was RUNNING and what was not. But I'd rather this be done instantly (it should just change the route metrics to highest value when the interface is unplugged and change it back when plugged in).

I can look into using the same IP on each interface. I did that for something else years ago, and it caused a lot of problems. But, this was back when this routing was not broken (e.g. back then, if I unplugged a cable, that interface was not used, and any communication that could work over another interface, did work over another interface). I know the kernel has changed the network logic many times over the years. Maybe shared IPs is fixed, now.

I wish they would fix ifup to handle IP aliases correctly (e.g. NOT treat them as individual interfaces ... which causes it to restart many daemons X times when there are X IP alias addresses ... taking a few seconds each, taking many minutes to bring things up when X is large, and causing some daemons to just shutdown and not come up at all).

I wish they would fix link local in IPv4 to operate like it does in IPv6 (e.g. it won't be used a source address unless the destination is also a link local).

Quote:
Originally Posted by TimothyEBaldwin View Post
But is just checking for a disconnected cable sufficient?
That would be a good start. Going further to check if traffic can actually flow would be harder, since the IP layer would not make a good test when more than one interface is present. If IP can't get through, it's unclear why. What is needed is a way to literally send ethernet frames to a specific interface and get something back from the switch itself. Maybe I can do that through IPv6 link local.

Just to summarize what I THINK the network stack and drivers SHOULD do ... when an interface enters an error or not-operating condition, ALL routes pointing to it should be FLAGGED to operate as if their metric was infinite (or at least the highest possible metric), without actually removing the routes or losing their administratively configured metric (or other data ... e.g. do not remove the route) ... or ... the routing logic should test the device when a route is found, and if the device is not-operational, continue the route search as if it was not a match. If I unplug a cable, there is no reason the ARP table should have any "(incomplete)" entry naming that device (at least not entered after unplugging).
 
Old 04-13-2010, 07:00 PM   #6
TimothyEBaldwin
Member
 
Registered: Mar 2009
Posts: 249

Rep: Reputation: 27
Quote:
Originally Posted by Skaperen View Post
That would be a good start. Going further to check if traffic can actually flow would be harder, since the IP layer would not make a good test when more than one interface is present. If IP can't get through, it's unclear why. What is needed is a way to literally send ethernet frames to a specific interface and get something back from the switch itself. Maybe I can do that through IPv6 link local.
Actually if the switch supports Spanning Tree Protocol, that is easy; just use the bridging. Install bridge-utils and read the bridge-utils-interfaces man page, you should probably increase the bridge priority value to ensure your server doesn't become the root bridge.
 
Old 04-13-2010, 07:29 PM   #7
nimnull22
Senior Member
 
Registered: Jul 2009
Distribution: OpenSuse 11.1, Fedora 14, Ubuntu 12.04/12.10, FreeBSD 9.0
Posts: 1,571

Rep: Reputation: 92
It may helps you, try to:
man ifcfg
 
Old 04-14-2010, 08:26 AM   #8
Skaperen
Senior Member
 
Registered: May 2009
Location: center of singularity
Distribution: Xubuntu, Ubuntu, Slackware, Amazon Linux, OpenBSD, LFS (on Sparc_32 and i386)
Posts: 2,684

Original Poster
Blog Entries: 31

Rep: Reputation: 176Reputation: 176
Code:
No manual entry for ifcfg
Did you mean "man ifconfig"? If so, maybe you can say what part of this command you think would help here.

I can look into the spanning tree. The switch surely supports it (HP ProCurve). But I don't understand how that behaviour would fix this.

I've been trying things out with different configurations with the same IP configured on both interfaces ... with various problems, and I've found that the whole proxy ARP implementation may be FUBAR. It's doing proxy ARP even when turned off. And ... even when eth1 is unplugged which means ARP requests MUST come in on eth0, it sometimes answers them with the MAC for eth1 !!! And I can't turn proxy ARP off ... it was already off.

The only way that makes things work for sure is to just NOT configure eth1 up at all (plugged in or not makes no difference). If eth1 is not configured, there's no point in even having this.
 
Old 04-14-2010, 08:52 AM   #9
Skaperen
Senior Member
 
Registered: May 2009
Location: center of singularity
Distribution: Xubuntu, Ubuntu, Slackware, Amazon Linux, OpenBSD, LFS (on Sparc_32 and i386)
Posts: 2,684

Original Poster
Blog Entries: 31

Rep: Reputation: 176Reputation: 176
Just to update ... this problem seems to be far more complex than previously thought. It seems that route settings and ARP settings are thoroughly entangled, and not in a good way. And this seems to all be because even when a physical interface is not in a RUNNING state, which the kernel knows about, it still behaves indefinitely as if it were.

There may even be 2 distinct problems, each masking the other from being clear.

It might be fine if the kernel holds off for a minute or so when the interfaces transistions from RUNNING to not. But for HOURS is just wrong. If the interface is not working, the kernel should not be trying to pretend that it is. It should NOT be routing EXCLUSIVELY to that interface.

I think maybe what I need is HSRP or VRRP for Linux.
 
Old 04-14-2010, 10:45 AM   #10
nimnull22
Senior Member
 
Registered: Jul 2009
Distribution: OpenSuse 11.1, Fedora 14, Ubuntu 12.04/12.10, FreeBSD 9.0
Posts: 1,571

Rep: Reputation: 92
Because when you unplug or plug interfaces you should do: ifup and ifdown.
Look, you can try to find "man ifcfg" in internet, because, as it was said before here, there is:
Code:
      
STARTMODE {manual*|auto|hotplug|ifplugd|nfsroot|off}
              Choose when the interface should be set up.
              manual Interface  will be set up if ifup is called manually (without option boot or hot-
                     plug)
              auto   Interface will be set up as soon as it is  available  (and  service  network  was
                     started).  This  either happens at boot time when network is starting or via hot-
                     plug when a interface is added to the system (by adding a  device  or  loading  a
                     driver). To be backward compliant onboot, on and boot are aliases for auto.
              hotplug
                     This mode is nearly the same as auto.  The difference between auto and hotplug is
                     that the latter does not make rcnetwork fail if the interface cannot  be  brought
                     up.
              ifplugd
                     The  interface will be controlled from ifplugd. At initial ifup only ifplugd will
                     be started for this interface. Then if ifplugd detects a link if calls ifup again
                     which finally sets the interface up. See also variable IFPLUGD_PRIORITY below.
              nfsroot
                     Nearly  like auto, but interfaces with this startmode will never be shut down via
                     rcnetwork stop.  ifdown <interface> still works. Use this when  you  use  a  root
                     filesystem via network.
              off    Will never be activated.
Or you can write a small script which will parse output of ethtool <ethN> and check if carrier appears, and if it appears script turn interface UP and DOWN later.
 
Old 04-14-2010, 11:48 AM   #11
Skaperen
Senior Member
 
Registered: May 2009
Location: center of singularity
Distribution: Xubuntu, Ubuntu, Slackware, Amazon Linux, OpenBSD, LFS (on Sparc_32 and i386)
Posts: 2,684

Original Poster
Blog Entries: 31

Rep: Reputation: 176Reputation: 176
It looks like either hotplug (ifplugd) or port bonding (if my switch can understand it) is the way to go. But I'm not convinced that will fix it all. I still don't know why the kernel was filtering out packets it actually received on eth1, while allowing them on eth0 (both had the same IP address), and prevented the NSD process from getting them.

This stuff worked right the last time I used dual ethernet ports. But that was many years ago and it was on Slackware, not Ubuntu.

So, what I think is needed is a document that simply describes exactly what steps are needed (and lists what extra packages are needed for the major distributions) to make 2 or more ethernet ports work correctly. The searches I have done on this have turned up how to do bonding (not what I wanted to do), how to bridge between them (not useful to me), and many unanswered or inadequately answered questions. In my case this situation involves Ubuntu. But I didn't even find one for Fedora (I could put new servers on Fedora and switch the other, later, if I needed to).
 
Old 04-14-2010, 12:02 PM   #12
Skaperen
Senior Member
 
Registered: May 2009
Location: center of singularity
Distribution: Xubuntu, Ubuntu, Slackware, Amazon Linux, OpenBSD, LFS (on Sparc_32 and i386)
Posts: 2,684

Original Poster
Blog Entries: 31

Rep: Reputation: 176Reputation: 176
It looks like "man ifcfg" is Fedora/Centos specific. I did a search for it under Ubuntu packages and there is no package that mentions it in any way. Ubuntu has "ifconfig" and "ip" commands, which are also on Debian and Slackware. I don't have Gentoo handy right now to check it.
 
Old 04-14-2010, 01:25 PM   #13
nimnull22
Senior Member
 
Registered: Jul 2009
Distribution: OpenSuse 11.1, Fedora 14, Ubuntu 12.04/12.10, FreeBSD 9.0
Posts: 1,571

Rep: Reputation: 92
Yes, script "ifup", which is read configuration file ifcfg <interface> is definitely different on linuxes.
But idea is the same. Try for example, using command ifconfig + ifup to do next thing:
1. Give to an interface IP and activate it.
2. Deactivate it.
3. Then, give THE SAME IP to different port, then activate it (ifup <ethN>)

Should be any problems.
 
Old 04-14-2010, 03:28 PM   #14
Skaperen
Senior Member
 
Registered: May 2009
Location: center of singularity
Distribution: Xubuntu, Ubuntu, Slackware, Amazon Linux, OpenBSD, LFS (on Sparc_32 and i386)
Posts: 2,684

Original Poster
Blog Entries: 31

Rep: Reputation: 176Reputation: 176
In Ubuntu it is the /etc/network/interfaces file. This is where I configured both eth0 and eth1. I have tried leaving them down by commenting out the "auto" directive, then manually bring up the interface with "ifup eth1". Other than that, I don't know which step you were suggesting I look at this for. I've tried many things with the various configurations. The routes always show which one was last configured, when they should show both interfaces.
 
Old 04-14-2010, 04:39 PM   #15
nimnull22
Senior Member
 
Registered: Jul 2009
Distribution: OpenSuse 11.1, Fedora 14, Ubuntu 12.04/12.10, FreeBSD 9.0
Posts: 1,571

Rep: Reputation: 92
You should not just comment out the "auto", you need to put "manual" there. It prevents script "network" from doing its job.
Then you can configure all interfaces (for example) with the same IP. BUT !!!, bring UP only one, then after putting it DOWN you can UP another interface, but not two at the same time (because they have same IP). It will work like "ifplugd".

Another question, you said:" The routes always show which one was last configured, when they should show both interfaces". You mean "routes" are which you connect ethernet to?

Last edited by nimnull22; 04-14-2010 at 04:43 PM.
 
  


Reply



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
can't make ethernet on laptop work, wireless and usb work fine ubuntu 8.10 rz1988 Linux - Newbie 10 01-13-2009 02:21 PM
Zenwalk: need help enabling ports 25 & 110 to make thunderbird's webmail ext. work frazum Linux - Newbie 1 07-05-2007 10:16 AM
how do I make USB ports work so I can get my printer working? M$ISBS Linux - Newbie 22 07-19-2005 02:04 PM
"make" command won't work in Fedora...installing Nvidia Ethernet drv's help Ge|atinousFury Linux - Hardware 24 01-22-2004 04:42 PM
How to make build in Ethernet work on RED HAT 8 x2000koh Linux - Networking 4 06-19-2003 08:23 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 02:14 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
Open Source Consulting | Domain Registration