CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Jul 2002
    Posts
    137

    Need home router's external dynamic IP address. How get it?

    Anyone know how to query (via a C or MFC program) a home router's status to get its external publically viewable IP addresses (that the ISP assigned to it dynamically) or can it be done by somehow pinging a remote server and sending back the real ip addresses assigned to the router. thanks.

  2. #2
    Join Date
    May 2001
    Location
    Oslo, Norway
    Posts
    610
    I am not an expert but this is better than nothing i think:

    1. You can use the tracert.exe command, parse its output to extract the primary gateway address (router IP).

    2. You may use the recently posted article about a custom "trace route" program, which also has the ability to extract the gateway IP.

    3. You need to get familiar with the DHCP protocol - this is what router client (OS) uses to communicate with DHCP enabled router. DHCP protocl impl. shoudl be available on the Internet.

    4. You may use a workaround, which involves parsing the HTTP_REFERER HTTP variable returned from a webserver. This will involve asking internet explorer to connect to 127.0.0.1:80 (or other for that matter) and retrieve and save the variable which contains the IP address of the client requesting the HTTP resource.

    In my opinion, the #3 is the best solution.

  3. #3
    Join Date
    Jul 2002
    Posts
    137

    Re: router's ip address

    Thanks AMn

    But I know the dhcp protocol very well. It does not publish the external router's ip address to the client.

  4. #4
    Join Date
    Jul 2002
    Posts
    137

    Re: router's ip address

    can you give me a link to the trace route program you mentioned? tks

  5. #5
    Join Date
    May 2001
    Location
    Oslo, Norway
    Posts
    610
    sure =)

    here it is :

    http://www.codeguru.com/network/tracert.html

    Regarding the DHCP - like i said i am not expert at this but i know this: router reports its address to the nodes it comunicates with, and if you are one of them then you know it too BEsides, why shouldnt it report the address to you ?

  6. #6
    Join Date
    Jul 2002
    Posts
    137

    router

    Amn

    The router reports its INTERNAL ip address to the internal clients (not its external ip address which is what I want).
    tks

  7. #7
    Join Date
    May 2002
    Location
    Texas
    Posts
    222
    pschiff,

    Many routers use a web interface and/or telnet for administration of the router. You can usually read the external IP address from there.

    Other than that, you'll need to use an internet resource to read your external IP address such as http://whatismyip.com/ .

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured