How to assign different IP address dependant on user login win 7
Originally posted here: http://answers.microsoft.com/thread/6da4e3a8-1d6c-47cd-9c85-f23263d63c68 They told me to REPOST here in this thread. I have a machine that generally sits on our network with DHCP assigned address (into our company network - mask 172.x.x.x). This assignment is correct and sufficient for the majority of the time. However, this machine is also the dedicated assigned machine for accessing our ip-based telephone system which runs on its own network (192.168.65.x). Currently, in order to access the configuration of our phone system, I have to manually change the ip address of the NIC from DHCP enable, to fixed 192.168.65.y - this then allows me to access the phone system through the browser. My question is if its possible to create a specific user, say "phonesys", (local to the machine and not domain based), that once logged in automatically sets/has the NIC ip address as the 192.168.65.y fixed address in order that I can just log in and access the phone system. (Conversely, all other users which are domain controlled will have the NIC settings as now which is DHCP). Is this possible? The initial answer I got was that I could use netsh commands to set the address with a login script for a certain user... http://technet.microsoft.com/en-us/library/cc731521(WS.10).aspx#BKMK_setaddress Now, I have tried looking and playing with this 'feature' but it is a little beyond my comprehension. I wonder if someone could guide me to what the 2 or 3 commands should be using the 'netsh' feature that could acheive my requirement? Also, is there a way of reversing the change on log out as I assume that a regular login (to the domain) when running its own login scripts will not allow/incorporate bespoking of this nature and will require the standard default setup of DHCP. (Or of course, is there any other way to acheive what I require other than the above suggestion?) Many thanks for any help I receive Graham
June 23rd, 2011 10:42am

If I understand you correctly then the computer is not moved, you just change it's ip address to access the phone network? If that is the case then you could probably solve this easily by adding a new route to the routing table of the computer. Try to run this command from an elevated command prompt to test, changes will be dismissed at next reboot: route add 192.168.65.0 mask 255.255.255.0 0.0.0.0 When done try to access phone network without changing the ip address. If test is successful then make the change permanent by adding the switch -p (persistant) like this: route -p add 192.168.65.0 mask 255.255.255.0 0.0.0.0
Free Windows Admin Tool Kit Click here and download it now
June 23rd, 2011 11:16am

(Or of course, is there any other way to acheive what I require other than the above suggestion?) Sure. In the interface's IPv4 alternate configuration assign it a second, static, IP address in the range 192.168.65.x. Now the machine is connected to both networks and can connect to devices on either one. The only issue might be is that now any user of the machine has access to both networks, so the security on your phone system needs to be rather tight...
June 23rd, 2011 11:31am

@Bob, I have tried this before and it failed as I would expect. The documentation says that the alternative address only comes into play when the primary DHCP lookup cannot be established. It was my thought ()as you are suggesting) that this is assigning 2 addresses to the same NIC but it doesnt work that way. @Eirik, I will try this now and report back. (thanks to both of you for your input so far) Graham
Free Windows Admin Tool Kit Click here and download it now
June 23rd, 2011 12:10pm

Eirik I tried the command and got a failure. Details: C:\Documents and Settings\Administrator>ipconfig Windows IP Configuration Ethernet adapter Local Area Connection 2: Connection-specific DNS Suffix . : mxxxxxl.com IP Address. . . . . . . . . . . . : 172.22.20.26 Subnet Mask . . . . . . . . . . . : 255.255.255.0 Default Gateway . . . . . . . . . : 172.22.20.254 C:\Documents and Settings\Administrator>route add 192.168.65.0 mask 255.255.255. 0 0.0.0.0 The route addition failed: Either the interface index is wrong or the gateway do es not lie on the same network as the interface. Check the IP Address Table for the machine. C:\Documents and Settings\Administrator> It seems that because the route is outside the current subnet mask, it isnt allowed (or am I misreading). Do you have a suggestion? Thanks Graham
June 23rd, 2011 12:25pm

@Bob, I have tried this before and it failed as I would expect. The documentation says that the alternative address only comes into play when the primary DHCP lookup cannot be established. It was my thought ()as you are suggesting) that this is assigning 2 addresses to the same NIC but it doesnt work that way. Yes, I forgot to mention that. Both addresses must be static in order for it to work as expected. Is there a problem with making the 172.x.x.x address static on this PC?
Free Windows Admin Tool Kit Click here and download it now
June 23rd, 2011 1:52pm

I am home right now but will go through the process tomorrow when back in the office to confirm. I think for this particular machine I can 'static-ip' it for the domain without a problem. However, pre-empting my findings, from an experience I have had previously trying this method I think it will still fail even with the static address. Im sure Ive tried this method before exactly as you are suggesting ut still had the same problem. My belief is that the alternative address comes into play when the primary assignment cannot be made (in the role of DHCP) or themachine is PHYSICALLY moved to another network that matches the second address mask (and doesnt actually assign 2 at the same time in the same way as you would get by inserting 2 separate NICs). Anyway, my memory might not be as good as I like to think it is (and therefore my previous experience may not be an exact match in conditions and setup), and of course I must give credit to you guys for any knowledge you know and offer. I will report back as soon as I have tried and inform you of the results. (would still appreciate further comment from Eirik on the 'route add' option too) Thanks guys.
June 23rd, 2011 3:56pm

Yes, I forgot to mention that. Both addresses must be static in order for it to work as expected. Is there a problem with making the 172.x.x.x address static on this PC? Hi Bob As expected this is not possible. As suggested before, the Alternate IP address is only used WHEN a DHCP server is set but not found. Suffice to say, it is not possible to enter 2 static IP addresses against the one NIC; you ONLY get the option of an alternate ip address when you select DHCP as the primary - if you do not select DHCP then the option for an alternate address is removed. This goes back to the theory that to have multiple assigned addresses to one machine requires either more than one NIC in use or some clever routing. So, I am still at the situation and open for any further thoughts and help. Much appreciated
Free Windows Admin Tool Kit Click here and download it now
June 24th, 2011 4:52am

Actually it is possible, you (and I) have just been looking in the wrong place - it's not under Alternate Configuration, it's under Advanced. I just gave it a shot on my laptop and it seems to have worked: After assigning a static address, gateway and DNS servers in the primary spot click on the Advanced button. You can then add as many secondary IP addresses as you wish. But the primary IP must be static or you can't add secondaries. You can also add secondary gateways (if needed) and DNS servers for your secondary IPs (if needed) on the DNS tab. I apologize for taking so long to figure it out; I knew I'd done it before, the how just slipped my mind.
July 1st, 2011 9:33am

HI Bob, many thanks for replying. This is a method (as you say) that I didnt think of trying yes. I will try the method back at work next week and return back and let you know the result. (Bear with me a few days though. Had a bike accident last night, nothing major, but might be off work a few days). I will keep you posted in any case of the results. Cheers Graham
Free Windows Admin Tool Kit Click here and download it now
July 1st, 2011 9:52am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics