How do i Add more MQTT options or Script when WAN is down to reboot modem
-
so i have issues where my modem gets stuck offline and connecting interfacer in Pfsense clicking Connect will do nothing.. you gotta physically unplug modem
i looking for 2 options
1.. if Pfsense sees WAN connection is down "-" more then 1 min run this script .. and that script would tell a raspberry pi with a Relay on it with the modem connected to the relay.. so it will do a cold reboot of the modem.. so simulates you unpluggin and plugging back in..2.. Pfsense has a limited MQTT features just packets sent and received.. how can i edit MQTT to add WAN connection to MQTT so in Home Assistant. if it says Number to "-" for longer then 1 or 2 min that it will instruction a raspberry pi to reboot the modem..
for either situation this would reboot the modem a cold reboot in the middle of the night when people sleep and not be offline.. especially since more and more crap is run online not offline but i dont have any of those google or alexia devices.. but just incase in future.. they are no good if offline.. and with my rural lousy internet things need to be rebooted..
and do you guys know why modems hang that they need to be physically unplugged the power and repower back up to get them working agian and simplying rebooting pfsense is not good enough either .. as a reboot of pfsesne does nothing it has to be the modem.. so i looking for options
-
or even an ardunino plugged into a usb port on the pfense box that tells the ardunino reboot modem by just flip on off relay when pfsense detects WAN has gone to "-" more then a minute or 2
and then wait 5 min to see if it come back online -
Can you down/up the WAN logically to bring back the connection?
I mean this seems like quite an extreme solution to something that shouldn't happen.
Why is the modem failing? What state it is in when it does?Steve
-
@stephenw10
no when i mentioned connecting interface in In Pfsense connect does nothing (i ment under interfaces. and clicking the Connect button) had no affectit shows bunch of info but if u refresh wan connection is still down and like i mentioned if you reboot Pfsense WAn is still down till you reboot the modem.
so reason i wanted more MQTT options or how do i edit the txt file for MQTT thats already saved in Pfsense so i could add WAN Connection so that way like home assistant sees "-" instead of a IP address it tell an ardunino or Raspberry pi to toggle a relay which cycles the dsl modem
the modem not really failing.. i guess its Stalled the lights are all on doesnt blink anymore.. so a reboot cures that issue so instead of blinking all leds are solid... and where the modem is its not accessable.. and if the middle of the night when your sleeping u dont know the modem is down till you wake up
so i wanted it automated reason i was looking for more MQTT other then just the packets sensors they offer
-
does anyone know where the Pfsense MQTT file is located i still havent found where Pfsense has saved the file so i can add to it.
i tried searching the forums didnt find it either.. where its located..anyone know? as i wanna add PPOE WAN Uptime and some others to send to send to Home Assistant
-
Does the modem have an interface you can connect to and reboot it manually?
How does the PPPoE connection fail?
I mean it sounds like it might be new modem time to me.
Steve
-
What makes you think pfSense has MQTT installed, as @stephenw10 said think you need a new modem or a new ISP.
-
@comet424
Hello, I had the exact same problem with my modem going off into the weeds and requiring a hard reboot. Looking at the modem logs it appeared that the cause was excessive T3 and T4 timeouts. My ISP, Comcast, eventually fixed the problem but it took several years...I wrote a simple BASH script for a RPi that checked internet connectivity by pinging Google and would cycle power to the modem if there were 5 unsuccessful pings. Also it checked to make sure the local gateway was up so it wouldn't reset the modem if the network cable to the pi was unplugged.
I wrote this script prior to discovering pfSense so it was used with a simple SOHO router where MQTT was not an option...
#!/bin/bash # LOGFILE=/home/pi/network-monitor.log i=0 # Initialize counter while true # loop forever do # ping local gateway if [ "$(ping -c 1 192.168.10.1 | grep '100% packet loss')" ] then echo "$(date "+%m %d %Y %T") : Gateway not reachable..." echo "$(date "+%m %d %Y %T") : Gateway not reachable..." >> $LOGFILE i=0 # reset counter else echo "$(date "+%m %d %Y %T") : Gateway connection OK." # ping google and comcast dns servers if [ "$(ping -c 1 8.8.8.8 | grep '100% packet loss')" -a "$(ping -c 1 75.75.75.75 | grep '100% packet loss')" ] then : $((i = $i + 1)) # increment counter echo "$(date "+%m %d %Y %T") : Internet down!" echo "$(date "+%m %d %Y %T") : Internet down!" >> $LOGFILE if [ $i -eq 5 ] then gpio -g mode 26 out # turn on relay 1 echo "$(date "+%m %d %Y %T") : Powering down Modem..." echo "$(date "+%m %d %Y %T") : Powering down Modem..." >> $LOGFILE sleep 300 # Modem off timer gpio -g mode 26 in # turn off relay 1 echo "$(date "+%m %d %Y %T") : Restarting Modem..." echo "$(date "+%m %d %Y %T") : Restarting Modem..." >> $LOGFILE i=0 # reset counter fi else echo "$(date "+%m %d %Y %T") : Internet connection OK." i=0 # reset counter fi fi sleep 300 # Main loop timer done
-
sorry my bad not MQTT pfsense broadcasts
UPnP so how do i edit the UPnP what it sends to home assistant? sorry dislexia i read MQTT wrong because i trying to figure that out and i mixed it up with UPnPso it sends home Assistant.. bytes send and recevied.. and the current speed its sending and receiving.. so how do i get the UPnP file??
as for modem. i PPOPe from Within PFSense accessing the modem is disabled..
ontop of that i have to purchase the Modem at a cost of more then 100 dollarsalso i live in Rural area.. means i live Farm Country land.. so Phone lines dont get fixed like you think if you live in a City.. your not a priority and they only bother to fix ur line from house to the road.. the rest is fixed if everyone complained.. as they say chipmunks get in there and chew the lines and ice and winter ruins them and rain.... so i deal with it..
but getting a new ISP or Modem isnt going to help since Bell Owns the wires of canada and they cant be bothered unless there is a big issue
so changing ISPs wont help because all internet providers use Bells Modems DSL things.. as there is only 1 kinda phone line in the country and bell owns it..
i like that Script i was going to do the same.. but through Home Assistant but if it seen "-" for PPOE or "WAN"
as like i mentioned a reboot of pfsense does nothing has to be a physcial reboot of the modem.. and living in the country away from major cities you dont get the best internet like people that live in cityFarmers Feed Cities but Farmers get the worst internet and bottom of the list for improvements..
and sorry about the disliexia and miss reading MQTT for UPnP broadcast..
-
pfSense uses miniupnpd for UPnP.
I'm not sure it can send anything more that maybe connection info for states it has opened.
What exactly do you see reported currently?
Steve
-
@azdeltawye do you set that script to run like every hour? in a crontab in the raspberry pi
and i made mistake wasnt MQTT was UPnP pfsense is broadcasting
so i hoping i get get Uptime and WAN and PPOE through the UPnP broadcast
-
@stephenw10
it reports packets in home assistant for pfsense.. the numbers are high because pfsense hasnt been rebooted in a while.. its re downloading games from epic games its a pain. and slow
i have even tried reset states and filter reload but thats never fixed itreason i was hoping i could get Pfsense to broadcast the connection info then if it shows "-" when modem goes down or lines home assistant would reboot a raspberry pi would reboot the modem.. like the guys script thats what i was asking for or an arduino..
as for Pfsense its workigh right now.. but when i loose internet connection PPOE "-" shows a dash so reason i trying to find a way if Internet goes to "-" instead of an IP Address then reboot a Arduino or Raspberry pi... and ill loose modem connection with or without downloading..
and i cant afford a new modem as they make you buy a new modem only a 1 year warrenty then your have to buy a new one -
@stephenw10 here is screen grab of home assistant
-
and that miniupnp website didnt work
but ill google it.. and pfsense to see if it can broadcast ip address or what not
-
The link didn't work? Weird, works fine for me.
One thing that UPnP IGD should be able to do it report the WAN IP so that should tell you if the modem is up.
For some reason though that doesn't work for me here:steve@steve-MMLP7AP-00 ~ $ upnpc -s upnpc : miniupnpc library test client, version 2.1. (c) 2005-2019 Thomas Bernard. Go to http://miniupnp.free.fr/ or https://miniupnp.tuxfamily.org/ for more information. List of UPNP devices found on the network : desc: http://172.21.16.1:2189/rootDesc.xml st: urn:schemas-upnp-org:device:InternetGatewayDevice:1 Found a (not connected?) IGD : http://172.21.16.1:2189/ctl/IPConn Trying to continue anyway Local LAN ip address : 172.21.16.5 Connection Type : IP_Routed Status : Connected, uptime=645s, LastConnectionError : ERROR_NONE Time started : Tue Feb 2 00:24:41 2021 MaxBitRateDown : 1000000000 bps (1000.0 Mbps) MaxBitRateUp 1000000000 bps (1000.0 Mbps) GetExternalIPAddress failed. (errorcode=501) Bytes: Sent: 2907268482 Recv: 870088557 Packets: Sent: 106471691 Recv: 147320624
It could be because it's an internal device and miniupnpd sees a private WAN IP as invalid.
Steve
-
@azdeltawye do you set that script to run like every hour?
No, that simple script just runs continuously. No crontab needed. The loop timer is set to 300 seconds which is 5 minutes. Five unsuccessful pings takes 25 minutes, reboot of the modem is another 5 minutes, so 30 minutes total for a full reset cycle. You could change the timer settings to whatever works for you, I just picked 5 min because it seemed reasonable...
I still run that script on a RPi now but my ISP seems to be much more reliable and it hasn't had to reboot the modem in over a year now. Originally when I first implemented that setup I was being subjected to 70+ outages per year...