Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Retrieve gateway's internet IP

Posted on 2003-10-26
9
Medium Priority
?
634 Views
Last Modified: 2012-05-04
Let's asume a LAN with some windows machines, one of
it with the IP 10.1.1.1.
10.1.1.1 is connected to the internet via a gateway with
the LAN IP 10.1.1.254.
The ISP assigned the IP 80.142.23.56 to the gateway.

My question is:
Do you know a way using winsock or iphlpapi to retrieve
this last IP? I tried GetIpForwardTable and
GetBestRoute but those functions just give me the
gateway's LAN IP.

Thanks in advance!
0
Comment
Question by:Last_Inquisitor
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 

Expert Comment

by:techwiz330
ID: 9624605
Not sure about those methods, but a quick an easy way to determine your external IP is just to visit http://www.whatismyip.com.
0
 
LVL 32

Expert Comment

by:LucF
ID: 9625598
If you can login to your gateway, you should be able to check it there also.

LucF
0
 
LVL 1

Author Comment

by:Last_Inquisitor
ID: 9626118
You are both right. Of course there are many ways to
check that IP MANUALLY. But I'm looking for a way to
get it in one of my programs. I want to code a function
like

const char* GetExternalIP(const char *gateway_lan_ip);

techwiz330:
I already thought of visiting a service like whatismyip,
retrive the HTML page and parse it to get the IP.
But I want to avoid using external services.
0
Plesk WordPress Toolkit

Plesk's WordPress Toolkit allows server administrators, resellers and customers to manage their WordPress instances, enabling a variety of development workflows for WordPress admins of all skill levels, from beginners to pros.

See why 2/3 of Plesk servers use it.

 
LVL 43

Expert Comment

by:JFrederick29
ID: 9626598
Perhaps you can pull that info from the registry:

Search for DefaultGateway or DhcpDefaultGateway depending on whether you use DHCP or not to determine the exact location of the setting.
0
 
LVL 1

Author Comment

by:Last_Inquisitor
ID: 9626633
JFrederick29:
This won't work. It will just lead me to the gateway's LAN IP, not
its external IP. Retrieving the LAN IP is not a problem at all, but it's
not what I want.
Thanks anyway.
0
 
LVL 2

Accepted Solution

by:
jlindq earned 750 total points
ID: 9626826
The external IP is not in your computer, it's only defined on the gateway. You have to make an external call to it to get it (if it supports this, which I doubt) or use some other external source (as parsing the HTML page as discussed above).
0
 
LVL 1

Author Comment

by:Last_Inquisitor
ID: 9626871
#?&*% grummel!
I feared it...
Well, thanks to all of you, especially jlindq for
taking away all illusions...
0
 

Expert Comment

by:hypomarc
ID: 9646398
heres an intresting one
form a dos prompt, type do

tracert 158.152.1.58

the first ip address will be your own gateway, the second listed will be the isp's gateway
0
 
LVL 1

Expert Comment

by:wickedz
ID: 9647849
See if your router supports SNMP and you can usually grap the info you want that way. SNMP can be very powerful when used correctly.
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

During and after that shift to cloud, one area that still poses a struggle for many organizations is what to do with their department file shares.
Tech spooks aren't just for those who are tech savvy, it also happens to those of us running a business. Check out the top tech spooks for business owners.
Viewers will learn how to connect to a wireless network using the network security key. They will also learn how to access the IP address and DNS server for connections that must be done manually. After setting up a router, find the network security…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question