How-To Geek

Stupid Geek Tricks: Change Your IP Address From the Command Prompt


Most everybody can figure out how to change their IP address using Control Panel, but did you know you can set your network card’s IP address using a simple command from the command prompt?

Note: The following commands require you to have an administrative command prompt open by right-clicking on the icon and choosing Run as Administrator.

Changing Your IP Address

Changing your IP information requires two commands, one for your IP address, subnet mask and default gateway and another for  your DNS settings. In order to change your IP address we use the netsh command, the exact command you want to use is the following:

netsh interface ip set address name=”Local Area Connection” static

This assumes the following:

  • The name of the interface you want to change the IP address  for is Local Area Network
  • You want to statically assign an IP address of
  • You want to set a subnet mask of
  • You want to set a default gateway of

Armed with this information you should obviously switch the settings out for some that are suited to your network. You might, however, be wondering how you can go from using an already set static IP address to getting an address from DHCP. In this case the command you are looking for is:

netsh interface ip set address name=”Local Area Connection” source=dhcp

Changing Your DNS Settings

As far as DNS goes you only have two settings to set, a primary DNS server as well as a secondary one. The command to set them is almost identical, to set your primary DNS server you will want to use:

netsh interface ip set dns name=”Local Area Connection” static

This again assumes a few things:

  • The name of the interface you want to change the primary DNS setting for is Local Area Network
  • The IP address of the DNS Server is

To change the IP address of the secondary DNS server you will need to specify the index parameter:

netsh interface ip add dns name=”Local Area Connection” index=2

The above command would set your network adapter named Local Area Connection to use a secondary DNS server address of (which is the Google public DNS servers, incase you didn’t know). The last thing you might want to do it set your DNS settings to be assigned dynamically, which can be done through the following command.

netsh interface ip set dnsservers name=”Local Area Connection” source=dhcp

That’s all the command line magic you are going to need to impress some of your friends, so what are you waiting for?

Taylor Gibb is a Microsoft MVP and all round geek, he loves everything from Windows 8 to Windows Server 2012 and even C# and PowerShell. You can also follow him on Google+

  • Published 01/23/12

Comments (32)

  1. Jack Davis

    Very interesting, but why would you want to change your IP address?
    Seriously, why? Is the motivation just to impress your friends?

  2. Bruno

    And for IPv6 ?

  3. Jeff

    I had to change on in the office because all of a sudden, he couldn’t get on the network and the dynamic IP that the Router was giving him was in conflict with another address. So I gave him a a static address and all is well again. It was pretty easy to do through the network icon in the control panel.

  4. Taylor Gibb

    I’m a geek, I’d rather change it through the command line than through the GUI, also on Server 2008 Core there is no GUI, this is the only way to change ur IP settings

  5. Mick

    As an OEM developer, most of the equipment with which I develop and support have different IP schemas. Furthermore, I have two VMs configured for different control systems that I support, AB, Siemens, etc. That being said, I have written batch files based on this same code….one if I have a DHCP server available, and another for a static IP based on the customer’s network infrastructure. I also find it handy when I need to do updates from the VM.

  6. Search

    Does this make your IP address untraceable? If you changed your IPs address number, would this prevent it from working correctly? Can you type in any number?

    How can you “easily” change your name on the computer system before you sell it?

    Thanks for your time…

  7. Tek9

    Remove the grab from your DHCP admin link, then either reboot the offending computer or figure out why both computers are reporting the same MAC address for the ethernet. Typically the router assigns IP based on that identifying MAC address and won’t assign the same address to two different ones. Better to resolve the issue in DHCP, rather than having one rogue terminal out there with a static that you have to keep track of.

    No. Possibly. Yes. Google.

  8. Lumi

    I would assume that one of the simple applications of this could be handy when watching movies online on sites that have a time limit. Since they use your IP-address to restrict connection then this might be a fail safe to complete the exciting movie :)

    *PS. I think it would be more impressive if you pull this off while watching a movie with friends :\

  9. John

    At my company we rely heavily on RDP both within the network and also connecting from outside. Having a static IP address ensures that incoming connections get routed to the correct PC. All PCs use port 3389 as the default RDP port so instead of changing it we just route to the IP address instead. For example if someone connects to from outside the company, our main network router is set to transfer port 1020 to 192.168.1.XXX:3389

  10. paul

    what is this trick “stupid”? And if it is really stupid (possibly might be, I am not a computer expert) why would one then want to post it?

  11. NumberSix6

    Does this work for like that only uses USA IPs to show playlists? If so, this is great! like UK, CH, GR, MX aro not allowed to see some content from USA, (dunno why)

  12. Svend

    @John – I hope you are using DHCP reservations. It would make it a lot easier to track the addresses that you have used. Also did you know Small Business Server has a nice gateway to allow RDP access to workstations without all the port translation stuff?

    @NumberSix6 – No – An IP address assigned by your ISP is needed for routing traffice back to you. That is what they are looking at. The reason it is restricted is because the content they provide is only licensed to them for distribution in a specific geographic area. Outside of those areas it is licensed to someone else who has done a different deal with the production house.

    On the whole I cannot see a lot of uses for this trick but it is good to know it can be done. It may come in handy if you need to incorporate it in a batch file.

  13. JimR

    This isn’t something for the average home user. I work in data center migrations, where we might have to change the ip addresses on anywhere from 2 to 50 computers in order to move them to a new data center. By putting the server name and IP’s in a file, I can eliminate the possibility of manual data entry errors by using the FOR command and the netsh program.

  14. Marc

    Thanks great tip!

  15. Charley

    This is a great tip, so, let’s say, I work at an office with an IP range of,xxx and my home network in , now I can create a Batch file called home and run that on return home and still have all the Port allocaqtion works without unPnP ,, Great Tip .. !

  16. rino19ny

    it’s a “mouthful” to type those commands. a lot easier and faster to just use the GUI.

  17. Nick

    Where did you get that wallpaper behind the command prompt?!?!?

  18. Taylor Gibb

    @Nick its actually a pack of wallpapers with different color variations optimized for iPad2, iPhone and a whole lot of other devices including desktop, sadly all i can remember is that it was called “Chip Pack” and i found it on deviantArt.. i might have a link on my site,Taylor Gibb, however i am not 100% sure i ended up posting it :) hope that helps

  19. Stuart

    I really hope this comment makes it.

    What this would be awesome for:

    If you have to set multiple static addresses in different places!! You could create a batch file per setting and woosh! I remember when I was messing with a few things at home and at work and they all needed different static addresses, a few projects were APs that for some reason I had their admin interface not no the network they were passing traffic for so I needed to connect then set a static to admin the device. This would have been perfect!

    However on a day to day bases or something I will remember I probably will not. I knew there might have been the possibility but I never really got into the net shell

  20. NumberSix

    Thanks a lot Svend, you clear my mind about this.

  21. The Unspoken

    Because I respect beginner questions as much as I do the super geeks here:
    Does this make your IP address untraceable? If you changed your IPs address number, would this prevent it from working correctly? Can you type in any number?

    How can you “easily” change your name on the computer system before you sell it?

    Thanks for your time…”

    No it does not make your IP untraceable. You need a program to spoof your IP.

    Your router has a preset range that the IP address needs to be. Typically it is going to be in the 192.168.XXX.XXX range. This is going to be the easiest way for a beginner to grasp what their IP should be.

    You can change the name on your computer rather easily, the OS will determine the steps though…

    The Unspoken

  22. K@RiS

    Can’t believe i read each comment!!!…. Thanks all the same!!

  23. aznjoejustin

    what is the main purpose of change ip address ,,can i trial everything with unlimited ??

  24. Anton

    If the router DHCP setting already preset the IP address to your computer you cant change it even if u release or do the commands above

  25. Anton

    You cannot spoof the websites because these ip addresses are local, meaning in your own network only your telco is the one that provides you with the pesudo-unique ip address via their NAT protocol

  26. Jimmy Strang

    For Nick who wanted the wallpaper here is the url:×16002.jpg/

  27. Android

    Usage: add dnsservers [name=] [address=] [[index=]] [[validate=lyes:no]


    Tag Value
    name – The name or index of the interface where DNS servers are added.
    address – The IP address for the DNS server you are adding.
    index – Specifies the index for the specified DNS server address.
    validate – Specifies whether validation of the DNS server
    setting will be performed. The value is yes by default.

    Remarks: Adds a new DNS server IP address to the statically- configured l list. If an index is specified, the DNS server will be placed in that posi8tion in the list, with other servers being moved down to make room. If DNS servers were previsionsly obtained through DHCP, the new address will replace the old list. If Validate switch is yes, then the newly added DNS server is validated.


    add dnsservers “Local Area Connection”
    add dnsservers “Local Area Connection” index=2

  28. Ragg

    Hello guys,
    Iv got a laptop with Win 7.
    Im running this tip according to this article. I run commanprompt in administrative mode. I paste the respective command according to how they are written in the grey boxes above.

    This doesnt work, it says wrong syntax…etc

    I try to use step by step entry netsh…enter….interface…enter set enter….

    Still wont work, after some time I get wrong syntax unknown command

  29. waldo

    this is very helpful to me as i do need to changed fixed ip addresses.

    could someone guide me in setting up a convenient batch file i could put on my desktop to make the changes?

    thanks so much!


  30. Yohannes

    It brings up an error message in the beginning saying that “The syntax for this command is not valid”
    Any Ideas?

  31. Qwik

    I agree with JimR. Not for the average home user.

    I also work in an Enterprise Data Center and have to deal with several hundred Virtual Servers on a daily basis that are segregated into Production, Test/QA, Development, Private, and Management VLANS. Each has its own subnet for the forward facing NIC and Backend NIC. Putting the above commands into a spreadsheet and making bulk changes then running on the VMs is a great timesaver. If you are only updating one pc or server, it would’nt necessarily save you time but, for my situation it’s awesome. I also have a similar routine for setting persistant route statements also. Work smart, not hard.

  32. royatm

    Hi All.
    I have been the victim of a boiler room scam that is still ongoing !!! The guy has sent me three emails from his yahoo account. I have checked in the IP look up to see where it has come from and it says Dublin Ireland. is there anybody on this site that can look deeper into the email and let me know more about where they are and who he is?

More Articles You Might Like

Enter Your Email Here to Get Access for Free:

Go check your email!