Network IP Address

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How do I find out what the network IP address is?

For example if I have a cable modem with 68.57.200.50 as the IP address and the linksys router assigns PC's on the network 192.168.1.1 how do I find out that the address is 68.57.200.50 running my code on the PC with the IP address assigned to it by the router of 192.168.1.1 ?

Make sense what I'm asking? I like using WMI but if there is another way I'm willing to listen.
 
Demetri

I don't think it is possible to determine the outbound IP address. What you
could do is call up an external page, such as http://www.whatismyip.com/ and
spider that page's content to determine the IP address your connection
actually went out as. However, if there is a transparent proxy involved (at
your ISP for example), you'll get the IP address of the proxy server, and
not the linksys router.

Another approach is that you could determine your gateway address (not sure
how) and then call up the gateway's webpage. This of course would need to be
able to login to the router's web interface, and also navigate to the
correct page. It would be heavily dependant on the router's manufacturer and
version of the software and not all routers have a web interface.








Demetri said:
How do I find out what the network IP address is?

For example if I have a cable modem with 68.57.200.50 as the IP address
and the linksys router assigns PC's on the network 192.168.1.1 how do I find
out that the address is 68.57.200.50 running my code on the PC with the IP
address assigned to it by the router of 192.168.1.1 ?
Make sense what I'm asking? I like using WMI but if there is another way
I'm willing to listen.
 
A third possibility (if the router supports so) ould be using UPnP to query
for the outside IP address.

But these three are all methods possible.

--
Regards

Thomas Tomiczek
THONA Software & Consulting Ltd.
(Microsoft MVP C#/.NET)
(CTO PowerNodes Ltd.)
 
How universal is UPnP? I use the following with success to create a
connection and get external address on a system using XP Internet connection
sharing. Does it work with a LinkSys router or other commonly used home
setups?

Add reference to NATUPNPLib.dll

using NATUPNPLib;
IPEndPoint external;
IPEndPoint local;
public void PrepareForNAT( int publicPort )
{
NATUPNPLib.UPnPNATClass nat = new NATUPNPLib.UPnPNATClass();
IStaticPortMappingCollection spmc = nat.StaticPortMappingCollection;

// make sure not there
try
{
spmc.Remove( local.Port, "TCP" );
}
catch( System.IO.FileNotFoundException )
{
// ok
}

IStaticPortMapping spm = spmc.Add( publicPort, "TCP", local.Port,
"MyLocalName", true, "id for display" );

external = new IPEndPoint( IPAddress.Parse( spm.ExternalIPAddress ),
spm.External Port );
}

// worth having a Dispose method to do a spmc.Remove( local.Port, "TCP" ) to
clean up...

You can check the results by right clicking internet connection, choosing
properties, and pressing the settings button. It takes a bit of time to
load.
 
Back
Top