I have a few CentOS 6/7 systems (non-production, experimental purposes) that have been configured to use DHCP for their IP address. Last week there was a big network disruption and I found that those systems had lost their IP address and the DHCP client had terminated. I guess after too many/too long retries.
What is the proper way to make it try to recover forever? Is there a dhcp client setting that can do this? Or should I add a cron entry that does something like 'ifup eth0' every hour? Or is there a much better way to do this?
I know CentOS 6 and CentOS 7 do these things differently and I'm looking for answers for both these cases.
Update:
For now I have created this script (which I put in /etc/cron.hourly/ ) that seems to work in the specific situation of CentOS 6. This is probably not the best solution but it "Works on my machine".
#!/bin/bash
IF=eth0
ifconfig ${IF} | fgrep 'inet addr' > /dev/null
if [ $? -ne 0 ];
then
echo "Network is dead, trying restart"
ifup ${IF}
fi
Still looking for the proper way to do this so I do not think this is the right answer to my question.
dhclient.conf
as you can define default lease options that can override what the client is told by the dhcpd. Specifically I would look at theinterface
stanza options around lease time and change timeouts.