1

I currently query an external server for my external IP address, but I should really query my own router. It would limit the traffic to the LAN, and the router certainly knows what the address is. Does anybody know if there's a concise way of querying the router (other than screen scraping the status page). Thanks!

4
  • Depends on what you are trying to do with it. Are you looking for a powershell script, vbscript script, bash script, python script, ect... Your platform and how you plan on using the info will greatly affect answers. Dec 29, 2013 at 21:31
  • Are you comfortable using SNMP?
    – Bandrami
    Dec 29, 2013 at 21:58
  • 2
    If the router itself is behind NAT, it may not know its own external IP address. Dec 29, 2013 at 22:36
  • @Bandrami Yes, SNMP would have been the "correct" way, but more complex than my eventual solution.
    – erict
    Nov 4, 2015 at 0:09

3 Answers 3

3

in console, run "nvram get wan_ipaddr"

3
  • this is not easily done with a program.
    – erict
    Sep 4, 2014 at 12:39
  • @erict It looks pretty concide to me. Please make your requirements clearer. Oct 8, 2015 at 10:45
  • @David As the title indicates, I want to do this programmatically. My requirements are that I have a server that wants to know the external internet address, even though it is NATed through a DD-WRT router. I was querying an external server like whatismyip.com, but wanted a solution that doesn't depend on external sources. I eventually found that I can query the DD-WRT router's page called Status_Internet.live.asp which returns a bunch of info, including the WAN IP.
    – erict
    Nov 4, 2015 at 0:07
2

I found an acceptable solution. Request page http://router_ip/Status_Internet.live.asp from your dd_wrt router (it needs authentication). This output is not dependent on the GUI style, since it is only the auto-refresh data. It's very easy to extract the IP address from the returned data.

0

Try to install php, if it isn't already installed.
Make a floder.
Make a php internal webserver -- the one built in.
Let it return the ouput from

ifconfig |grep "inet addr" |cut -d: -f2 |cut -d" " -f1

It will return all the ip addresses it has (internal, external and loopback). You can then poll this instead of the external server.

1
  • 1
    wouldn't work -- need the external IP on the other side of a router (specifically a DD-WRT router). Your suggestion would return the local IP addresses
    – erict
    Dec 30, 2013 at 0:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .