How Setup Dynamically Updating Gateway IP DNS Alias?
My pfSense WAN connects to a cable modem in bridge mode and then on to Xfinity. A Raspberry Pi (Raspbian and Node-RED) sits on one of the LANs and monitors LAN/WAN connectivity to log and alert on component outages and instability. On the uplink, the Pi pings (1) the pfSense firewall LAN IP, (2) the cable modem admin IP, (3) the Comcast upstream gateway IP, and (4) google.
I could not come up with a clever way on the Pi to discover the Comcast gateway IP. For now, I added a Host Override in the pfSense DNS Resolver to map isp-gateway.local.lan to the Comcast gateway IP. The Pi can ping the Comcast gateway fine using this name.
But my Comcast Internet connection is not a static IP. It doesn’t change often but it does change. I either need a clever way to determine the current Comcast gateway IP from the Pi, or a way in pfSense to update the configured gateway IP alias name periodically (cron) or maybe a script run when the uplink connection is established.
Thoughts and suggestions welcome.
JKnott last edited by
Check the host name for the IP you get. You might find it's based on modem and router MAC addresses, as mine is. In that case, the host name won't change, unless you change hardware. You can then create an alias for the long host name you get for something easier to remember.
If you’re just looking for ideas, here’s what I came up with a few years ago and its still working fine. I have a lab domain (one that I just fool around with various web projects, DBs, PHP applications) My Spectrum home IP address rarely changes but like you said, it does change. So, I wrote a CRON job from my pFsense router to ping out every few minutes to a web page I wrote. The web page sees what the calling IP address is and compares it to the current IP stored in its DB. If it’s the same, nothing happens. If it is different then it stores the new address, sends me a text message, and activates my NameCheap APIs to change the IP address and DNS Records for all my subdomain.domain.com URLs which target various servers and devices at home via a reverse proxy. That way the links are always up to date and I can access PLEX, NAS drives and my home automation server without any problems.
The web app also monitors the time between pings (10mins for example) and if the time exceeds specified limits then it assumes there was an internet outage and alerts me with the approximate time and outage duration. Sometimes you can lose internet service and not know it real time but you still want to know it happened.