Link to home
Start Free TrialLog in
Avatar of mrfite
mrfiteFlag for United States of America

asked on

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.
Avatar of gregcmcse
gregcmcse
Flag of United States of America image

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.
Avatar of mrfite

ASKER

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.
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.
Avatar of Patrick Tallarico
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.  
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?

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 :-)
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.
gregmcse's comment creates 2 static addresses I don't think this is what you are wanting, is that correct?

Pete :-)
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.
Avatar of mrfite

ASKER

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.
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
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
Avatar of mrfite

ASKER

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.
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).
Avatar of ola_erik
ola_erik

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
ASKER CERTIFIED SOLUTION
Avatar of mrfite
mrfite
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial