How to retrieve the IP Address Assigned to the machine by ISP

7,190

Solution 1

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 (http://checkip.dyndns.com/) on occasion.

Solution 2

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.

example:

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

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.

Solution 3

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

IPCONFIG

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.

Solution 4

You could download WGet then run the following command:

wget -q -O - http://automation.whatismyip.com/n09230945.asp

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

Solution 5

I like http://www.ipchicken.com/ .

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:
7,190

Related videos on Youtube

Gunwant Saini
Author by

Gunwant Saini

Updated on September 17, 2022

Comments

  • Gunwant Saini
    Gunwant Saini almost 2 years

    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 192.168.1.2 and is having a DSL router provided by the ISP which will connect to the Internet with Win XP SP2

    Looking for favorable replies.

    Thanks

  • Sam Cogan
    Sam Cogan about 15 years
    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
  • user1686
    user1686 about 15 years
    Also, what if user has many NICs? What if a NIC has more than one IP?
  • Kevin Kuphal
    Kevin Kuphal about 15 years
    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.
  • Spence
    Spence about 15 years
    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.
  • Sam Cogan
    Sam Cogan about 15 years
    I agree that the question is poorly phrased, and your answer could be a valid response, I don't feel it deserves a downvote.
  • David Pashley
    David Pashley about 15 years
    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 Schwartz
    David Schwartz almost 13 years
    The local machine has no idea, and in fact there's no guarantee that there is one and only one such IP address.