HOEI

Change XP IP from Command Line

March 23rd, 2009

Here are a few tips on how to change your Network Interface card IP address setting from the command line. Why? Well, as a network security engineer there can be a number of reasons that require switching between network segments many time in a day. I might have to move my laptop off into a DMZ to verify connectivity after making Firewall changes. Most of these segments were not running a DHCP server and required that I manually set the IP, Default Gateway, subnet mask, and sometime the DNS settings.  So running a ipconfig release and renew was not going to do it.  Then I might have to switch back to a segment running DHCP.  I was often running from the command line anyway to execute ping and tracert. I also use SSH from the Windows command line to access routers, switches, and firewalls so it just made sense to switch IP settings from the commandline.  Here is how I do it:

  1. Create folder a in My Documents called “ip”
  2. Inside of that folder create as many batch files as required to meet your needs

Example Batch (.bat) file used to switch from static IP back to DHCP.

netsh interface ip set address name=”Local Area Connection” static 192.168.10.200 255.255.255.0 192.168.10.2 1
netsh interface ip set dns “Local Area Connection” static 192.168.16.102 primary

Note: this file only contains two lines (each beginning with “netsh interface”)

Each of your Ethernet adapters will be listed as “Ether adapter [some name]:” The portion between the [brackets] is what you enter between the “quotes” after name=.

Below is an example of how to set a static IP address, subnet mask, default gateway, and DNS.

netsh interface ip set address name=”Local Area Connection” static 192.168.10.200 255.255.255.0 192.168.10.2 1
netsh interface ip set dns “Local Area Connection” static 192.168.10.102 prima
ry

I create as many of these as needed and name the bat files something that makes sense to me for the job I am on. My bat files might be named;

  • DHCP.bat
  • homewireless.bat
  • siteFWinside.bat
  • siteFWoutside.bat
  • siteDMZ1.bat
  • siteDMZ2.bat

If you put your ip folder in your path then you can execute the bat files from any directory on the command line.  You can also put bat files on your desktop and create keyboard shortcuts as well. I put a copy of my DHCP.bat on my desktop and assign it a Ctrl+Alt+D keyword shortcut.

No Comments »

No comments yet.

Leave a comment

:mrgreen: :neutral: :twisted: :shock: :smile: :???: :cool: :evil: :grin: :oops: :razz: :roll: :wink: :cry: :eek: :lol: :mad: :sad:


Subscribe without commenting

RSS feed for these comments. | TrackBack URI

Feed Icon
Subscribe to our feed.

TwitterCounter for @TheOzz

What's a feed?

Enter your email address:

Delivered by FeedBurner



Blogging Blogs - BlogCatalog Blog Directory