7

I need to start eth0 network interface during boot, but only if cable is plugged in. I have following in my /etc/network/interfaces

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet dhcp

The problem is, when the cable is not plugged in, the computer still tries to reach the dhcp server and it takes long time to time out and eventually boot.

Is there some way to skip the eth0 configuration if link is not detected?

I am using Debian Wheezy

2
  • did you tried to set static insted of dhcp, and put some static address, if this works for you
    – klerk
    May 29, 2014 at 21:52
  • @vladeli - no, I need to use dhcp. May 29, 2014 at 21:54

1 Answer 1

8

You can modify the amount of time used to wait for the DHCP response by editing /etc/dhcp3/dhclient.conf:

#timeout 60
timeout 10

This will set a ten-second window of opportunity for the DHCP server to respond. You might want to experiment with the timeout speed. Or, you could disable eth0 at startup by editing /etc/network/interfaces:

#auto eth0

Then, bring up eth0 manually when you want it, with sudo ifup eth0.

1
  • 1
    the DHCP server is sometimes slow to respond. If I set the timeout too low, then my client will mistaken slow response for no response. If I set the timeout high enough, then I am back where I have started. I know, I can detect if link is up with ethtool eth0. Is there no possibility (i.e. a ifup hook) to check if link is up? May 30, 2014 at 7:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .