Page 1 of 1

Router IP address monitoring?

Posted: Mon Apr 21, 2014 5:06 pm
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!

Re: Router IP address monitoring?

Posted: Mon Apr 21, 2014 5:21 pm
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 :)

Re: Router IP address monitoring?

Posted: Tue Apr 22, 2014 9:12 am
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.

Re: Router IP address monitoring?

Posted: Sat Apr 26, 2014 4:27 pm
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?

Re: Router IP address monitoring?

Posted: Sat Apr 26, 2014 10:56 pm
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?

Re: Router IP address monitoring?

Posted: Sun Apr 27, 2014 5:59 pm
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 ;).

Re: Router IP address monitoring?

Posted: Mon Apr 28, 2014 10:39 am
by slansing
Hooray! Let us know how this works out for you pixel!