• Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Search
  • Register
  • Login
Netgate Discussion Forum
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Search
  • Register
  • Login

Howto force a dhcp release and dhcp renew on wan interface when down?

Scheduled Pinned Locked Moved DHCP and DNS
10 Posts 6 Posters 5.3k Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M
    megapearl
    last edited by Feb 16, 2018, 12:17 PM

    Hello,

    I'm running pfSense 2.4.2-RELEASE-p1 for years now in a multi WAN environment.
    I use a 4G dongle connected via Proxycast in bridge mode (4G to Ethernet) which is connected to a WAN interface in pfSense as backup when the adsl and cablemodems are offline.

    Problem is when the ISP of the 4G dongle itself goes down and comes up again the IP address assigned to it doesn't renew, and so is offline.
    When I do a manual release renew under status -> interfaces -> mobile interface/opt 6 it works again for a couple of days.

    Is it possible to let it do this automaticly? So when interface opt6 goes down and comes up again do dhcp release renew on interface opt6?

    Any help would greatly appreciated!

    Best Regards,
    Donald.

    1 Reply Last reply Reply Quote 0
    • J
      JKnott
      last edited by Feb 16, 2018, 1:43 PM

      In Linux, there are hooks for running scripts on various evens, such as a network connection coming up.  I expect the same would be available in FreeBSD, which pfSense runs on.  However, I'm not that familiar with FreeBSD and haven't bothered looking.  Look for the script that starts the DHCP client and you should be able to modify it to do a release/renew.

      PfSense running on Qotom mini PC
      i5 CPU, 4 GB memory, 32 GB SSD & 4 Intel Gb Ethernet ports.
      UniFi AC-Lite access point

      I haven't lost my mind. It's around here...somewhere...

      1 Reply Last reply Reply Quote 0
      • J
        jly2680
        last edited by May 15, 2020, 8:22 PM

        hi did you manage to solve this problem..I have a script where my modem will reset and will have it's ip renewed but the default gateway does not change automatically..I need to go to interfaces tab to release then renew so its gateway will update...

        1 1 Reply Last reply Jun 6, 2020, 4:32 PM Reply Quote 0
        • 1
          172pilot @jly2680
          last edited by Jun 6, 2020, 4:32 PM

          I'm having the same basic problem.. Cable modem / pfSense on hardware watchguard... Works fine for months, but when the cable modem experiences problems and I lose my IP address, I end up with a WAN that shows physical up, but no IP address. I go into the WAN interface, unclick the "Enable interface", save and activate, then re-enable and activate, and it comes back up, does a DHCP request and all is well. Looking for a way to make pfSense do this automatically..

          J J 2 Replies Last reply Jun 6, 2020, 6:04 PM Reply Quote 0
          • J
            JKnott @172pilot
            last edited by Jun 6, 2020, 6:04 PM

            @172pilot

            Try running /sbin/dhclient-script to see if that clears the problem. If it does, you could write a script that pings the gateway (or other address) periodically, which then runs dhclient-script when it fails.

            PfSense running on Qotom mini PC
            i5 CPU, 4 GB memory, 32 GB SSD & 4 Intel Gb Ethernet ports.
            UniFi AC-Lite access point

            I haven't lost my mind. It's around here...somewhere...

            1 Reply Last reply Reply Quote 0
            • J
              jly2680 @172pilot
              last edited by jly2680 Jun 6, 2020, 7:13 PM Jun 6, 2020, 6:49 PM

              @172pilot

              ALLDEST="8.8.8.8"
              # Interface to reset, usually your WAN
              BOUNCE=ue0
              # Log file
              LOGFILE=/root/ping.log
              #=====================================================================
              
              COUNT=1
              while [ $COUNT -le 2 ]
              do
              
                 for DEST in $ALLDEST
                 do
                    echo `date +%d%m%Y.%H%M` "Pinging $DEST" >> $LOGFILE
                    counting=$(ping -c 5 $DEST | grep 'received' | awk -F',' '{ print $2 }' | awk '{ print $1 }') 
                    if [ $counting = 0 ]; 
              	  then
              	echo `date +%Y%m%d.%H%M%S` "All pings failed. Resetting 4G interface $BOUNCE." >> $LOGFILE
                    sleep 2
                  echo -e 'AT^RESET' > /dev/cuaU0.0
                  sleep 20
              	/sbin/ifconfig $BOUNCE down
              	   # Give interface time to reset before bringing back up
                   echo -e 'AT^NDISDUP=1,1' > /dev/cuaU0.0
                   
                    /sbin/ifconfig $BOUNCE up
                    /etc/rc.linkup start $BOUNCE
              	  sleep 5
              	 else
                   echo `date +%d%m%Y.%H%M`  "Ping received =" $counting  "Internet is UP" >> $LOGFILE
               
                    exit 0
                    fi
              	
                 done
              
                
              
                 COUNT=`expr $COUNT + 1`
              
              

              Here's my working script to reset my 4g interface..but you may adjust this script since your wan interface is not 4g usb modem

              T 2 Replies Last reply Jun 6, 2020, 7:08 PM Reply Quote 0
              • T
                trent6gol @jly2680
                last edited by Jun 6, 2020, 7:08 PM

                @jly2680 Curious, Shouldn't PF Multi-Wan switch back and forth like HA? It's basically failover why the need for a script?

                J 1 Reply Last reply Jun 6, 2020, 7:13 PM Reply Quote 0
                • J
                  jly2680 @trent6gol
                  last edited by Jun 6, 2020, 7:13 PM

                  @trent6gol
                  sorry but forgot to mention , 4g is my single wan connection

                  1 Reply Last reply Reply Quote 0
                  • T
                    trent6gol @jly2680
                    last edited by trent6gol Jun 6, 2020, 7:20 PM Jun 6, 2020, 7:17 PM

                    @jly2680 Which Watch guard box I had similar issues way back and it turned out to be the Marvell NIC ports and a conflict with PF. My second experience was my WAN would go down all the time because I didn't have a cable in the IPMI/IMM port which defaults to first NIC port /WAN usually. I also found that if any machine supports RMM and does not have specific IPMI/IMM it also will default to first LAN port which in that case just turn IPMI off in Bios. Oopps meant for 172pilot

                    1 Reply Last reply Reply Quote 0
                    • S
                      serbus
                      last edited by Jun 6, 2020, 7:31 PM

                      Hello!

                      For reference :

                      https://www.freebsd.org/cgi/man.cgi?query=dhclient-script&sektion=8

                      What does the WAN section of Status -> Interfaces look like when it says the interface is up but there is no IP?

                      John

                      Lex parsimoniae

                      1 Reply Last reply Reply Quote 0
                      • First post
                        Last post
                      Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.
                        [[user:consent.lead]]
                        [[user:consent.not_received]]