Scripting the behaviour of Status --> Interfaces --> DHCP renew button

  • Further to my quest to deliver robust 4G connectivity using a pfsense box have now now veered away from the PPP method I was pursing earlier with my post a few days ago Huawei E3372 will not reconnect PPP after manual disconnect under status-->interfaces and have managed to configure and successfully connect with the Huawei E3372 in ndis mode. This resolves the issue I had previously where once the PPP session disconnects the modem's port would become unresponsive. For those who might be interested, this is how I achieved a successful ndis connection using a Huawei E3372:

    • The E3372 must be flashed with stick mode firmware v21.xx

    • Port mode needs to be configured as:

    • The USB Ethernet interface the stick presents to pfsense (ue0) needs to be configured as a WAN gateway with connection type DHCP

    • The following needs to be setup in shellcmd as an earlyshellcmd. This sends the NDISUP string to the modem and instructs it to connect to the internet. By executing it as an earlyshellcmd, the connection is up and live by the time pfsense goes to bring the interface up and as such it is able to grab a DHCP lease immediately. Executing this command as a regular shellcmd sees it happen after pfsense has brought the interface up and as such pfsense hangs until the DHCP request times out for that interface on boot.

        echo -e 'AT^NDISDUP=1,1' > /dev/cuaU0.1
    • The same command string is also setup as a cron job that executes every minute. The idea behind this is if the stick is unplugged and reinserted it'll bring the stick back online within one minute.
        echo -e 'AT^NDISDUP=1,1' > /dev/cuaU0.1

    This is the point where I have run into a problem. When the stick is removed the interface will go down as expected. When the stick is reinserted the LED on the stick blinks as it's booting up and once my cron job executes the NDISUP command the LED goes solid blue indicating it's connected to the internet which is great, all working as expected... only in pfsense the interface stays down. If I jump into Status --> Interfaces and click the renew button to the right of Status DHCP down it brings the interface up, gets an IP and LAN clients can access the internet. Excellent this what I need, so I figured I could script the same thing by simply executing dhclient ue0 and simply appending that to the end of my cron task. So I tested it in the shell by unplugging and replugging the stick, waited for it to turn solid blue after the cron job, then ran:

    # dhclient ue0

    and sure enough it got a lease. I thought this was it but unfortunately it gets a lease but it doesn't update pfsense's routing table. So the interface comes up with a valid IP, I can ping hosts on the internet from the pfsense box but my LAN clients don't have any internet access. If I am to repeat the test but instead of running dhclient from the shell I click the renew button under status-->interfaces it gets an ip just the same, but the routing gets updated and the LAN clients can get to the net. I assume because dhclient is being called outside of the pfsense core it doesn't know about it and as a result doesn't update the routes (despite the fact that within a second or so of running dhclient from the shell the interfaces monitor on the home screen updates with the new IP address). I've looked through the code in /usr/local/www/status_interfaces.php and whilst I've found the command it executes for doing a DHCP release I unfortunately can't work out what it's executing when it does a DHCP renew for an interface. It's clearly more than just dhclient [interface_name].

    Not one to give up easily I tried a number of other approaches from the shell including ifconfig ue0 up which brings the interface up, at which point I was hopeful that pfsense would see an interface status change from down to up and then automatically poll for a DHCP lease. Unfortunately the interface status changes from ⬇ to ⬆ but it never does a DHCP call on its own and as such the interface sits there with no IP. If I hit the renewal button it gets a lease and updates the routes and clients can connect immediately, if I manually execute dhclient ue0 it gets a lease straight away but the routes aren't updated and as such despite the fact it's online and I can ping public IP addresses from that interface on the pfsense box, none of my LAN clients can reach the internet. I even tried via an AT command AT^DHCP? which returned an address in the console session with the modem, but it wasn't passed to the operating system which isn't surprising.

    This last obstacle is the only thing stopping me deploying this solution, keen for any feedback or direction anyone might have. In ndis mode my testing has shown speeds exceeding what I was able to achieve using PPP which seemed to tap out at about 45mbps so I'm keen to get this working. Thanks!

  • This post is deleted!

  • Netgate Administrator

    I expect it to run that the dhcpclient when the shows as up. That's what the behaviour would be if it was a USB Ethernet device and you connected the cable. Or any Ethernet interface for that matter.

    You might be able to do it using /etc/rc.linkup start wan but you would need to make that conditional. You wouldn't want that running every minute, it does a lot of things. One of them is running the dhcp client though.

    Another issue you will hit here is that if the modem is unplugged or not in ndis mode for some reason pfSense will not boot fully if ue0 is not detected. It will wait at the interfaces assign screen on the console. That's the main reason why ppp is currently preferred for direct conected modems and an external Ethernet connected device is the best option.


Log in to reply