DHCP client on red0 won't reassign IP upon reconnection

Facing similar issues since I switched to cable. I wrote a small script and a cron check every 10 minutes. The script pings two domains and If none is reachable dhcpdc gets killed and started again.

IPs=(“bbc.com” “startpage.com”);
IPs_present=0;

for IPs in “${IPs[@]}”
do
ping -c 1 $IPs &>/dev/null && IPs_present=1
done

if [[ $IPs_present -eq 1 ]]; # Inet ok
then
exit
else # not ok
dhcpcd -k red0 # kill red
sleep 60
dhcpcd -n red0 # start red
exit
fi
fi
done
exit

1 Like