Find an Airport Extreme's WAN address in Terminal
Dec 30, '09 07:30:00AM • Contributed by: runforesterrun
Dec 30, '09 07:30:00AM • Contributed by: runforesterrun
I wrote a bash script that will find the current IP address of the WAN port on an Airport Extreme (and possibly other wireless routers) from the command line. It also works on a Linux-based computer, if you have the package net-smnp installed.
Go to the Advanced settings in your AirPort configuration, and select the Statistics tab. Make sure that 'Allow SNMP' is checked, and note the 'SNMP Community String -- it can be changed, but I would just keep it at public. Save your settings if they've been changed.
In the script below, the variable SNMPKEY needs to be changed if the 'SNMP Community String' is anything but public. You can also pass it from the command line if you wish. Here's the script:
[robg adds: I haven't tested this one.]
Go to the Advanced settings in your AirPort configuration, and select the Statistics tab. Make sure that 'Allow SNMP' is checked, and note the 'SNMP Community String -- it can be changed, but I would just keep it at public. Save your settings if they've been changed.
In the script below, the variable SNMPKEY needs to be changed if the 'SNMP Community String' is anything but public. You can also pass it from the command line if you wish. Here's the script:
#!/bin/sh SNMPKEY="public" if [ $# = 1 ] ; then SNMPKEY="$1" fi IFS=" " set -- $(netstat -nr | egrep '^0.0.0.0|^default') ROUTER=$2 set -- $(snmpwalk -Os -c "$SNMPKEY" -v 1 "$ROUTER" ipRouteNextHop.0.0.0.0) set -- $(snmpwalk -Os -c "$SNMPKEY" -v 1 "$ROUTER" ipRouteNextHop.$4) echo $4
•
[13,632 views]
