Storing setups for multiple windows networks
#1
Scooby Regular
Thread Starter
Join Date: Jun 2002
Location: Berkshire
Posts: 1,280
Likes: 0
Received 0 Likes
on
0 Posts
I seem to remember someone was talking about an application to keep the settings to sign on to multiple windows networks / workgroups so that when moving between locations i dont have to keep changing network settings.
anyone remember?
David
anyone remember?
David
#4
If you are using W2K or XP you can use a simple command-shell script and the Netsh (i.e., NetShell) command.
Netsh provides a command-line interface that lets you administer and configure network services, including the ability to change the TCP/IP network configuration settings. The script in Listing 1, shows how to switch a PC to use a dynamic address assigned by a DHCP server.
The script turns off the echo, then the first Netsh command sets the context to interface. The context controls which facet of the network configuration the Netsh command will manipulate. Netsh supports the following contexts: ras, routing, and interface. Using the interface context sets the command to work with the system's networking properties. The ip label specifies that the Netsh command will work with the TCP/IP configuration.
Several subcommands are available within the interface context. In Listing 1, the Set subcommand changes configuration information, and the address label specifies that the Set subcommand will set the system's IP address. The "Local Area Connection" string identifies the connection that these settings will apply to. The name Local Area Connection is the default on most systems, but if your system is different you'll need to change this string to match the connection name that's in use. The dhcp label indicates that a DHCP server will assign the address.
The second Netsh command sets the DNS name of the connection named "Local Area Connection" to be supplied by the DHCP server. When the network uses dynamic addresses assigned through DHCP, DHCP typically assigns the DNS address as well.
When you want to switch your system back to a fixed IP address, you can run the script that Listing 2, shows. In Listing 2, the first Netsh command sets the IP address of the connection named "Local Area Connection" to the static IP address of 192.168.1.10. The second parameter of the Netsh command specifies the subnet mask. This example uses 255.255.255.0 as the subnet mask associated with the static IP address. The third parameter is the default gateway (if any) on the local IP subnet. Listing 2 gives the gateway a sample address of 192.168.1.1. An optional fourth parameter of the Netsh command is the metric, which defines the maximum number of hops to the default gateway.
The second Netsh command in Listing 2 changes the system's DNS configuration to use a static DNS server at the IP address of 192.168.1.2.
You can learn more about the Netsh command from the Microsoft article :
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/netshell/netshell/netshell_start_page.asp
LISTING 1: Code to Switch to a Dynamic Address
:: Switch2DHCP.cmd
@echo off
@echo Changing to Dynamic IP address
:: Set to dhcp.
netsh interface ip set address "Local Area Connection" dhcp
netsh interface ip set dns name="Local Area Connection" source=dhcp
@echo System Switched to DHCP
Listing 2: Code to Switch to a Fixed IP Address
:: Switch2IP.cmd
@echo off
@echo Changing to Static IP address 192.168.1.10
:: Set the IP address.
netsh interface ip set address "Local Area Connection"
static 192.168.1.10 255.255.255.0 192.168.1.1 1
netsh interface ip set dns "Local Area Connection"
static 192.168.1.2
@echo System Switched to static IP 192.168.1.10
Dupo
Netsh provides a command-line interface that lets you administer and configure network services, including the ability to change the TCP/IP network configuration settings. The script in Listing 1, shows how to switch a PC to use a dynamic address assigned by a DHCP server.
The script turns off the echo, then the first Netsh command sets the context to interface. The context controls which facet of the network configuration the Netsh command will manipulate. Netsh supports the following contexts: ras, routing, and interface. Using the interface context sets the command to work with the system's networking properties. The ip label specifies that the Netsh command will work with the TCP/IP configuration.
Several subcommands are available within the interface context. In Listing 1, the Set subcommand changes configuration information, and the address label specifies that the Set subcommand will set the system's IP address. The "Local Area Connection" string identifies the connection that these settings will apply to. The name Local Area Connection is the default on most systems, but if your system is different you'll need to change this string to match the connection name that's in use. The dhcp label indicates that a DHCP server will assign the address.
The second Netsh command sets the DNS name of the connection named "Local Area Connection" to be supplied by the DHCP server. When the network uses dynamic addresses assigned through DHCP, DHCP typically assigns the DNS address as well.
When you want to switch your system back to a fixed IP address, you can run the script that Listing 2, shows. In Listing 2, the first Netsh command sets the IP address of the connection named "Local Area Connection" to the static IP address of 192.168.1.10. The second parameter of the Netsh command specifies the subnet mask. This example uses 255.255.255.0 as the subnet mask associated with the static IP address. The third parameter is the default gateway (if any) on the local IP subnet. Listing 2 gives the gateway a sample address of 192.168.1.1. An optional fourth parameter of the Netsh command is the metric, which defines the maximum number of hops to the default gateway.
The second Netsh command in Listing 2 changes the system's DNS configuration to use a static DNS server at the IP address of 192.168.1.2.
You can learn more about the Netsh command from the Microsoft article :
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/netshell/netshell/netshell_start_page.asp
LISTING 1: Code to Switch to a Dynamic Address
:: Switch2DHCP.cmd
@echo off
@echo Changing to Dynamic IP address
:: Set to dhcp.
netsh interface ip set address "Local Area Connection" dhcp
netsh interface ip set dns name="Local Area Connection" source=dhcp
@echo System Switched to DHCP
Listing 2: Code to Switch to a Fixed IP Address
:: Switch2IP.cmd
@echo off
@echo Changing to Static IP address 192.168.1.10
:: Set the IP address.
netsh interface ip set address "Local Area Connection"
static 192.168.1.10 255.255.255.0 192.168.1.1 1
netsh interface ip set dns "Local Area Connection"
static 192.168.1.2
@echo System Switched to static IP 192.168.1.10
Dupo
#5
Or you could you use www.netswitcher.com
There's a free trial on the PC Pro cover disc this month.
Roger
[Edited by rogp - 1/21/2004 10:33:03 PM]
There's a free trial on the PC Pro cover disc this month.
Roger
[Edited by rogp - 1/21/2004 10:33:03 PM]
Thread
Thread Starter
Forum
Replies
Last Post