IP Address info from Router

Posted in Internet by parvez 2349 days ago

Installed lynx and added egrep and sed magic to get the IP Address information from my CISCO Router.

/opt/local/bin/lynx -dump -auth=admin:PASSWORD -accept_all_cookies | egrep -E ":  " | sed "s/   :  //g" | awk 'NR==3'

I did not want to use whatismyip.com to get my IP Address. Prefer to get the info locally.



User Avatar
matt 2349 days ago
Note: For this to work correctly you have to have lynx installed in `/opt/local/bin` - i.e. you have to install it via macports:

If you don't want to go to the trouble of getting MacPorts, you can install Lynx on it's own, and modify the script - most likely to `/usr/local/bin`
User Avatar
HaywoodEnubs 231 days ago
Чтобы построить по-настоящему теплоэффективный дом, надо позаботиться об утеплении не только стен, но и крыши, подробнее об этом читайте на сайте teletap.org
User Avatar
RickeyCable 229 days ago
Производство мебели на заказ в Санкт-Петербурге, подробности смотрите на сайте akro-spb.ru
User Avatar
Leroyorere 228 days ago
Кольца со вставками из драгоценных и полудрагоценных камней выглядят стильно и солидно. Не удивительно, что многие девушки мечтают, чтобы в день свадьбы жених одел им на пальчик колечко со сверкающими камнями. Читайте об этом подробнее на сайте womanmaniya.ru
User Avatar
parvez 2344 days ago
Thanks Matt for the additional info!
User Avatar
dylanjnsn022 2259 days ago
you jus do this


ifconfig | grep 'broadcast'| awk '{print $2 }'


does the same thing
User Avatar
parvez 2257 days ago
@dylanjnsn022 That does not give you the public IP address.
User Avatar
parvez 2257 days ago
User Avatar
GYLLIWER 2247 days ago
User Avatar
cessnakid 2120 days ago
User Avatar
hawk 2008 days ago
You don't need lynx for this, curl can do the job (and is installed on every mac).

Here is the command I'm using to get the IP from my NETGEAR WNDR3400v2 router running the firmware version V1.0.0.34_1.0.52

echo "IP address\n$(curl -u admin:password 2>/dev/null | egrep -iA 2 "ip address" | egrep -o '([0-9]{1,3}\.?){4}')"

You may need a different pattern to search for, so open the status page of your router's web interface and study the HTML source code. In my case, the relevant part looks like this:

Edit: Nevermind, the markdown on this site is broken.
User Avatar
ksb 1921 days ago
If you put your password in ~/.netrc ( see the curl manual page), then you may use

this command for a QWest or Century Link modem:

> curl -s --netrc

That gets you the raw text, then a grep for

> var wanInfNames = htmlDecodeStr

Gets you a line with all sorts of great things to know about the modem. I parsed

that with a little perl, and now I have a near-real-time external IP address.

Log in to comment or register here.