Clear, practical technology insights BSOD Code Lookup · Windows Error Code Lookup · Wi-Fi Troubleshooting · PC Troubleshooting Checklist

Configure IPv4 in Windows With Netsh: Static IP, DHCP, and DNS

Identify the correct Windows network adapter, set a static IPv4 address or DNS server, and switch back to DHCP if needed.

Table of Contents

Use netsh interface ipv4 in an administrator Command Prompt to configure an adapter’s IPv4 address and DNS settings. Start by checking the adapter name and recording the current settings. Changing the active adapter can interrupt a remote connection, so make the change locally when possible.

Find the adapter and its current configuration

netsh interface show interface
netsh interface ipv4 show config
ipconfig /all

Use the exact adapter name, such as Ethernet or Wi-Fi. Get an unused address, subnet prefix, gateway, and DNS server from your network administrator or router settings before assigning a static configuration.

How to configure TCP/IP using CMD command on Windows Picture 1

How to configure TCP/IP using CMD command on Windows Picture 2

Set a static address or return to DHCP

The addresses below are examples. Substitute values appropriate to your network.

TaskCommand
Set a static address and gatewaynetsh interface ipv4 set address name="Ethernet" source=static address=192.168.2.20/24 gateway=192.168.2.1
Set a DNS server manuallynetsh interface ipv4 set dnsservers name="Ethernet" source=static address=192.168.2.1
Obtain the address automaticallynetsh interface ipv4 set address name="Ethernet" source=dhcp
Obtain DNS servers automaticallynetsh interface ipv4 set dnsservers name="Ethernet" source=dhcp

How to configure TCP/IP using CMD command on Windows Picture 3

How to configure TCP/IP using CMD command on Windows Picture 4

How to configure TCP/IP using CMD command on Windows Picture 5

How to configure TCP/IP using CMD command on Windows Picture 6

The screenshots show an older interactive Netsh session. The table uses complete commands you can run directly from the Command Prompt.

Verify before closing the terminal

Run ipconfig /all again and check the intended adapter’s IPv4 address, gateway, DNS servers, and DHCP status. Test a known local or public hostname. If the change breaks connectivity, restore your previous settings. Use both DHCP commands only if the adapter previously obtained both address and DNS automatically.

How to configure TCP/IP using CMD command on Windows Picture 7

See the Microsoft Netsh interface reference for command details, or configure TCP/IP through Windows settings if you prefer a graphical interface.

Discussion

Reader Comments 0

Sign in with email or Google to join the discussion.