• Welcome to Overclockers Forums! Join us to reply in threads, receive reduced ads, and to customize your site experience!

Dynamic/static IP settings

Overclockers is supported by our readers. When you click a link to make a purchase, we may earn a commission. Learn More.

grs

Member
Joined
Apr 3, 2006
Location
Dublin, Ireland
This is to do with IP setting with my wireless network card. At home I have the laptop with Static IP settings so I can use some programs through my router. When I go into college and want to use the wireless network I have to go and change back to dynamic settings, the problem is the the static setting are not saved and I have manually type in the static setting when I go home. Is there a way of saving them so just click once are the setting are restored?
 
i haven't seen a way to do this but i don't claim to be an expert at networking by any stretch.

my advice (which is something i also do on my system) is to just have a file with all of the various IP addresses for your local setups that you need. you still have to remember to change it when you get home, but at least you won't forget what you had everything configured as.
 
you can also set up the alternate config under tcp/ip properties. make the first one a dhcp, and the alternate the static. if after a minute or two windows cant connect to the primary, it will try the alternate.
 
Alternate settings will only work for you if DHCP is disabled on your home network, in which case any machine that connects would need a static IP set - this may or may not be a problem depending on how you use your home network.

You might be better off to use the following script to set a static IP. Copy the code into a notepad window, then save it as a vbs after editting the configuration section for your home network:

Code:
' This code sets the local IP address
'   to a static IP of 10.0.0.100,
'   with a subnet mask of 255.0.0.0,
'   a default gateway of 10.0.0.1,
'   and a metric of 1
' ------ SCRIPT CONFIGURATION ------
strComputer = "."
strIPAddress = Array("10.0.0.100")
strSubnetMask = Array("255.0.0.0")
strGateway = Array("10.0.0.1")
strGatewayMetric = Array(1)
' --------- END CONFIGURATION ------

Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set adapters = objWMIService.ExecQuery _
    ("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")

For Each a in adapters
    errIP = a.EnableStatic(strIPAddress, strSubnetMask)
    errGateways = a.SetGateways(strGateway, strGatewaymetric)
    If errIP = 0 Then
        WScript.Echo "Success! The IP address has been changed."
    Else
        WScript.Echo "Error! The IP address could not be changed."
    End If
Next

The following code will set your settings back to DHCP:

Code:
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colNetAdapters = objWMIService.ExecQuery _
("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")
For Each objNetAdapter In colNetAdapters
errEnable = objNetAdapter.EnableDHCP()
If errEnable = 0 Then
Wscript.Echo "DHCP has been enabled."
Else
Wscript.Echo "DHCP could not be enabled."
End If
Next

You can find these examples on the net in various places.
 
At the moment I am carrying the different setting in a .txt file.
I.M.O.G.:-
I need to have the home setup so Pc's without static IP's can connect. My brother and his girlfriend us a laptop here to as well as their college and other places. They know even less than me about PC's so I don't want to bother them with settings and thing too much.
 
grs said:
At the moment I am carrying the different setting in a .txt file.
I.M.O.G.:-
I need to have the home setup so Pc's without static IP's can connect. My brother and his girlfriend us a laptop here to as well as their college and other places. They know even less than me about PC's so I don't want to bother them with settings and thing too much.

The scripts I gave you should work fine then.
 
Thanks. I will try that, but it could be some before I get a chance to do it.
Just explain it to me:- I copy all that script into into notepad, save it as two .vbs files, one to change it one way and the second to change it back, any particular name? Do I save it anywhere particular or just run from whereever. Also where would the configuration section of my network be?
The section above SCRIPT CONFIGURATION and END CONFIGURATION, I change the number to what I need?

May have more questions after I get around to doing it.

Thanks again
 
grs said:
Thanks. I will try that, but it could be some before I get a chance to do it.
Just explain it to me:- I copy all that script into into notepad, save it as two .vbs files, one to change it one way and the second to change it back, any particular name? Do I save it anywhere particular or just run from whereever. Also where would the configuration section of my network be?
The section above SCRIPT CONFIGURATION and END CONFIGURATION, I change the number to what I need?

May have more questions after I get around to doing it.

Thanks again

Cool. Yes, you copy the entire top script into notepad, and save it as one file. Change the section below script configuration and above end configuration to suit your particular network settings (those are the static settings you would normally input manually), then you could name it anything, I suggest "Disable DHCP.vbs". Then copy the entire bottom script into notepad and save it as "Enable DHCP.vbs".

In scripts like these, a comment is code that is not executed, and any line which begins with the apostrophe is just a message, so you don't have to worry about changing the lines at the top of the enable DHCP script.

It can be run from anywhere on your PC, put it somewhere convenient for you.
 
Another solution is to just use DHCP in both, but configure your router to always assign the MAC address of your laptop the ip you want, so when you are home, you'll always get the same IP, so you'll be effectively static, and when you're at school, you'll get whatever their dhcp server feels like giving you.
 
Back