Warning: Invalid argument supplied for foreach() in /home/techrecipes/public_html/wp-content/themes/techrecipes/header.php on line 77

XP: Set or Configure Network Interface to DHCP with netsh from Command Line

My predisposition to command line solutions for problems stems from my vast experience with UNIX. (I will admit that it is fun to intimidate GUI users.) However, there are times that command line solutions are the best fit for a problem. For example, if you find yourself frequently switching between a static IP address and DHCP for a network interface, as happens with laptops sometimes, it would be nice to have a command that could fit in a batch file. The netsh command in XP SP2 makes this possible. This tech-recipe shows the command to make an interface use DHCP.


To make the interface Local Area Network use DHCP instead of a static address, use the following command (all on one line):

netsh int ip set address name="Local Area Connection" source=dhcp

Other interface names can be substituted as needed.

 

About Quinn McHenry

Quinn was one of the original co-founders of Tech-Recipes. He is currently crafting iOS applications as a senior developer at Small Planet Digital in Brooklyn, New York.
View more articles by Quinn McHenry

The Conversation

Follow the reactions below and share your own thoughts.

  • Name

    What if I would like to have DHCP and static ip at the same time (multiple ip on one NIC). Now I have to use Regedit. BR

  • http://google murali

    super,ya i tried its working fine

  • Robert

    Insurmountable connectivity *issues with my broadband adapter have been resolved by using a enable/disable LAN icon on my XP QuickLaunch taskbar.

    To avoid the hassle of access to my isp’s website in order to re-boot the adapter [ a thrice daily chore ], I now simply restart the DHCP Client service found in the Service file of Administrative Tools when the connection is enabled.

    Works like a charm – but I’m sure this method could be refined?

    How would I go about creating a short-cut linking aforesaid DHCP Client “Restart” function to my QuickLaunch task bar, please?

    * For those who’re interested, my broadband connection is lost when my laptop reverts to stand-by and re-emerges as a continual “mobile connection” with permanent connectivity, thus becoming a security issue
    and wasting my 2Gb monthly capacity.

    Using the DHCP Client “Restart” facility restores my broadband connection instantly which will revert to the “pause/idle” mode when I’m not actually downloading anything.

    I wouldn’t worry ‘cept I’m concerned that malware could be inserted via this permanently open “mobile connection”. Yes, I have anti-virus but that stuff’s all reactive. I like to believe I’m proactive…

    Also, I’m too dumb to figure out this “how” on my own. I type with two fingers and that’s about the extent of my “techie” skill. I fiddle around a lot and haven’t blown anything major up yet.

    Thank you for your attention.

    PS I also like your site ‘cos I very seldom have Java enabled and I don’t need it here. That tell me y’all are secure.

  • Robert

    Ooops!

    Came across this ‘un:

    “Using notepad enter the following and save as DHCPstop.bat
    net stop DHCP Client

    This one call DHCPstart.bat
    net start DHCP Client

    Which makes, I think, my earlier entreaty redundant.

    Kindly consider it so – ‘less I’m missing some important advice otherwise.

    Cheers.