473,469 Members | 1,685 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to retieve public IP of NIC / Router

Hi All, anyone know of a way to programatically get the WAN ip address of either a NIC or router ?
Apr 17 '07 #1
6 5801
"Pete Kane" <pj**********@uku.co.ukwrote in message
news:%2******************@TK2MSFTNGP06.phx.gbl...
Hi All, anyone know of a way to programatically get the WAN ip address of
either a NIC or router ?
If it is a NIC in your computer, you can get all its network addresses by
means of WMI. There's an example here:
http://www.codeproject.com/cs/system...&select=705111

However, the case of a router is more complex: The router hides the
external address from the internal network, so you can't get directly the
WAN address unless you can login into the router and query its operating
system for the configuration. This is different for different brands and
models, so there isn't a general answer.
If there is a server on the WAN side that you can query, an alternative
is to send a network request to that server, and have the server reply to
you with the return address that it is receiving, which would be the WAN
address of your router. If your WAN connects to the Internet, there are
various servers that offer this service to the public, for instance
http://whatsmyip.org/

Apr 17 '07 #2
On Tue, 17 Apr 2007 07:30:17 -0700, Alberto Poblacion
<ea******************************@poblacion.orgwro te:
[...]
However, the case of a router is more complex: The router hides the
external address from the internal network, so you can't get directly
the WAN address unless you can login into the router and query its
operating system for the configuration. This is different for different
brands and models, so there isn't a general answer.
This is true for .NET, since as far as I know there's no Universal Plug
and Play support in .NET. However, if you're willing to use p/invoke to
get at the unmanaged Windows API support for UPnP, that can be used to
find out your "real" Internet address. Not all routers support UPnP, but
most do and so using UPnP would solve the question in most cases.

A truly general-purpose solution doesn't really exist, though as Alberto
suggests you may be able to rely on some server on the Internet that can
reply to a request asking it what your Internet address is.

Most of the time, an application should not need to know what its Internet
address is. For those applications that do need that infomation, most of
the time UPnP will work. In the rare cases when an application needs to
know its Internet address AND UPnP isn't supported, it may well be
sufficient simply to allow the user to enter the IP address by hand.

Pete
Apr 17 '07 #3
Peter Duniho wrote:
On Tue, 17 Apr 2007 07:30:17 -0700, Alberto Poblacion
<ea******************************@poblacion.orgwro te:
>[...]
However, the case of a router is more complex: The router hides the
external address from the internal network, so you can't get directly
the WAN address unless you can login into the router and query its
operating system for the configuration. This is different for
different brands and models, so there isn't a general answer.

This is true for .NET, since as far as I know there's no Universal Plug
and Play support in .NET. However, if you're willing to use p/invoke to
get at the unmanaged Windows API support for UPnP, that can be used to
find out your "real" Internet address. Not all routers support UPnP,
but most do and so using UPnP would solve the question in most cases.

A truly general-purpose solution doesn't really exist, though as Alberto
suggests you may be able to rely on some server on the Internet that can
reply to a request asking it what your Internet address is.

Most of the time, an application should not need to know what its
Internet address is. For those applications that do need that
infomation, most of the time UPnP will work. In the rare cases when an
application needs to know its Internet address AND UPnP isn't supported,
it may well be sufficient simply to allow the user to enter the IP
address by hand.

Pete
thanks very much to you both
Apr 18 '07 #4
i having problem in oracle 9i dataBase------
i want to convert my oracle data to sql 2000.....but i cant convert
the hindi data from oracle to sql 2000...
means......
i having table in oracle9i...
CREATE TABLE SC_CODE (
GRANT_NO VARCHAR2 (3),
H_CODE VARCHAR2 (13),
FIN_YEAR VARCHAR2 (8),
NAME1_HIN NVARCHAR2 (130),
NAME2_HIN NVARCHAR2 (130),
NAME3_HIN NVARCHAR2 (130),
NAME4_HIN NVARCHAR2 (130),
NAME5_HIN NVARCHAR2 (130),
PRIMARY KEY ( GRANT_NO, H_CODE, FIN_YEAR ))
an having data like----------------------->
04 4059600510101 ¿¿¿¿¿¿ ¿¿¿¿¿¿¿ ¿¿
¿¿¿¿¿¿¿(50¿¿¿¿¿0¿¿0¿0)
1
0
04 4059600510102 ¿¿¿¿¿¿¿¿¿ ¿¿¿¿¿ ¿¿¿¿ ¿¿ ¿¿¿¿¿
¿¿¿¿¿¿¿ ¿¿
¿¿¿¿¿¿
0
0
04 4059600510300 TEHSILON KE
AVASIYE
66667
0
0
5965
06 2029000010400 ¿¿¿¿¿¿ ¿¿¿¿¿¿ ¿¿¿¿¿¿¿¿ (¿¿¿0 ¿¿0
07 ¿¿
¿¿¿¿¿¿¿¿¿¿¿¿)
0
2390
these symbol show ¿¿¿¿¿¿ ¿¿¿¿¿¿¿ ¿¿----->Datain oracle in Hindi.
my task is to covert the whole ¿¿¿¿¿¿ ¿¿¿¿¿¿¿ ¿¿ into hindi as it.
after convertion i saw it never changed it into hindi...it look like
same as in oracle side

i having no problem if i used my front end to insert data into
oracledata base....i having both option hindi and english...
bt when i go throudh my database i never seen the my data in hindi it
look like ¿¿¿¿¿¿ ¿¿¿¿¿¿¿ ¿¿.

what i did for it......(but never suceed...)

The database character set: use AL32UTF8. You can theoretically use
IN8ISCII, which would give you space savings, but as both Java and
Windows support Hindi (actually: the Devanagari script) through
Unicode, you should use Unicode. This way your database will be
prepared for other languages, including other Indian and South Asian
languages.

1.Have 0racle 9i on windows 2000 enterpiseEdition and client on same

2. regedit and changed NLS_LANG. Change the value to
AMERICAN_AMERICA.UTF8 . For 9idatabse as well as devloper suite.

3. Internet explorer changed the following font Lucida Sans Unicode

4. SELECT * from NLS_DATABASE_PARAMETERS;

.................................................. .............>
if you have some solution about tha plz mail me the solution.....

wait for reply---------------------->

al**********@gmail.com
al***********@yahoo.co.in

Apr 18 '07 #5
alok wrote:
i having problem in oracle 9i dataBase------
i want to convert my oracle data to sql 2000.....but i cant convert
the hindi data from oracle to sql 2000...
means......
i having table in oracle9i...
CREATE TABLE SC_CODE (
GRANT_NO VARCHAR2 (3),
H_CODE VARCHAR2 (13),
FIN_YEAR VARCHAR2 (8),
NAME1_HIN NVARCHAR2 (130),
NAME2_HIN NVARCHAR2 (130),
NAME3_HIN NVARCHAR2 (130),
NAME4_HIN NVARCHAR2 (130),
NAME5_HIN NVARCHAR2 (130),
PRIMARY KEY ( GRANT_NO, H_CODE, FIN_YEAR ))
an having data like----------------------->
04 4059600510101 ¿¿¿¿¿¿ ¿¿¿¿¿¿¿ ¿¿
¿¿¿¿¿¿¿(50¿¿¿¿¿0¿¿0¿0)
1
0
04 4059600510102 ¿¿¿¿¿¿¿¿¿ ¿¿¿¿¿ ¿¿¿¿ ¿¿ ¿¿¿¿¿
¿¿¿¿¿¿¿ ¿¿
¿¿¿¿¿¿
0
0
04 4059600510300 TEHSILON KE
AVASIYE
66667
0
0
5965
06 2029000010400 ¿¿¿¿¿¿ ¿¿¿¿¿¿ ¿¿¿¿¿¿¿¿ (¿¿¿0 ¿¿0
07 ¿¿
¿¿¿¿¿¿¿¿¿¿¿¿)
0
2390
these symbol show ¿¿¿¿¿¿ ¿¿¿¿¿¿¿ ¿¿----->Data in oracle in Hindi.
my task is to covert the whole ¿¿¿¿¿¿ ¿¿¿¿¿¿¿ ¿¿ into hindi as it.
after convertion i saw it never changed it into hindi...it look like
same as in oracle side

i having no problem if i used my front end to insert data into
oracledata base....i having both option hindi and english...
bt when i go throudh my database i never seen the my data in hindi it
look like ¿¿¿¿¿¿ ¿¿¿¿¿¿¿ ¿¿.

what i did for it......(but never suceed...)

The database character set: use AL32UTF8. You can theoretically use
IN8ISCII, which would give you space savings, but as both Java and
Windows support Hindi (actually: the Devanagari script) through
Unicode, you should use Unicode. This way your database will be
prepared for other languages, including other Indian and South Asian
languages.

1.Have 0racle 9i on windows 2000 enterpiseEdition and client on same

2. regedit and changed NLS_LANG. Change the value to
AMERICAN_AMERICA.UTF8 . For 9idatabse as well as devloper suite.

3. Internet explorer changed the following font Lucida Sans Unicode

4. SELECT * from NLS_DATABASE_PARAMETERS;

.................................................. ............>
if you have some solution about tha plz mail me the solution.....

wait for reply---------------------->

al**********@gmail.com
al***********@yahoo.co.in
you obviously meant to create a new thread not post to an existing one of a totally unrelated matter !!!
Apr 18 '07 #6
Pete Kane wrote:
Hi All, anyone know of a way to programatically get the WAN ip address
of either a NIC or router ?
This should work:

public static string MyIp()
{
WebClient wc = new WebClient();
StreamReader sr = new
StreamReader(wc.OpenRead("http://www.myip.dk/"));
string html = sr.ReadToEnd();
return Regex.Matches(html, @"(?:<title>Your IP:
)(\d+\.\d+\.\d+\.\d+)(?:</title>)")[0].Groups[1].Value;
}

Arne
May 6 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: John J. Hughes II | last post by:
My code starts a TCP/IP socket listener and waits for incoming connections. This works fine on my system and my test system but I have a customer who say it does not work on their system. As far...
2
by: cyshao | last post by:
How to reset Router by programing? For some resean, we need usually reset our Router. Now, we have to Reset Router manually(shot down and reopen). Are there any method to control and reset...
5
by: krollenhagen | last post by:
First off, let me say I am new to vb. I may have done a bad thing and also posted this in vb.general, but I have both vb6 and vb.net and don't know which one I am going to continue to use. I am...
0
by: John | last post by:
Today something weird happened: I bought myself a new wireless router for home, got it set up, and everything was great. Browsing, email, even Shareaza p2p. Until I tried to use the ASP.NET 2...
0
by: mario.lat_ | last post by:
Hallo to all, I have write a little script for connecting to cisco router BUT I have a problem: I have to send to router all the commands and then I have to read the output. If I send a command1...
5
by: =?Utf-8?B?SmltbWVy?= | last post by:
Hello, I've been trying to create a WCF SOAP Router Service that can forward not just the message body but also any security headers set by the originator of the message. The destination service...
1
by: izecul | last post by:
Hi, I'm a newbie here, and what I know about networking you can probably copy on a matchbook :) That said, here's my problem: I've got two wireless routers - D-Link DI-524 and Airlink AR325W....
2
by: canucks13 | last post by:
Good day. I work form home, so our tech guy set up a VPN using Cisco WRT31ON router to connect Nortel i2004 phone to the office system. The Nortel tech did the initial set up and the phone works...
3
by: apg018 | last post by:
Hi - I just bought an Asus laptop with wireless capabilities. I have a desktop that I've used for years that is hooked up to Cox cable for high speed internet through a Motorola SG5120 cable modem....
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.