Auto DHCP Renew not working on WAN (How to fix it)

  • This is an update to the script that can be found here:,17243.0.html

    For those of you who are nix handicapped like me, installing and activating this script is easy to do via the web interface.
    Go to Diagnostics > Edit file
    Cut & paste the code below, editing the user variables to match your settings.
    Save the file as /usr/local/bin/ (or path/name of your choosing)
    Go to Diagnostics > Command
    Execute the command "chmod +x /usr/local/bin/" (makes the file executable)
    Go to System > Packages and install the Cron package
    Go to Services > Cron
    Install a new cron with settings "
    /5 * * * * root /usr/local/bin/" (runs test every 5 minutes)

    If you want to verify the test is running, uncomment (remove the "#") in front the "echo" commands on lines 33 & 37.  Then, use Diagnostics > Edit file to view the contents of /root/pingtest.log.  There should be a log entry every 5 minutes.  Once you're sure it's running, be sure to add the comments back so you don't fill your hard drive with this script's status message.

    Comcast does not like renewing my IP Address on my WAN port so I used the script found here but it would only reboot the firewall it would never just renew the IP Address.

    So I added 2 lines to the Original script
    I found that the dhcp client was not turned back on when you did the down / up with ifconfig. So here it is, figured it might help someone out there  ;)

    #, v1.0.2
    # Created 2009 by Bennett Lee
    # Released to public domain
    # (1) Attempts to ping several hosts to test connectivity.  After
    #     first successful ping, script exits.
    # (2) If all pings fail, resets interface and retries all pings.
    # (3) If all pings fail again after reset, then reboots pfSense.
    # History
    # 1.0.2   Added turn dhclient on for the interface. (Dice81)
    # 1.0.1   Added delay to ensure interface resets (thx ktims).
    # 1.0.0   Initial release.
    # Set multiple ping targets separated by space.  Include numeric IPs
    # (e.g., remote office, ISP gateway, etc.) for DNS issues which
    # reboot will not correct.
    # Interface to reset, usually your WAN
    # Log file
    while [ $COUNT -le 2 ]
    	for DEST in $ALLDEST
    		#echo `date +%Y%m%d.%H%M%S` "Pinging $DEST" >> $LOGFILE
    		ping -c1 $DEST >/dev/null 2>/dev/null
    		if [ $? -eq 0 ]
    			#echo `date +%Y%m%d.%H%M%S` "Ping $DEST OK." >> $LOGFILE
    			exit 0
    	if [ $COUNT -le 1 ]
    		echo `date +%Y%m%d.%H%M%S` "All pings failed. Resetting interface $BOUNCE." >> $LOGFILE
    		/sbin/ifconfig $BOUNCE down
    		# Give interface time to reset before bringing back up
    		sleep 10
    		/sbin/ifconfig $BOUNCE up
    		# Give WAN time to establish connection
    		sleep 20
    		dhclient $BOUNCE
    		sleep 20
    		echo `date +%Y%m%d.%H%M%S` "All pings failed twice. Rebooting..." >> $LOGFILE
    		/sbin/shutdown -r now >> $LOGFILE
    		exit 1
    	COUNT=`expr $COUNT + 1`

Log in to reply