Wednesday, January 12, 2011

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

Hello Friends

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

  • 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.

    David Pashley : 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.
    From Zoredache
  • 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.

    Sam Cogan : 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
    grawity : Also, what if user has many NICs? What if a NIC has more than one IP?
    Evan Anderson : 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 : I agree that the question is poorly phrased, and your answer could be a valid response, I don't feel it deserves a downvote.
  • You could download WGet then run the following command:

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

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

    Kevin Kuphal : 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.
    From Sam Cogan
  • 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.

    From Peter
  • 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.

    From netlinxman
  • You can download this: http://curl.haxx.se/latest.cgi?curl=win32-nossl

    Extract it, then go to a command prompt and type "curl http://whatismyip.com/automation/n09230945.asp"

    (same idea roughly as above by Sam)

    From TheCleaner

0 comments:

Post a Comment