Set A Static IP Address On Windows 7 From The Command Line

Windows has traditionally been all about the GUI. However, in Windows 7 it’s possible to set a static IP address from the command line. Here’s how to do it.

Let’s say you want to give your Windows 7 system an IP address of 192.168.1.2, a subnet mask of 255.255.255.0, a default gateway of 192.168.1.254, and a DNS server address of 192.168.1.200. Go to an elevated command prompt (right-click on the command prompt icon and select Run As Administrator) and type these two commands:

netsh interface ipv4 set address “local area connection” static 192.168.1.2 255.255.255.0 192.168.1.254

netsh interface ipv set dnsservers “local area connection” static 192.168.1.200

These commands will configure the Local Area Connection with a static IP, netmask, gateway, and DNS server.

If you want to switch back to receiving your networking settings from a DHCP server, use these commands:

netsh interface ipv4 set address name=”local area connection” source=dhcp

netsh interface ipv4 set dnsservers name=”local area connection” source=dhcp

This will set the Local Area Connection back to using DHCP.

-JM

This entry was posted in Windows. Bookmark the permalink.

6 Responses to Set A Static IP Address On Windows 7 From The Command Line

  1. sam liyanage says:

    can u pls make this into a batch file and either add a download link or show it so we can copy and paste is

  2. Ben Gates says:

    Hi Jonathan. Thank you very much. This article was exactly what I needed. Very simple and most importantly works perfectly.

    To Sam Liyanage, just copy the command right off this webpage at paste it into a batch file of your choice, e.g. “static_ip.bat” (right-click desktop and select new text document, then rename text document to “static_ip.bat”).

    Thanks again Jonathan.

  3. X3STeNLiTE says:

    netsh interface ipv[4] set dnsservers “local area connection” static 192.168.1.200

    missing 4 ?

  4. read more says:

    naturally like your web site but you have to test the spelling on several of your posts. Several of them are rife with spelling issues and I to find it very bothersome to inform the truth nevertheless I will certainly come back again.

  5. ranjeet says:

    how to sole “GRUB> error massage show ?

  6. naveen says:

    The filename, directory name, or volume label syntax is incorrect.
    this is the error i got when i run your command in run..??
    my ip is changing when i restarted my pc..
    in need to make is static permanent how ??
    please help me please
    Thank you in advance