Solved

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

Posted on 2010-08-25
16
852 Views
Last Modified: 2013-12-23
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.
0
Comment
Question by:mrfite
  • 5
  • 4
  • 3
  • +3
16 Comments
 
LVL 9

Expert Comment

by:gregcmcse
ID: 33523634
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
 

Author Comment

by:mrfite
ID: 33523686
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
 
LVL 4

Expert Comment

by:alexmclv
ID: 33523891
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
 
LVL 6

Expert Comment

by:Patrick Tallarico
ID: 33523944
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
 
LVL 9

Expert Comment

by:gregcmcse
ID: 33523994
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
 
LVL 3

Expert Comment

by:petelettin
ID: 33524016
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
 
LVL 9

Expert Comment

by:gregcmcse
ID: 33524125
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
 
LVL 3

Expert Comment

by:petelettin
ID: 33524461
gregmcse's comment creates 2 static addresses I don't think this is what you are wanting, is that correct?

Pete :-)
0
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
LVL 9

Expert Comment

by:gregcmcse
ID: 33524605
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
 

Author Comment

by:mrfite
ID: 33525533
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
 
LVL 6

Expert Comment

by:Patrick Tallarico
ID: 33525626
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
 
LVL 6

Expert Comment

by:Patrick Tallarico
ID: 33525676
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
 

Author Comment

by:mrfite
ID: 33526800
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
 
LVL 9

Expert Comment

by:gregcmcse
ID: 33561730
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
 
LVL 3

Expert Comment

by:ola_erik
ID: 33575942
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
 

Accepted Solution

by:
mrfite earned 0 total points
ID: 33748274
It appears that this functionallity doesn't work well in XP and has been remvoed from Vista and Windows 7
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

A Cisco router can be configured as a DHCP Server. There are advantages and disadvantages in making your Cisco router work as DHCP Server. Almost all the features for windows DHCP can be configured on Cisco-based DHCP server. Some of the features me…
Are you one of those front-line IT Service Desk staff fielding calls, replying to emails, all-the-while working to resolve end-user technological nightmares? I am! That's why I have put together this brief overview of tools and techniques I use in o…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now