Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

my question is regarding the IP Address assigned to a machine, whenever we go to any site which reveal our IP Address, they display a number which is assigned to the machine through which we are accessing the Internet, i want to know how is it possible to retrieve the IP Address from the local machine using which commands, if any, rather than going to the sites to know the IP Address assigned to the machine by ISP. the local machine is having an IP Address of and is having a DSL router provided by the ISP which will connect to the Internet with Win XP SP2

Looking for favorable replies.


share|improve this question

Login to your DSL router and look at the status page. If you want to log this information build a script that simply downloads the status page.

You could also write a script with curl/wget that simply gets the page ( on occasion.

share|improve this answer
This obviously depends on the DSL router being configured to allow customers to gain access to them. Many consumer grade ISPs tend to ship routers with no user-visible interface. – David Pashley Jun 3 '09 at 18:01

You're just looking for the IP assigned to your NIC? Execute:


from a command prompt.

Edit: Re-re-re-reading your question again, it looks like you're asking for the IP address assigned to the Internet-side interface of your router. That's not stored on the local machine. You're going to have to write something to get it from the router itself, or rely on a third-party site to get you that.

share|improve this answer
This will only work if they are directly connected to the internet, I believe he is looking to get the external IP when connected to a NAT router – Sam Jun 3 '09 at 17:44
Also, what if user has many NICs? What if a NIC has more than one IP? – grawity Jun 3 '09 at 17:48
You're downvoting me for at least trying to parse his poor English? Yeesh! I guess I should ask for clarification in a comment rather than in an answer first, eh? Yeah-- if he has multiple NICs he's going to see multiple IP addresses. Far be it from me to assume that the poster has some degree of competence and would be able to figure that out. – Evan Anderson Jun 3 '09 at 17:53
I agree that the question is poorly phrased, and your answer could be a valid response, I don't feel it deserves a downvote. – Sam Jun 3 '09 at 17:56

I like .

It doesn't provide the additional information that Kevin's site does, but I find the name sticks in people's heads and is easy to remember.

share|improve this answer

If your DSL router has SNMP, you can usually fetch via snmpget the IP address that is assigned to the external interface of your DSL router. Most, (but not all) DSL router manufacturers have SNMP, and they support MIB-II.


[root@myhost ~]# snmpwalk -v1 -c ***** ipAdEntAddr
IP-MIB::ipAdEntAddr. = IpAddress:

In this case, I am querying the "inside" IP with SNMP and I get the following IP as my external IP. where ** is my SNMP community string or password. ipAdEntAddr is the SNMP OID string i queried to get the answer.

share|improve this answer

You could download WGet then run the following command:

wget -q -O -

You will need to run this either from the WGet directory, or add it to your systems Path.

share|improve this answer
I think this is the best option to do it programatically. It is unclear from the question whether the information can come from an online source or must only come from information stored on the local machine. – Kevin Kuphal Jun 3 '09 at 17:53
The local machine has no idea, and in fact there's no guarantee that there is one and only one such IP address. – David Schwartz Aug 28 '11 at 6:41

You can download this:

Extract it, then go to a command prompt and type "curl"

(same idea roughly as above by Sam)

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.