Skip to content

Instantly share code, notes, and snippets.

@cdlewis
Last active August 29, 2015 14:12
Show Gist options
  • Save cdlewis/20260b2b101e7f09fed9 to your computer and use it in GitHub Desktop.
Save cdlewis/20260b2b101e7f09fed9 to your computer and use it in GitHub Desktop.
manual_dhcp.sh
#!/bin/bash
# Make sure only root can run our script
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root" 1>&2
exit 1
fi
while true; do
count=$(ping -c 2 -s 1 -t 2 google.com | grep -E " 5?0\.0% packet loss")
if [ -z "$count" ]; then
echo "$(date): Packet drop, renewing DHCP"
ipconfig set en0 DHCP
sleep 10
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment