5

IP Address info from Router

Posted in Internet by parvez 2137 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 http://192.168.1.1/Status_Router.asp | 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.

Thanks!

Comments

User Avatar
matt 2138 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 19 days ago
Чтобы построить по-настоящему теплоэффективный дом, надо позаботиться об утеплении не только стен, но и крыши, подробнее об этом читайте на сайте teletap.org
User Avatar
RickeyCable 18 days ago
Производство мебели на заказ в Санкт-Петербурге, подробности смотрите на сайте akro-spb.ru
User Avatar
Leroyorere 17 days ago
Кольца со вставками из драгоценных и полудрагоценных камней выглядят стильно и солидно. Не удивительно, что многие девушки мечтают, чтобы в день свадьбы жених одел им на пальчик колечко со сверкающими камнями. Читайте об этом подробнее на сайте womanmaniya.ru
User Avatar
parvez 2133 days ago
Thanks Matt for the additional info!
User Avatar
dylanjnsn022 2048 days ago
you jus do this

********************************************

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

********************************************

does the same thing
User Avatar
parvez 2046 days ago
@dylanjnsn022 That does not give you the public IP address.
User Avatar
parvez 2046 days ago
User Avatar
GYLLIWER 2036 days ago
5+
User Avatar
cessnakid 1908 days ago
nice
User Avatar
hawk 1796 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 http://192.168.1.1/RST_st_dhcp.htm 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 1709 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 http://192.168.0.1/modemstatus_home.html

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.