CLI: How to release/renew WAN dhcp, one solution
-
Hi all,
I posted this also as a reply to a very old thread, but I'll post it also here as a new topic.
How to release/renew WAN dhcp, one CLI solution proposal.
My setup, 4/5G moden with 'ip-passthrough-mode', pfSense Plus v 24.03.1 with Netgage 6100 hardware.
The problem: Sometimes when my modem gets a new public IP, but my pfsense box don't get it. I see tons of dhcp discover messages to 255.255.255.255, but I really never get a real working new IP and working WAN connection, thus the Internet cuts and stays down.
This happens every now and then, and sometimes this problem does not occur, so everything still works.
If I renew WAN IP from web GUI, I'll start getting tons of following errors in my /var/log/system.log, and thus those 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)
I found the below CLI / SSH solution to the problem, and made the following shell script /root/bin/renew-wan-ip.sh (and thanks 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. And please, test it if you can/want.
I'll try this for a first time only when I have this problem again, 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.
Thanks and happy hacking!
-
Ps. If this script to renew WAN IP is working without problems, I think I'll do another scripts that probes continually if WAN has an IP, and if not, it renews my WAN dhcp IP automatically. Thus no more manual work and no Internet downtimes.
Please, test if you can/want.
Thanks!
-
Your solution starts dhclient without checking if another instance instance wasn't already running.
edit : Ok, the PHP script part does take the WAN down, this should take care of any dhclient instances that were running.
The real issue is : see your "4/5G modem" as a classic Wifi access point : it converts radio signals to electrical wired Ethernet data bit stream, and the other way around.
Humans can't see radio waves, so we presume they are always fine, and thus emission and reception is good.
In reality, it is a pure chaos.The very first person with a 4G/5G radio device, like a phone, that passes nearby your house, or worse, in your house, can - no .... will ! - disrupt the signal.
There is resilience build in, so one of the devices will change it's frequency, so it sends / receives on a more clear and available channel. Or hops from 4G to 5G, or the other way around.Your issue is probably : the 4G/5G modem device does its best to keep a connection open, using 4G then 5G, and this includes a lot off equipment on the ISP side. If the modem concludes that a 4G/5G is usable, but on a higher 'network', the connection was reset-and-rebuid on the ISP side, the ISP will wait for a new connection creation. But from your side, pfSense didn't not 'saw' a network down event its WAN interface, so the dhcpclient will continue to start to "renew" by asking the known DHCP server a lease renewal. Or : this know DHCP server IP can't be reached any more, as there is no low-level connection. The Ethernet connection that uses this low level connection is gone. The dhcp client should use the initial DHCPDISCOVER etc to rebuild a new connection first.
What the modem should have been doing : if the low level connection goes down, it should pull it's Ethernet interface down. This will signal pfSense to restart the dhcp client, exactly like you did in your one-liner.
Or : thats issue : it didn't.Btw : I'm not using a 4G/5G modem (router) myself, but have friend who has one - a TP-LINK Archer M600. A 4G only device, as 5G doesn't in France (only in the big towns, my friend lives in the middle of nowhere)
Ones in while, he had to use a browser to connect himself to the "modem" GUI to see the status of the connection, it would show : 4G ok ..... but no Ethernet packets what so ever coming in or going out.
This happened randomly, ones in every week or two weeks. Power down the TP-LINK, 10 sec wait and power up would solve the problem.
We somewhat "solved the issue" by restarting the 4G modem router every night at 03 AM.
Since we did this, no more issues what so ever.Btw : the modem/router restart is build into the device, what makes me think the people that made the TP-LINK know about the issue. Updating the modem didn't solve this. What makes me thing a part of the issue is 'upstream'.
Btw : see the Status > Interfaces page.
Checking the "Relinquish Lease" checkbox and the red button calls /etc/inc/interfaces.inc : thefunction interface_configure($interface = "wan", $reloadall = false, $linkupevent = false)
function (line 4017 for my 24.03).
You could call it like this :
interface_configure("WAN",TRUE)
or even
interface_configure("WAN",TRUE, TRUE)
this will also restart dhclient the correct way.
<?php require 'interfaces.inc'; interface_configure("WAN",TRUE); ?>
and place it here : /root/script.php
Call this script with
php -q /root/script.php
I didn't not test this.
-
-
-
This platform is now flagging my reply / next post as spam by 'Akismet.com'
Really Netgate??
-
Not Netgate. The forum-engin, it's protected by "Akismet.com" for, 'reasons'.
I'll give you some up-votes. As soon as you have 5 or so, "Akismet.com" won't bother you anymore.
You've posted some script text, that is considered as 'dangerous' (I guess).
See here Home >> Off-Topic & Non-Support Discussion >> Forum Feedback for more info.
-
Please, see my post here:
https://forum.netgate.com/topic/188034/akismet-com-garbage
There's alternatives for not only for this forum, but also for pfSense (Plus). As everybody knows.
Thanks a lot anyway, I'll log off now