How to determine if an IP address is DHCP assigned?

G

Guest

Guest
Archived from groups: microsoft.public.windowsnt.protocol.tcpip,microsoft.public.win32.programmer.networks (More info?)

(Apologies for the cross-posting as I am still new to the Microsoft groups.)

The situation is that, an interface (say an Ethernet LAN connection) may
have multiple IP addresses. When DHCP is enabled on the interface, what
is the best way to determine if a particular IP address is DHCP assigned?

What I have done so far is traversing the IP address table returned by
the GetIpAddrTable() function, then check the (dwType) field in each
MIB_IPADDRROW entry for the MIB_IPADDR_DYNAMIC bit. The document for
MIB_IPADDRROW on MSDN simply says that the bit means "Dynamic IP
address" and that's all the information I have been able to find on the Net.

However, that bit of information does not seem to be consistant across
different Windows operating systems. On 2000, the bit is unset for a
DHCP assigned IP address, while on XP Pro SP2 it is set. However, on XP
Pro SP2, an IP address programmatically setup on the host using the
AddIPAddress() function also has that bit set.

Any insights on this bit of information? Any ideas, thoughts, or
pointers would be greatly appreciated.

Have a good day!
--
Wei Wang
 
G

Guest

Guest
Archived from groups: microsoft.public.windowsnt.protocol.tcpip,microsoft.public.win32.programmer.networks (More info?)

Wei Wang wrote:
> (Apologies for the cross-posting as I am still new to the Microsoft
> groups.)
> The situation is that, an interface (say an Ethernet LAN connection)
> may have multiple IP addresses. When DHCP is enabled on the
> interface, what is the best way to determine if a particular IP address is
> DHCP
> assigned?
> What I have done so far is traversing the IP address table returned by
> the GetIpAddrTable() function, then check the (dwType) field in each
> MIB_IPADDRROW entry for the MIB_IPADDR_DYNAMIC bit.

Did you try GetAdaptersAddresses? It is not available on Win2k though.


--
Eugene
http://www.gershnik.com
 
G

Guest

Guest
Archived from groups: microsoft.public.windowsnt.protocol.tcpip,microsoft.public.win32.programmer.networks (More info?)

Eugene Gershnik wrote:
> Wei Wang wrote:
>
>>(Apologies for the cross-posting as I am still new to the Microsoft
>>groups.)
>>The situation is that, an interface (say an Ethernet LAN connection)
>>may have multiple IP addresses. When DHCP is enabled on the
>>interface, what is the best way to determine if a particular IP address is
>>DHCP
>>assigned?
>>What I have done so far is traversing the IP address table returned by
>>the GetIpAddrTable() function, then check the (dwType) field in each
>>MIB_IPADDRROW entry for the MIB_IPADDR_DYNAMIC bit.
>
>
> Did you try GetAdaptersAddresses? It is not available on Win2k though.

Thanks a lot for responding. I did look at it. But it didn't seem to
provide the information I need.

Have I missed anything in what that function does? I looked a bit deeper
just now. The IP_ADAPTER_UNICAST_ADDRESS described on is page seems
promising:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/iphlp/iphlp/ip_adapter_unicast_address.asp

I will try to write some code to see what I get back for different kinds
of addresses. However, from reading the information on the page above,
there is no direct indication either. The only thing I could do seems to
check (ValidLifetime) and (LeaseLifetime). However, what should I expect
to see in there for DHCP address and otherwise?

Again, thanks for responding.
--
Wei Wang
 
G

Guest

Guest
Archived from groups: microsoft.public.windowsnt.protocol.tcpip,microsoft.public.win32.programmer.networks (More info?)

You can read it from registry or check it with WMI
Arkady

"Wei Wang" <ww9rivers@gmail.com> wrote in message
news:4317CF70.7020800@gmail.com...
> Eugene Gershnik wrote:
>> Wei Wang wrote:
>>
>>>(Apologies for the cross-posting as I am still new to the Microsoft
>>>groups.)
>>>The situation is that, an interface (say an Ethernet LAN connection)
>>>may have multiple IP addresses. When DHCP is enabled on the
>>>interface, what is the best way to determine if a particular IP address
>>>is DHCP
>>>assigned?
>>>What I have done so far is traversing the IP address table returned by
>>>the GetIpAddrTable() function, then check the (dwType) field in each
>>>MIB_IPADDRROW entry for the MIB_IPADDR_DYNAMIC bit.
>>
>>
>> Did you try GetAdaptersAddresses? It is not available on Win2k though.
>
> Thanks a lot for responding. I did look at it. But it didn't seem to
> provide the information I need.
>
> Have I missed anything in what that function does? I looked a bit deeper
> just now. The IP_ADAPTER_UNICAST_ADDRESS described on is page seems
> promising:
>
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/iphlp/iphlp/ip_adapter_unicast_address.asp
>
> I will try to write some code to see what I get back for different kinds
> of addresses. However, from reading the information on the page above,
> there is no direct indication either. The only thing I could do seems to
> check (ValidLifetime) and (LeaseLifetime). However, what should I expect
> to see in there for DHCP address and otherwise?
>
> Again, thanks for responding.
> --
> Wei Wang
 
G

Guest

Guest
Archived from groups: microsoft.public.windowsnt.protocol.tcpip,microsoft.public.win32.programmer.networks (More info?)

Arkady Frenkel wrote:
> You can read it from registry or check it with WMI

Mind sharing some details?

Thanks for responding.
--
Wei Wang
 
G

Guest

Guest
Archived from groups: microsoft.public.windowsnt.protocol.tcpip,microsoft.public.win32.programmer.networks (More info?)

EnableDHCP key for my adapter guid
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\{2CA46387-EE75-49C2-A468-9CA7CE69DC65}\Parameters\Tcpip
Arkady

"Wei Wang" <ww9rivers@gmail.com> wrote in message
news:43204898.3070409@gmail.com...
> Arkady Frenkel wrote:
>> You can read it from registry or check it with WMI
>
> Mind sharing some details?
>
> Thanks for responding.
> --
> Wei Wang
 
G

Guest

Guest
Archived from groups: microsoft.public.windowsnt.protocol.tcpip,microsoft.public.win32.programmer.networks (More info?)

Thanks for responding.

Arkady Frenkel wrote:
> EnableDHCP key for my adapter guid
> HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\{2CA46387-EE75-49C2-A468-9CA7CE69DC65}\Parameters\Tcpip

I checked. But those registry entries do not have information on
multiple IP addresses on a single interface.

By the way, the term "IP aliasing" means to add more than one IP address
to an interface:

http://www.defcon1.org/html/Networking_Articles/natdhowto-whisky/aps-filter/Sharity-Light/body_ip-aliasing.html

Regards,
--
Wei Wang
 
G

Guest

Guest
Archived from groups: microsoft.public.windowsnt.protocol.tcpip,microsoft.public.win32.programmer.networks (More info?)

But those by definition not have DHCP ( as Eugene wrote ) , you set IP , not
DHCP so DHCP know nothing about them and can't know
Arkady

"Wei Wang" <ww9rivers@gmail.com> wrote in message
news:4320580F.8090308@gmail.com...
> Thanks for responding.
>
> Arkady Frenkel wrote:
>> EnableDHCP key for my adapter guid
>> HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\{2CA46387-EE75-49C2-A468-9CA7CE69DC65}\Parameters\Tcpip
>
> I checked. But those registry entries do not have information on multiple
> IP addresses on a single interface.
>
> By the way, the term "IP aliasing" means to add more than one IP address
> to an interface:
>
> http://www.defcon1.org/html/Networking_Articles/natdhowto-whisky/aps-filter/Sharity-Light/body_ip-aliasing.html
>
> Regards,
> --
> Wei Wang