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

    How do i Add more MQTT options or Script when WAN is down to reboot modem

    Scheduled Pinned Locked Moved General pfSense Questions
    16 Posts 4 Posters 1.1k 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.
    • C
      comet424 @comet424
      last edited by

      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

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

        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

        1 Reply Last reply Reply Quote 0
        • NogBadTheBadN
          NogBadTheBad @comet424
          last edited by NogBadTheBad

          @comet424

          What makes you think pfSense has MQTT installed, as @stephenw10 said think you need a new modem or a new ISP.

          Andy

          1 x Netgate SG-4860 - 3 x Linksys LGS308P - 1 x Aruba InstantOn AP22

          1 Reply Last reply Reply Quote 0
          • A
            azdeltawye @comet424
            last edited by

            @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
            
            C 1 Reply Last reply Reply Quote 1
            • C
              comet424 @azdeltawye
              last edited by

              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 UPnP

              so 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 dollars

              also 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 city

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

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

                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

                1 Reply Last reply Reply Quote 0
                • C
                  comet424 @comet424
                  last edited by

                  @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

                  C A 2 Replies Last reply Reply Quote 0
                  • C
                    comet424 @comet424
                    last edited by

                    @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 it

                    reason 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

                    C 1 Reply Last reply Reply Quote 0
                    • C
                      comet424 @comet424
                      last edited by

                      @stephenw10 here is screen grabpf.PNG of home assistant

                      C 1 Reply Last reply Reply Quote 0
                      • C
                        comet424 @comet424
                        last edited by

                        and that miniupnp website didnt work

                        but ill google it.. and pfsense to see if it can broadcast ip address or what not

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

                          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

                          1 Reply Last reply Reply Quote 0
                          • A
                            azdeltawye @comet424
                            last edited by

                            @comet424

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

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