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 /allUse 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.


Set a static address or return to DHCP
The addresses below are examples. Substitute values appropriate to your network.
| Task | Command |
|---|---|
| Set a static address and gateway | netsh interface ipv4 set address name="Ethernet" source=static address=192.168.2.20/24 gateway=192.168.2.1 |
| Set a DNS server manually | netsh interface ipv4 set dnsservers name="Ethernet" source=static address=192.168.2.1 |
| Obtain the address automatically | netsh interface ipv4 set address name="Ethernet" source=dhcp |
| Obtain DNS servers automatically | netsh interface ipv4 set dnsservers name="Ethernet" source=dhcp |




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.

See the Microsoft Netsh interface reference for command details, or configure TCP/IP through Windows settings if you prefer a graphical interface.
Reader Comments 0
Sign in with email or Google to join the discussion.