URGENT: Unigue Host IP Address.

  • Thread starter Thread starter Sami
  • Start date Start date
S

Sami

Hello,
I would like to get the host IP Address for my local machine.
By using gethostname and gethostbyname I get a list of IP Addresses
(depending on how many ethernetadaptors I have on my machine).
How can I determine which IP Address is the correct one that I use mostly on
my machine.

I need just one IP address. Which is the correct one from the list of
addresses that I get back?
 
try trimming out the non routable ones ...
127.*
192.168.*
10.*
and see what's left.
 
Hello,

I don't know of a programmatic way to determine the host ip address on a multihomed system, but consider the following:
- The host ip address will be determined by which NIC adapter is bound first.
a- Open the 'Network and dialup connections folder" from control panel
b- click on the advanced menu option and select advanced settings
c- click the Adapters and Bindings tab and see which NIC adapter is at the top of the bindings from the
'Connections' window. This will be the NIC from where the host IP address will come from.

Also, check the following KB article for more information:
Default Gateway Configuration for Multihomed Computers WGID:159
ID: 157025
http://support.microsoft.com/?id=157025

Again, for a programmatic you need to post this question under the windows\developer newsgroups

--------------------
From: "Sami" <[email protected]>
Subject: URGENT: Unigue Host IP Address.
Date: Thu, 29 Apr 2004 13:29:48 +0200

Hello,
I would like to get the host IP Address for my local machine.
By using gethostname and gethostbyname I get a list of IP Addresses
(depending on how many ethernetadaptors I have on my machine).
How can I determine which IP Address is the correct one that I use mostly on
my machine.

I need just one IP address. Which is the correct one from the list of
addresses that I get back?

--
Regards,
Sami

[Remove Numbers from e-mail address to use it]

--
Sergio Moreno
Microsoft Windows Networking

This posting is provided "AS IS" with no warranties, and confers no rights. Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm

Note: For the benefit of the community-at-large, all responses to this message are best directed to the newsgroup/thread from which they originated.
 
"Sami" said:
I would like to get the host IP Address for my local machine.
By using gethostname and gethostbyname I get a list of IP Addresses
(depending on how many ethernetadaptors I have on my machine).
How can I determine which IP Address is the correct one that I use mostly on
my machine.

By finding out what that phrase "the correct one that I use mostly on my
machine" means. What are you going to do with the IP address that you get
back? Are you going to quote it to someone? It's possible that _none_ of
those addresses will be the right one!
I need just one IP address. Which is the correct one from the list of
addresses that I get back?

They all are. Your question is meaningless without additional information.

Alun.
~~~~

[Please don't email posters, if a Usenet response is appropriate.]
 
Back
Top