PF Sense renew ip when connection lost
#!/bin/sh
wan="em5"
currip=$(ifconfig $wan | grep "inet " | cut -d " " -f 2)
if test -z "$currip"; then
logger `date +%Y%m%d.%H%M%S` "pingtest - Detected empty IP on $wan! Will try again in 60 seconds."
sleep 60
currip=$(ifconfig $wan | grep "inet " | cut -d " " -f 2)
if test -z "$currip"; then
logger `date +%Y%m%d.%H%M%S` "pingtest - 2nd try: Still empty IP on $wan! Will fix now."
ifconfig $wan down
sleep 5
ifconfig $wan up
sleep 10
dhclient $wan
logger `date +%Y%m%d.%H%M%S` "pingtest - Fixing done!"
else
logger `date +%Y%m%d.%H%M%S` "pingtest - 2nd try: $wan has IP $currip; ok"
fi
else
logger `date +%Y%m%d.%H%M%S` "pingtest - $wan has IP $currip; ok"
fi
1
Renews ip and logs to system.log. Change wan=”em5″ to match your wan interface.
- Diagnostics / Edit File: Enter file name /usr/local/bin/pingtest.sh and paste the file from above in there and click Save. Update igb1 with the name of your WAN interface. That name is visible in Status / Interfaces in the title. For me it says there: “WAN Interface (wan, igb1)”
- Diagnostics / Command: “chmod +x /usr/local/bin/pingtest.sh” (without quotes) and click Execute. This makes the file executable.
- System / Package Manager / Available Packages: Install Cron. To my understanding, this is just the user interface for Cron.
- Services / Cron / Settings: Leave the existing packages there and add a new one.
- Minute: “/10″ (without quotes) or just “” for every minute, but every 10 minutes should be fine and avoids filling up the log.
- Other values: “*”, User: “root”, Command: “/usr/local/bin/pingtest.sh”
From: https://forum.netgate.com/topic/127403/auto-renew-dhcp-after-outage/24