Ubuntu: Server Network DHCP Fail Kills Interfaces



Question:

I have a server with the current /etc/network/interfaces:

auto lo  iface lo inet loopback    auto em1  iface em1 inet dhcp    auto em1:1  iface em1:1 inet static      address 192.168.168.1      netmask 255.255.255.0  

dhclient.conf file is default, nothing edited. If I connect 2 machines together, ethernet port on pc1 to ethernet port on pc2, the connection works great for 5 minutes (this just happens to be the default dhclient.conf timeout). If I change the dhclient.conf timeout to 20 seconds, the machines stay connected for 20 seconds then kill both interfaces (em1 and em1:1). I can do ifdown to both connections & ifup to bring them up, but they will just die again in whatever the dhcp timeout is.

/etc/network/interfaces has to be like that, DHCP on em1 with an alias or virtual connect for em1:1 that is static. I could set the dhcp timeout to like 9999999999999999999999999999999999999, but eventually it will hit that timeout & bomb. No errors in the log files.

Any ideas? No Network Mangler suggestions please :)


Solution:1

We had a similar issue for an embedded application that we wanted to connect to a DHCP server when available, but also have a static IP on an alias.

Our final solution was to simply add a script to /etc/dhcp/dhclient-enter-hooks.d/ that simply restarts the alias. We tested this with a flood ping and had no dropped packets on the alias even when the DHCP retry caused this script to run. That entire script follows:

ifup em1:1 @> /dev/null


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »