Learn about my 2012 Core Survival Guide here.
Determining if an IPv4 address is DHCP or Static
When troubleshooting IPv4 configuration you will need to know if the IPv4 address you are looking at is DHCP or Static. If you notice that the configuration is wrong and it is a DHCP assigned address then you will need to correct the DHCP Server’s scope. But if it is a Static address then you need to correct the misconfiguration here on the server itself.
Viewing IP interface status
Just like with the IPv4 basic configuration you will need to know the “InterfaceIndex” of the NIC you wish to work with and weather it is DHCP or Static. PowerShell is going to be the tool of choice to determine this. I use the following PowerShell command to determine the “InterfaceIndex”, and if DHCP is enabled.
Get-NetIPInterface -AddressFamily IPv4 | format-table interfaceindex,interfacealias, dhcp, -autosize
When the DHCP column below shows enable for a network interface than the network interface is getting its configuration information from an DHCP server. If the DHCP column below shows disable for a network interface than that interface is statically configured.
Remember to check if the IPv4 address starts with 169.254.y.z if DHCP is enabled. This indicates that the client is not receiving a lease from the DHCP server. This can be cause by no DHCP server, misconfigured DHCP Server, or a misconfigured router that is not forwarding the DHCP request.
Modifying IP interface status
If you wish to switch a network interface from static to DHCP enabled you can use the PowewShell Set-NetIPinterface cmdlet.
Set-NetIPInterface -interfaceindex 12 -DHCP enable
This cmdlet reconfigured the interface to be DHCP. In the example below I configured interfaceindex 12 to go from static to DHCP enabled.
If you wish to reset the static IPv4 address I found this process always work:
If you try and reset the static IPv4 address without doing steps one and two above you will receive an error like below.
I hope you found this useful. Please leave me a comment
in "Viewing IP interface status" command there is an extra comma before -autosize