René Nyffenegger's collection of things on the web
René Nyffenegger on Oracle - Most wanted - Feedback -
 

Changing IP addresses for a laptop

I use my laptop at home as well as at various offices. At home, I have a fixed IP address while in the offices where I work, there are usually DHCP servers that assign an IP address to me. NETSH is a command line tool (that comes preinstalled with Windows) that allows to change the IP address with a configuration script.
I use a variation of the following script at home, where I have a fixed IP address. I do not want to include my real IP address, so this example uses a 192.168.1.6 as IP address. The dns address in this example is 192.168.1.2. The network mask is 255.255.255.0 and the gateway is 192.168.1.1
home.net
pushd interface ip

set address name="Local Area Connection" source=static addr=192.168.1.6 mask=255.255.255.0
set address name="Local Area Connection" gateway=192.168.1.1 gwmetric=0
set dns     name="Local Area Connection" source=static addr=192.168.1.2 register=PRIMARY
set wins    name="Local Area Connection" source=static addr=none

popd
The following configuration file is used in a DHCP environment:
dhcp.net
pushd interface ip

set address name="Local Area Connection" source=dhcp
set dns     name="Local Area Connection" source=dhcp register=PRIMARY
set wins    name="Local Area Connection" source=dhcp

popd
These configuration files can now be invoked with netsh like so:
netsh -f home.net
netsh -f dhcp.net