Jump to content

temporary network connection


Jay_ro

Recommended Posts

I have a network at my workplace without DHCP system. Everytime someone comes and needs a network connection I have to manually configure an IP adress and stuff for them. This is not so much trouble, but the thing is that I need to find a way to set that network connection to last only a few hours. Or to last until they restart their computers.

Do you guys know how can I set a computer to use a particular network connection setting only for a limited time? Could a setting like this be created with the help of a batch file?

Thank you

Link to comment
Share on other sites


I have written a program to static an IP address, which I can share here. Actually its really simple. You can handle this in multiple fashions.

First you can use a Logon script to set the IP address. Use the following procedure:

1. Take 1 machine (a test pc) and put in your IP address info. The whole shot, IP, subnet, gateway, dns, etc.

2. verify connectivity.

3. run the following:

netsh -c interface dump > c:\location1.txt

4. when the computer logs into Windows, run teh following:

netsh -f c:\location1.txt

This, of course, is for specific IP addresses. I use this for computers that always get the same IP, as we have a single drop to a static IP that is assigned to that drop. Now, if you need to assign different IP addresses, you may need another way to create that text file, or create different text files for different users.

You can then use Task Scheduler to create a task that runs every 3 hours (starting from login) that resets the IP information to default. Example command:

netsh interface ip set address "Local Area Connection" dhcp

Obvious issues with this is the name of the connection must be Local Area Connection or the program will fail.

Make sure to also consider the possibility that your users may shut down or power off their computers without logging off them first, which could also trigger a logoff script to 1) delete the scheduled task and 2) reset the NIC to DHCP (redundant but required). As such, you may need to use an INI, or create a file during the logon script. If the file exists at boot (when it shouldn't) the script would need to run the logoff script, and then run the logon script.

My AutoIT code for inputting the static IP (I run from a USB key):

RunWait( @ComSpec & " /c netsh -f " & @ScriptDir & "\location.txt" )
Sleep( 1000 )

Extra info:

http://www.petri.co.il/configure_tcp_ip_from_cmd.htm

http://technet.microsoft.com/en-us/library/bb490996.aspx

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...