Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have Ubuntu 10.04 "SERVER" installed on a system with two ethernet ports. I use only one at a time. I wanted to know if I can switch between ports without using ifup and ifdown every time. That means when I connect my LAN cable on eth0 it should work and it does. But when I disconnect the LAN cable and connect it on eth1 I have to ifdown eth0 and only then it works.

In my /etc/network/interfaces file I have configured both eth0 and eth1. there is no problem other than I have to switch it manually with ifdown and ifup every time.

share|improve this question
    
Are you connecting both to the same switch? It should work if you have assigned static ips for both interfaces. It will also work if have set a dhcp client to obtain ips. Can you add your interfaces file contents to your question? –  nixnotwin Apr 12 '12 at 6:15
    
There is only one lan cable coming from switch. I connect it to one ethernet port, then I disconnect it from there and connect it to other ehternet port. but when I do this I have to ifdown first ethernet port eth0 only then the network ping will be available. It is not about dhcp or static IP. –  Chaitanya Apr 12 '12 at 8:04
    
You can configure a script in /etc/network/if-post-down.d/ folder (it exists in ubuntu 11.10 at least). I think these scripts are executed after ("post") a device is disconnected. I don't know the exact details for such a script, nor if it works in 10.04, hence I posted this as a comment. –  medigeek Apr 12 '12 at 8:57
1  
This question appears to be abandoned, if you are experiencing a similar issue please ask a new question with details pertaining to your problem. If you feel this question is not abandoned, please flag the question explaining that. :) –  Seth Dec 30 '12 at 19:19

1 Answer 1

mediageek posted this as a comment. This may essentially be the answer, and it's the best we've got (so far), so here it is:

You can configure a script in /etc/network/if-post-down.d/ folder (it exists in ubuntu 11.10 at least). I think these scripts are executed after ("post") a device is disconnected. I don't know the exact details for such a script, nor if it works in 10.04, hence I posted this as a comment.

– medigeek Apr 12 '12 at 8:57

To complete that, I believe it may be sufficient to do this:

  1. Create a script called start-eth1 in /etc/network/if-post-down.d directory by running:

    cd /etc/network/if-post-down.d
    gksu gedit start-eth1
    
  2. Give it these contents in the text editor (then save the file and quit the text editor):

    #!/bin/sh
    [ -e $IFACE = eth0 ] && ifup eth1
    

    I believe that will check to see if the interface being disconnected is eth0, and if it is, then it will start eth1.

  3. Make the script executable so it will be run:

    sudo chmod +x start-eth1
    

Please understand that I'm not sure how well this will work (or even if it will work).

If anyone has more information about this please feel free to edit this to improve it, and/or post a new answer.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.