Set a static IP address with netsh from CMD

Configure a fixed IPv4 address, subnet mask and default gateway on any adapter in one line — essential for headless servers and remote workstations.

WindowsnetworksystemTerminalMedium risk
Run `netsh interface ip set address name="Ethernet" static <ip> <mask> <gateway>` to set a static IP, and swap `static ...` for `dhcp` to revert.

01Command

Command
$ netsh interface ip set address name="Ethernet" static 192.168.1.50 255.255.255.0 192.168.1.1

02What it does

The name value must match the adapter's connection name exactly (spaces included); list them with `netsh interface show interface` or `Get-NetAdapter`. The command above sets address, mask, and gateway; DNS is a separate call: `netsh interface ip set dns name="Ethernet" static 1.1.1.1`. Verify with `ipconfig /all` or `netsh interface ip show config`, and test the gateway with `ping 192.168.1.1`. Adding a second IP to the same adapter without removing the first uses the `add address` variant instead of `set address`, which would replace the primary IP.

03Risk

RiskMedium risk
RequirementsRun as administrator; the interface name must match exactly (check with `netsh interface show interface`).
!Warning: Setting a wrong gateway or an IP already in use on a remote machine will cut your connection immediately — prefer setting a second address or doing this over a console/iLO session.

04Undo

Undo
$ netsh interface ip set address name="Ethernet" dhcp

05Sources

  • Netsh contexts and commands | Microsoft Learn
    Microsoft · vendor-doc · 2026-09-17
    Evidence: Microsoft documents the netsh interface ipv4 context with set address commands accepting static address, mask and gateway parameters or dhcp.
  • Netsh - Network Shell - Windows CMD
    SS64 · technical · 2026-09-17
    Evidence: SS64 shows 'netsh interface ip set address name=... static addr mask gateway' syntax and the dhcp variant for reverting.

Last verified: 2026-09-17 · Category: Network

06Related solutions