Skip to main content
Endpoint shell

netsh interface ip set address <adapter> static <ip> <mask> [gateway]

Windows' command to give an adapter a static address, mask and default gateway in one line; 'dhcp' in place of 'static' (and the addresses) takes a DHCP lease instead. The adapter is the name ipconfig prints (Eth0), and Windows' default name 'Ethernet' means the same NIC. Like Windows, it prints nothing when it works: check with ipconfig.

Works on: PC, Server, Printer, NASMode: shell

Example

PC1> netsh interface ip set address Eth0 static 192.168.1.10 255.255.255.0 192.168.1.1
PC1> ipconfig
Watch out

The parameters may also be named: name=Eth0 source=static address=192.168.1.10 mask=255.255.255.0 gateway=192.168.1.1, and the mask may ride on the address as 192.168.1.10/24. gateway=none removes the default gateway. A network or broadcast address is refused with 'The combination of IP address and subnet mask is invalid.', and an adapter the host doesn't have with 'The filename, directory name, or volume label syntax is incorrect.' Only set address is simulated: other netsh commands say so. The Linux way works too: ip addr add 192.168.1.10/24 dev Eth0, then ip route add default via 192.168.1.1.

Run this command live

Don't just read it — type netsh interface ip set address <adapter> static <ip> <mask> [gateway] in a real network simulator in your browser and watch it take effect. No install, no account needed to start.

Open the lab

Frequently asked

What does the "netsh interface ip set address <adapter> static <ip> <mask> [gateway]" command do?

Windows' command to give an adapter a static address, mask and default gateway in one line; 'dhcp' in place of 'static' (and the addresses) takes a DHCP lease instead. The adapter is the name ipconfig prints (Eth0), and Windows' default name 'Ethernet' means the same NIC. Like Windows, it prints nothing when it works: check with ipconfig.

What's the common gotcha with "netsh interface ip set address <adapter> static <ip> <mask> [gateway]"?

The parameters may also be named: name=Eth0 source=static address=192.168.1.10 mask=255.255.255.0 gateway=192.168.1.1, and the mask may ride on the address as 192.168.1.10/24. gateway=none removes the default gateway. A network or broadcast address is refused with 'The combination of IP address and subnet mask is invalid.', and an adapter the host doesn't have with 'The filename, directory name, or volume label syntax is incorrect.' Only set address is simulated: other netsh commands say so. The Linux way works too: ip addr add 192.168.1.10/24 dev Eth0, then ip route add default via 192.168.1.1.

Example of "netsh interface ip set address <adapter> static <ip> <mask> [gateway]"

PC1> netsh interface ip set address Eth0 static 192.168.1.10 255.255.255.0 192.168.1.1 PC1> ipconfig

More Endpoint shell commands

← Back to the full command reference