Entering IP info from Command line under XP

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Good morning,

Is it possible to enter your IP address, gateway, subnets, dns, from the
command line?
My senario is this. At my desk I have a static IP address, if I move to
another building, I no longer can use the static and must go to DHCP. I would
like a quick way to configure my IP between the two.
Thanks
 
Good morning,

Is it possible to enter your IP address, gateway, subnets, dns, from the
command line?
My senario is this. At my desk I have a static IP address, if I move to
another building, I no longer can use the static and must go to DHCP. I would
like a quick way to configure my IP between the two.
Thanks

The "netsh" command does exactly what you want. To set a static IP
address:

netsh interface ip set address <connection> static <ip> <mask>
<gateway> <gateway metric>

To use DHCP:

netsh interface ip set address <connection> dhcp

For example:

netsh interface ip set address "Local Area Connection"
static 192.168.0.100 255.255.255.0 192.168.0.254 10

netsh interface ip set address "Local Area Connection" dhcp

This article has more information:

How to Use the Netsh.exe Tool and Command-Line Switches
http://support.microsoft.com/?id=242468
--
Best Wishes,
Steve Winograd, MS-MVP (Windows Networking)

Please post any reply as a follow-up message in the news group
for everyone to see. I'm sorry, but I don't answer questions
addressed directly to me in E-mail or news groups.

Microsoft Most Valuable Professional Program
http://mvp.support.microsoft.com
 
Ok here is what worked. For reference, my connection is named "Static". I put
this in a batch file called Static.bat:

cls
c:\winnt\system32\netsh.exe interface ip set address "Static" static
10.10.10.10 255.255.255.0 10.10.10.10 1
c:\winnt\system32\netsh.exe interface ip set dns "Static" static 10.10.10.10
c:\winnt\system32\netsh.exe interface ip add dns "Static" 10.10.10.10
c:\winnt\system32\netsh.exe interface ip show address "Static"
c:\winnt\system32\netsh.exe interface ip show dns "Static"

pause
exit

And while I was at it, wrote a file called dhcp.bat which releases all
settings:

cls
c:\winnt\system32\netsh.exe interface ip set address "Static" dhcp
c:\winnt\system32\netsh.exe interface ip set dns "Static" dhcp
c:\winnt\system32\netsh.exe interface ip show address "Static"
c:\winnt\system32\netsh.exe interface ip show dns "Static"

pause
exit
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top