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

How to release/renew DHCP

DHCP and DNS
8
27
13.7k
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.
  • J
    JKnott @dotdash
    last edited by Jul 30, 2020, 9:18 PM

    @dotdash

    /root: service dhclient restart re0
    're0' is not a DHCP-enabled interface
    dhclient already running? (pid=76670).

    As for "service netif restart", I had to reboot pfSense to get out of that one.

    It's not fair to say you can't release and renew easily on pfSense, as there is a button right on the status page.

    When I use that, even with Relinquish Lease selected, it does not go through the full 4 step DHCP process. As I mentioned above, I only capture the request and ack. The discover and offer are nowhere to be seen. So, yeah, it is fair to say that.

    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
    • D
      dotdash
      last edited by Jul 30, 2020, 9:43 PM

      I've never captured the traffic, but I haven't had a problem using the release and renew the handful of times I've needed it. Yours doesn't release/renew properly? Does it log an error?

      J 2 Replies Last reply Jul 31, 2020, 1:23 AM Reply Quote 0
      • J
        JKnott @dotdash
        last edited by Jul 31, 2020, 1:23 AM

        @dotdash

        I haven't checked the logs, but use Packet Capture or Wireshark frequently. Clearly, Packet Capture is working, as it captures the request and ack. Also, on both Linux and Windows, just renewing, without doing a release provides the same result. On both, I have to specifically release to get all 4 steps.

        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
          JKnott @dotdash
          last edited by Jul 31, 2020, 1:26 AM

          @dotdash

          Why not try it and see what happens. Run Packet Capture to capture port 67, then release DHCP and see what's captured.

          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
          • S
            serbus
            last edited by Jul 31, 2020, 2:35 AM

            Hello!

            I am not knowledgeable about dhcp, but I have been trying to learn more. I have been poking around and found a few things that might be useful...or useless....

            Just kind of stream of consciousness....

            There appears to be multiple versions of dhclient on pfsense. The one you get by just running "dhclient" points to /sbin/dhclient and is ancient(?) - no "-r" option.

            There is another dhclient at /usr/local/sbin/dhclient. This is the one the gui uses for things like releasing the wan with "Relinquish lease" in Status -> Interfaces. This appears to be a more recent isc version of dhclient and does support the "-r" option.

            The gui uses something like this to relinquish the lease :

            /usr/local/sbin/dhclient -4 -d -r 
               -lf  /var/db/dhclient.leases.igb0 
               -cf  /var/etc/dhclient_wan.conf 
               -sf /usr/local/sbin/pfSense-dhclient-script
            

            It looks like it would be pretty simple to roll together a short php script that would mimic the release/relinquish/renew functionality of the gui.

            There is also a pre-rolled script that seems like it might do much the same thing :

            /etc/rc.linkup stop igb0
            /etc/rc.linkup start igb0
            

            As far a forcing a dhcp rebind (bcast discover) as opposed to a renew (ip directed to previous server), I dont know. It seems like pfsense pretty strictly follows the dhcp renew/rebind approach. If the "relinquish lease" command above doesnt force a rebind, maybe you could nuke the /var/db/dhclient.leases.igb0 file before doing a renew. This might force a rebind.

            John

            Lex parsimoniae

            J 2 Replies Last reply Jul 31, 2020, 10:53 AM Reply Quote 1
            • J
              JKnott @serbus
              last edited by Jul 31, 2020, 10:53 AM

              @serbus

              I'll give that other client a try later. However, the commands to release and rebind should just work, as they do in Linux and Windows. It shouldn't be necessary to touch any files. I don't understand why it doesn't seem to work properly with pfSense out of the box. If the other client is what it takes, why isn't it used?

              On this site, there are occasionally problems with connecting to the Internet. I often tell people to capture the full DHCP sequence, but that apparently won't work with the current DHCP client.

              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
                JKnott @serbus
                last edited by Jul 31, 2020, 2:20 PM

                @serbus

                That other client seems to have done the trick. One curious thing though is I didn't see a release as I do with Linux and Windows.

                This begs the question of why that client is not used, if the default one is so old.

                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...

                S 1 Reply Last reply Jul 31, 2020, 3:29 PM Reply Quote 0
                • S
                  serbus @JKnott
                  last edited by Jul 31, 2020, 3:29 PM

                  @JKnott

                  Hello!

                  There seems to be a relationship between the release option and dhclient running in daemon mode. Pfsense is running dhclient as a daemon and windows/linux might not be.

                  I dont know anything about the dhclient packages or how/why they are ordered in the path.

                  John

                  Lex parsimoniae

                  J 1 Reply Last reply Jul 31, 2020, 4:40 PM Reply Quote 0
                  • J
                    JKnott @serbus
                    last edited by Jul 31, 2020, 4:40 PM

                    @serbus

                    I just did some more testing. It seems that if I release with that other client, I have to use the default client to renew, for it to show on the interface status.

                    This looks like something the developers should look into, as it can produce confusing situations, in addition to not being able to do a proper release with the default dhclient.

                    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...

                    S 1 Reply Last reply Jul 31, 2020, 5:44 PM Reply Quote 0
                    • S
                      serbus @JKnott
                      last edited by serbus Jul 31, 2020, 5:46 PM Jul 31, 2020, 5:44 PM

                      @JKnott

                      Hello!

                      It looks like the /sbin/dhclient is used to run/control the daemon, while the /usr/local/sbin/dhclient is just used to send the courtesy "relinquish" message to the dhcp server.

                      There appears to be many things that happen in pfsense when you release/renew dhcp leases on the wan, probably more than on a workstation client. I dont know what effect going straight at the dhclient interface could have on the rest of the system. It might be better to use the higher level apis that are provided to do the release/renew, if possible. YMMV.

                      John

                      Lex parsimoniae

                      J 1 Reply Last reply Jul 31, 2020, 6:09 PM Reply Quote 0
                      • J
                        JKnott @serbus
                        last edited by Jul 31, 2020, 6:09 PM

                        @serbus

                        I wanted a simple way to release/renew it for testing. It's easy enough with Linux & Windows, but not pfSense. Why should there be 2 versions of dhclient, which provide different results?

                        Many years ago, I worked on the team that developed standard desktops (OS/2, NT & W95) for IBM Canada. Part of my work involved testing to make sure things worked properly and consistently. Such a thing wouldn't have been tolerated.

                        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...

                        keyserK 1 Reply Last reply Mar 30, 2023, 7:33 PM Reply Quote 0
                        • F Fallon referenced this topic on Feb 23, 2022, 6:05 PM
                        • J
                          jtm200
                          last edited by Jan 5, 2023, 3:49 AM

                          tl;dr to renew DHCP lease run /sbin/dhclient -c /var/etc/dhclient_wan.conf $INTERFACE

                          How I find that command

                          1. From the Admin Web UI, I clicked Release WAN
                          2. From a shell terminal,
                            I "scraped" the command-line by first running as user root
                            while true; do ps -A | grep dhclient; echo; done
                            
                          3. from the Admin Web UI, I clicked Renew WAN
                          4. in the shell terminal, the particular renewal command was briefly listed

                          Command output

                          For me, I see

                          $ /sbin/dhclient -c /var/etc/dhclient_wan.conf em0
                          Cannot open or create pidfile: No such file or directory
                          dhclient 68253 - - PREINIT
                          DHCPREQUEST on em0 to 255.255.255.255 port 67
                          DHCPACK from 11.22.33.44
                          bound to 55.66.77.88 -- renewal in 91710 seconds.
                          

                          (run as user root)

                          Thanks @serbus for sharing your research!

                          1 Reply Last reply Reply Quote 0
                          • keyserK
                            keyser Rebel Alliance @JKnott
                            last edited by Mar 30, 2023, 7:33 PM

                            @jknott I wonder if this has been “cleaned up” and simplified with 23.01 as that is a wastly never OS release and has required netgate to refactor a lot of the UI and services tooling.

                            Love the no fuss of using the official appliances :-)

                            J 1 Reply Last reply Mar 30, 2023, 8:05 PM Reply Quote 0
                            • J
                              JKnott @keyser
                              last edited by Mar 30, 2023, 8:05 PM

                              @keyser said in How to release/renew DHCP:

                              I wonder if this has been “cleaned up” and simplified with 23.01

                              No idea.

                              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
                              • P
                                panjali.ganiyev
                                last edited by May 12, 2023, 4:15 PM

                                Please help. How to automatically remove reserved MAC addresses from DHCP Static Mappings, for example, not active for 2 months?

                                1 Reply Last reply Reply Quote 0
                                • D
                                  dread
                                  last edited by May 7, 2024, 8:43 PM

                                  Hi all,

                                  I have a problem that when my 4/5G modem sometimes renews IP, it does't give it to my pfsense box (running latest pfSense Plus 24.03.1 release). Yes, I miss the times I had fiber..

                                  So in this situation, I get a lot of dhcp discover messages to 255.255.255.255, but I really never get a real working new IP and working WAN connection.

                                  Quite obvious that my modem is running dnsmasq to provide 'ip-passthrough-mode'. Propably all software in it is partially just (old?) Linux /GNU software, like most todays customer devices do.

                                  If I renew WAN IP from web GUI, I'll start getting a mass of following errors in my system.log, and thus error messages are flooding my system.log.

                                  Arpresolve: can't allocate llinfo for xxx.xxx.xxx.xxx (where xxx.xxx.xxx.xxx is my old ip)
                                  

                                  Today I found the below solution to the problem, and made the following shell script /root/bin/renew-wan-ip.sh (and thank a lot for the original author):

                                  #!/bin/sh
                                  /usr/local/sbin/dhclient -4 -d -r -lf /var/db/dhclient.leases.ix3 -cf /var/etc/dhclient_wan.conf -sf /usr/local/sbin/pfSense-dhclient-script; php -r "require 'interfaces.inc'; interface_bring_down('wan'); interface_configure("wan");"
                                  

                                  So It's almost a one liner. It assumes that yout wan name is 'WAN' and WAN interface is ix3. Please, modify the script to suite your configuration.

                                  I'll try this next time I have this problem, but you may try it now or suggest improvements or better solutions.

                                  And if someone knows a solution for the 'Arpresolve: can't allocate llinfo for xxx.xxx.xxx.xxx' problem in this exact scenario, I would be happy to hear. I'm running latest pfSense Plus 24.03.1 on Netgate 6100 hardware.

                                  Thanks and happy hacking!

                                  GertjanG 1 Reply Last reply May 8, 2024, 8:14 AM Reply Quote 0
                                  • GertjanG
                                    Gertjan @dread
                                    last edited by Gertjan May 8, 2024, 8:14 AM May 8, 2024, 8:14 AM

                                    @dread said in How to release/renew DHCP:

                                    I have a problem that when my 4/5G modem sometimes renews IP, it does't give it to my pfsense box (running latest pfSense Plus 24.03.1 release)

                                    If your "4/5G modem" is a modem ( 😊 ) then it doesn't know shit about IP addresses. It doesn't handle that kind of info. It just passes bits encoded in 4G/5G radio signals into electrical bits that are Ethernet packets.
                                    A modem can not signal the attached device anything meaningful. It can do only one thing : if the connections needs to be rebuild, it will take it's wired Ethernet port 'down' for a moment. This, and only this, is the info pfSense needs so dhclient can do its job.

                                    See also here.

                                    @dread said in How to release/renew DHCP:

                                    Yes, I miss the times I had fiber..

                                    Leaving fiber for a 4G connection ?
                                    Your choice ???

                                    No "help me" PM's please. Use the forum, the community will thank you.
                                    Edit : and where are the logs ??

                                    D 2 Replies Last reply May 8, 2024, 9:18 AM Reply Quote 0
                                    • D
                                      dread @Gertjan
                                      last edited by May 8, 2024, 9:18 AM

                                      @Gertjan

                                      Hi,

                                      My 'modem' is a router, but I use it only as a modem.

                                      This kind of consimer grade devices rarely have a 'pure bridge' mode, only a 'ip-passthrough-mode'. They surely speak TCP/IP. I guess my 'modem' is using dnsmasq for this feature.

                                      I left a fiber/Ethernet with 600mbps because I moved to one of the most remote areas In Europe.

                                      We currenly have only 4G here, but my ISP has confirmed me they will modernize the nearest GSM base station on the second half of this year.

                                      There's no fiber connections and propably never will.

                                      Currently my 'modem' is forced to use only 4G.

                                      😊

                                      GertjanG 1 Reply Last reply May 8, 2024, 10:13 AM Reply Quote 0
                                      • D
                                        dread @Gertjan
                                        last edited by May 8, 2024, 9:51 AM

                                        @Gertjan said in How to release/renew DHCP:

                                        See also here.

                                        I'll suggest it would be best to continue this discussion about my script on this thread:

                                        https://forum.netgate.com/topic/188031/cli-how-to-release-renew-wan-dhcp-one-solution

                                        Thanks again!

                                        1 Reply Last reply Reply Quote 0
                                        • GertjanG
                                          Gertjan @dread
                                          last edited by Gertjan May 8, 2024, 10:14 AM May 8, 2024, 10:13 AM

                                          @dread said in How to release/renew DHCP:

                                          most remote areas In Europe ...

                                          Ah. I thought it was me.

                                          This site shows the progress of "ditching ADSL in progress" and "putting fiber in place" (they actually pull strings of fiber cables through trees here .... its just amazing).
                                          Zoom out and you'll get the entire Fiber In France picture.

                                          The blue space = fiber present. The white surface is the south east part of the Dordogne, one of the most tourist provinces in France (Europe). The local mayors don't give a sh*t about 'Internet'.

                                          You don't live that 'remote' if 4G (probably not 5G) is available to you. But your probably use one of these country side 4G installations that exists for one simple reason : so that the phone (voice) works ... data is just .... well ... no priority as these antennas have to cover a very big surface. As said above : the radio signal is weak, messy and when you start to understand how it works you will always have one final question left : How on earth can this work ?

                                          @dread said in How to release/renew DHCP:

                                          Currently my 'modem' is forced to use only 4G

                                          Out of my head, without looking it up : 5G radio frequencies are good for a mile or two. Beyond that, 4G is elected. Supporting 5G costs ten times the electricity of a 4G connection. Etc.

                                          No "help me" PM's please. Use the forum, the community will thank you.
                                          Edit : and where are the logs ??

                                          1 Reply Last reply Reply Quote 0
                                          • First post
                                            Last post
                                          Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.