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

    Proper way to perform the dhcp release/renew via script?

    Scheduled Pinned Locked Moved General pfSense Questions
    3 Posts 2 Posters 270 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.
    • GPz1100G
      GPz1100
      last edited by

      The webui has function under Status/Interfaces/WAN to release WAN and perform renew.

      What is the command line equivalent of this to use in script?

      /etc/rc.d/dhclient forcerestart igb0

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

      I notice ipv6 does not restart properly with dhclient forcerestart.

      To bypass my isp's (att) gateway box, I'm using wpa_supplicant to handle 802.1x eapol auth. This runs at boot and appears to be generally stable.

      With my old firewall I had a cron task that ran every 10 minutes to verify connectivity and kill/restart the wpa_supplicant if it was unresponsive. Part of the script was to initiate a dhcp renew once eapol authorized successfully.

      1 Reply Last reply Reply Quote 0
      • stephenw10S
        stephenw10 Netgate Administrator
        last edited by

        It does this:

        if ($_POST['ifdescr'] && $_POST['submit']) {
        	$interface = $_POST['ifdescr'];
        	if ($_POST['status'] == "up") {
        		if ($_POST['relinquish_lease']) {
        			dhcp_relinquish_lease($_POST['if'], $_POST['ifdescr'], $_POST['ipv']);
        		}
        		interface_bring_down($interface);
        		restart_interface_services($interface);
        		filter_configure();
        		system_routing_configure();
        		send_event("service reload packages");
        	} else {
        		interface_configure($interface);
        	}
        	header("Location: status_interfaces.php");
        	exit;
        }
        

        So you could just include those php functions in your script.

        I would probably try rc.linkup stop and start as you showed though. That will likely run a bunch of other things but if it doesn't cause an issue I'd go with it.

        GPz1100G 1 Reply Last reply Reply Quote 0
        • GPz1100G
          GPz1100 @stephenw10
          last edited by

          @stephenw10 The original script is in bash, but is fairly simple so should be easily adaptable to tcsh.

          I know lots of other folks with similar configurations don't even bother with a watchdog script for wpa_supplicant. This is fine if it works. I rather have something in there that ensures there's network connectivity and the supplicant is not stalled.

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