top of page
book of spells.webp

Start your journey towards mastering the CLI with our FREE Command Line Book of Spells.

By entering your email address you agree to receive emails from Command Line Wizardry. We'll respect your privacy and you can unsubscribe at any time.

Writer's picturePaul Troncone

The Ipconfig Command

The ipconfig command is used in Windows to display information about a computer's network interfaces.


Basic Use


To execute the ipconfig command open the Windows Command Prompt (cmd) and type ipconfig. The command will display information about each of the network interfaces (NICs) on the computer. Here is the output for a single network interface:


C:\>ipconfig

Windows IP Configuration

Wireless LAN adapter Wi-Fi:

   Connection-specific DNS Suffix  . : xyz.st.provider.net.
   IPv6 Address. . . . . . . . . . . : 2601:0:4501:0:f064:0:d977:505f
   Temporary IPv6 Address. . . . . . : 2601:0:4501:0:648b:0:1531:fae6
   Temporary IPv6 Address. . . . . . : 2601:0:4501:0:8916:0:f988:98d
   Link-local IPv6 Address . . . . . : fe80::f064:4a1a:0:0f%5
   IPv4 Address. . . . . . . . . . . : 192.168.0.11
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Default Gateway . . . . . . . . . : fe80::0:7eff:0:0%5
                                       192.168.0.1

The default output includes information on the interface's IP addresses, subnet mask, and default gateway (router). To obtain additional information such as DHCP and DNS settings use the /all option. It will also display information about the physical interface such as the MAC address and device description:


C:\>ipconfig /all

Windows IP Configuration

Wireless LAN adapter Wi-Fi:

   Connection-specific DNS Suffix  . : xys.st.provider.net.
   Description . . . . . . . . . . . : Intel(R) Dual Band
   Physical Address. . . . . . . . . : 01-02-03-04-05-06
   DHCP Enabled. . . . . . . . . . . : Yes
   Autoconfiguration Enabled . . . . : Yes
   IPv6 Address. . . . . . . . . . . : 2601:0:0:9630:f064:0:0:505f
   Temporary IPv6 Address. . . . . . : 2601:0:0:9630:0:f520:0:fae6
   Temporary IPv6 Address. . . . . . : 2601:0:0:9630:0:ab2b:0:98d
   Link-local IPv6 Address . . . . . : fe80::0:4a1a:0:505f%5
   IPv4 Address. . . . . . . . . . . : 192.168.0.11(Preferred)
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Lease Obtained. . . . . . . . . . : Friday, April 16, 2021 10:14 AM
   Lease Expires . . . . . . . . . . : Sunday, April 18, 2021 1:16 PM
   Default Gateway . . . . . . . . . : 0::0:0:0:0%5
                                       192.168.0.1
   DHCP Server . . . . . . . . . . . : 192.168.0.1
   DHCPv6 IAID . . . . . . . . . . . : 75800000
   DHCPv6 Client DUID. . . . . . . . : 01-00-00-61-00-00-00-00-00-00-13
   DNS Servers . . . . . . . . . . . : 0:0:0::1
                                       0:0:0::2
                                       8.8.8.8
                                       1.1.1.1
   NetBIOS over Tcpip. . . . . . . . : Enabled

Common Ipconfig Options


The following table lists common options for the ipconfig command.


Using Ipconfig to Reset Your DHCP IP Address


If your network adapter is configured to obtain an IP address automatically using DHCP you can reset it by using the /release and /renew parameters for ipconfig.


C:\>ipconfig /release

C:\>ipconfig /renew

This will reset the IP address on all network interfaces on the computer. To reset the IP address of just one interface, provide its name as an argument. If the interface name contains spaces be sure to enclose it in quotes.


C:\>ipconfig /release "Wi-Fi"

One thing to note is that the interface name displayed by ipconfig is not necessarily the actual name of the interface. For example, if you try to use the name "Wireless LAN adapter Wi-Fi" to release the interface from the example above you will receive the following error:


C:>ipconfig /release "Wireless LAN adapter Wi-Fi"

Windows IP Configuration

The operation failed as no adapter is in the state permissible for
this operation.

To obtain a true list of the network interface names use the wmic command:


C:\>wmic nic get NetConnectionID
NetConnectionID

Ethernet
Wi-Fi
Bluetooth Network Connection

Note that the interface is actually called "Wi-Fi". That is the name you will need to use in ipconfig to release or renew the DHCP address for the interface.


Using Ipconfig to Display Your DNS Cache


In order to increase speed and efficiency computers often cache DNS information, at least for a short time period. You can use the /displaydns option for ipconfig to display your current DNS cache.


C:\>ipconfig /displaydns

Windows IP Configuration

forcesafesearch.google.com
    ----------------------------------------
    Record Name . . . . . : forcesafesearch.google.com
    Record Type . . . . . : 1
    Time To Live  . . . . : 56066
    Data Length . . . . . : 4
    Section . . . . . . . : Answer
    A (Host) Record . . . : 216.239.38.120

To delete all of your DNS cache entries (flush) you can use ipconfig's /flushdns option.


C:>ipconfig /flushdns

Windows IP Configuration

Successfully flushed the DNS Resolver Cache.

Setting a Network Interface's IP Address


While ipconfig lets you display information, it cannot be used to change an interface's IP address. For that you can use the netsh command, however, the command is being deprecated by Microsoft, so you are better of using PowerShell.


First open PowerShell and type Get-NetIPConfiguration. Below is an example of the output for a single interface. Note the interfaces InterfaceIndex.


PS C:\> get-netipconfiguration

InterfaceAlias       : Wi-Fi
InterfaceIndex       : 5
InterfaceDescription : Intel(R) Dual Band 
NetProfile.Name      : wifissid 3
IPv6Address          : 2601:0:0:9630:0:4a1a:0:505f
IPv4Address          : 192.168.0.11
IPv6DefaultGateway   : fe80::0:0:0:d58e
IPv4DefaultGateway   : 192.168.0.1
DNSServer            : 8.8.8.8
                       1.1.1.1

Next set the IP address, subnet mask, and default gateway for the interface using the New-NetIPAddress cmdlet:


PS C:\>New-NetIPAddress -InterfaceIndex 5 -IPAddress 192.168.0.100 -PrefixLength 24 -DefaultGateway 192.168.0.1

Here is a breakdown of the parameters used:


-InterfaceIndex: The index of the interface you want to update

-IPAddress: The IP address you want to assign to the interface

-PrefexLength: The number of bits used by the subnet mask

-DefaultGateway: The IP address of the computer's default gateway (router)


Next you can use the Set-DnsClientServerAddress cmdlet to specify the DNS servers for the interface to use:


PS C:\>Set-DNSClientServerAddress -InterfaceIndex 5 -ServerAddresses ("8.8.8.8", "1.1.1.1")

Here is a breakdown of the parameters used:


-InterfaceIndex: The index of the interface you want to update

-ServerAddresses: A list of the DNS servers to assign to the interface


Links and Resources

3,556 views0 comments

Recent Posts

See All

Comments


bottom of page