How to Enable DHCP and Static IP's on the same interface in Windows

I have a business requirement to allow one PC to talk to two different networks.  One network is controlled by DHCP Protocols and the other is static.  I need to be able to allow the DHCP Network to assign an address to the PC and I need the PC to also have a static address for the other network.  2 Network cards will not work in this situation so I need one card to have both addresses.  I have seen registery tweaks to do this but I would perfer a netsh or script to accomplish this.

Your help is appreciated.
mrfiteAsked:
Who is Participating?
 
mrfiteConnect With a Mentor Author Commented:
It appears that this functionallity doesn't work well in XP and has been remvoed from Vista and Windows 7
0
 
gregcmcseCommented:
You can set an alternate configuration that it will fail to if DHCP doesn't exist on the network you need the static address for.  A better solution, if DHCP does exist on the network you need a static address for is to define a DHCP reservation for that network adapter with the static IP you want to use.
0
 
mrfiteAuthor Commented:
I need both addresses to be available at the same time (not a fall back postion).  One network is hardcoded in a piece of equipment and the other is our corporate network.  I need for both to be active at the same time.
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
alexmclvCommented:
You can try to force additional static IP addresses by editing the registry.

1.- Using Registry Editor, navigate to the folder:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Paremeters\Interfaces\{FFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFFFFFF}
*** I posted a dummy GUID at the end of the string, but you should be able to locate the right GUID for your NIC by comparing the settings listed on the right panel to your DHCP-assigned settings. ***

2.- Modify the IPAddress multi-string key and include the desired static IP addresses. You might also want to modify the SubnetMask and DefaultGateway keys.
0
 
Patrick TallaricoFSEP Systems AnalystCommented:
Unfortunately to my knowledge, enabling the multiple IP addresses in windows xp will disable the dhcp option.  You should be able to hard-code up to 5 addresses per adapter.  
You could assign static addresses for both networks you need to access.  
0
 
gregcmcseCommented:
You'll need to use static IPs for both, I would think.  Create a DHCP reservation to prevent problems just in case.  Which client OS?

0
 
petelettinCommented:
you need a router or layer 3 switch attach device to a port or vlan with subnet in range of device. workstations only need dhcp address. packets directed to device by router/switch.

Pete :-)
0
 
gregcmcseCommented:
This should work on XP -- might be subtly different for Vista/Windows 7.
netsh interface ip show config
(will show you interface names -- use the correct name for the interface if different than "Local Area Connection")
netsh interface ip set address name="Local Area Connection" static addr=10.1.2.200 mask=255.255.255.0 gateway=10.1.2.1 gwmetric=1
netsh interface ip add address name="Local Area Connection" static addr=192.168.0.200 mask=255.255.255.0
(note, second address may not need a gateway or metric and I wouldn't include them if you don't need to).
You may want to use the GUI to assign the first address and the DNS servers, etc.  You can then use just the second "netsh" to configure the second address.
0
 
petelettinCommented:
gregmcse's comment creates 2 static addresses I don't think this is what you are wanting, is that correct?

Pete :-)
0
 
gregcmcseCommented:
I'm pretty sure he's stuck with two statics, Pete -- although he could try just the "netsh interface ip add address" line and see if it works.
0
 
mrfiteAuthor Commented:
As my origional post states, there are registry tweaks like alexmclv points out that will make this work.  I was hoping for a solution that could be put in the form of a script or batch to make it easier to deploy.
0
 
Patrick TallaricoFSEP Systems AnalystCommented:
add the following into a file called test.bat  and see if that works for you.
I have test4ed it on XP.

netsh interface ip set address name="Local Area Connection" static 192.168.0.100 255.255.255.0 192.168.0.1 1
netsh interface ip add address name="Local Area Connection" 192.168.0.14 255.255.255.0 192.168.0.1 1
0
 
Patrick TallaricoFSEP Systems AnalystCommented:
then to configure dns add the following line to your script

netsh interface ip set dns name="Local Area Connection" static 192.168.0.1 both

the both refers to registering with the dns server
0
 
mrfiteAuthor Commented:
This would make two static ip addresses.  This is not what I need.  I need one static and one DHCP address on the same interface.  I have done this before in linux but cannot find a easy way to do this in windows without using  a registry tweak.
0
 
gregcmcseCommented:
mrfite:  There is no way to do what you have requested unless the last post I mentioned works for you.
With DHCP configured, try this command:
netsh interface ip add address name="Local Area Connection" static addr=192.168.0.200 mask=255.255.255.0
(Replace 192.168.0.200 and 255.255.255.0 with your static IP address and mask)
It will probably fail or remove your DHCP address.  If not, you're set.  If so, you'll need to create a DHCP reservation (or pick an address outside the scope) for your main subnet IP and specify it as a static IP on your machine.
netsh interface ip set address name="Local Area Connection" static addr=10.1.2.200 mask=255.255.255.0 gateway=10.1.2.1 gwmetric=1
netsh interface ip add address name="Local Area Connection" static addr=192.168.0.200 mask=255.255.255.0
 (Replace 10.1.2.200, mask, and gateway with the correct values for your network).
0
 
ola_erikCommented:
If done this with two different hardware profiles on one machine. Yuo have to reboot and choose that particular profile during the boot sequence. Each HW profile then has separate configs.

It was a while since, so I don't remeber the specifics.

http://www.google.com/search?q=xp+hardware+profile&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:sv-SE:official&client=firefox-a
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.