Router IP address monitoring?

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
pixelpshr
Posts: 14
Joined: Sun Feb 23, 2014 7:51 am

Router IP address monitoring?

Post by pixelpshr »

My ISP (Cox) has a nasty habit of changing the IP address of my home network router (Airport Extreme). From the inside of my network I can still reach it as 198.162.1.1, but the WAN IP Address is subject to change without notice. Is there any way to have a Nagios server (currently have v4.0.4) running inside the LAN check the WAN address of the router and send an email if it changes?

Thanks!
User avatar
jsmurphy
Posts: 989
Joined: Wed Aug 18, 2010 9:46 pm

Re: Router IP address monitoring?

Post by jsmurphy »

Find out if your router supports SNMP, find out what the SNMP OID is that contains the WAN address and then use check_snmp to do a regex match on the value of that OID. As long as your router supports SNMP, it should be easy :)
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Router IP address monitoring?

Post by tmcdonald »

Or do something like this in a bash script:

Code: Select all

ip=`curl -s http://icanhazip.com/`
echo "$ip"
I know it might look kinda silly, but icanhazip.com does one thing: spit out your IP in a plain text format. No frills, no anything fancy. I use it it a lot of places for just this sort of thing. Obviously a proxy would affect the result, but that should not be an issue in most cases.
Former Nagios employee
pixelpshr
Posts: 14
Joined: Sun Feb 23, 2014 7:51 am

Re: Router IP address monitoring?

Post by pixelpshr »

Ok, I admit to being WAY over my head here. I did find the check_snmp script and I found the mibdepot.com and oid-info.com websites, which gave me some info. but the output of the script is always "no such variable name. As in:

Code: Select all

$ ./check_snmp -H 192.168.1.1 -o iso.org.dod.internet.private.enterprises.apple.airport.3.1
External command error: Error in packet
Reason: (noSuchName) There is no such variable name in this MIB.
Failed object: AIRPORT-BASESTATION-3-MIB::abs3SysConf
Any idea what the WAN address OID might be, or how to find the list of OIDs supported by the device?
Last edited by pixelpshr on Sat Apr 26, 2014 10:57 pm, edited 1 time in total.
pixelpshr
Posts: 14
Joined: Sun Feb 23, 2014 7:51 am

Re: Router IP address monitoring?

Post by pixelpshr »

I have found the snmpwalk command which lets me display all the OIDs for my router. With a bit of coercion, I was able to find a result that might move me along the road to solving this problem. A command that looks like this:

Code: Select all

$ snmpwalk -v 1 -c public 192.168.1.1 | grep "IpAddress: 127.0.0.1" | grep "ip.21.1.7" | grep -v "7.127"
IP-MIB::ip.21.1.7.98.166.83.50 = IpAddress: 127.0.0.1
And then, pushing that into the check_snmp:

Code: Select all

$ ./check_snmp -H 192.168.1.1 -o ip.21.1.7.98.166.83.50
SNMP OK - ddress: 98.166.83.50 | 
Now, I can write a version of the check_snmp program, maybe check_snmp_IpAddress, that would run with the same parameters as above, but on failure would run the snmpwalk as above and would include those results in an email to the admin group. But, is this really the best way to find the IP address for the device?
User avatar
jsmurphy
Posts: 989
Joined: Wed Aug 18, 2010 9:46 pm

Re: Router IP address monitoring?

Post by jsmurphy »

You're so close, Well done!

All you need to do now is tell it what you expect the address to be in Nagios:

Code: Select all

./check_snmp -H 192.168.1.1 -o ip.21.1.7.98.166.83.50 -s 98.166.83.50
If that address changes, then it will raise an error and email you the new IP Address. The OID will contain whatever the current address is, now that you have found the OID that contains the address for the WAN interface you won't need to run that SNMP walk again ;).
slansing
Posts: 7698
Joined: Mon Apr 23, 2012 4:28 pm
Location: Travelling through time and space...

Re: Router IP address monitoring?

Post by slansing »

Hooray! Let us know how this works out for you pixel!
Locked