Quickly change IP configuration with netsh

Last update on October 20, 2009 09:41 AM by aakai1056
Published by aakai1056

Quickly change IP configuration with netsh





Issue


Sometimes it happens that your status is not systematically set as DHCP client, depending on the environment in which it operates. It becomes cumbersome to constantly change the TCP/IP parameters. Consider a simple example:
  • Environment 1: Office. The parameters are:
    • IP Address: 10.21.45.87 / 16
    • Gateway: 10.21.47.100
    • DNS: 10.21.48.127
    • WINS: 10.21.48.128
  • Environment 2: Main Client at which it moves 2 to 3 times per week.
    • IP Address: 192.168.27.101 / 24
    • Gateway: 192.168.27.100
    • DNS: 192.168.27.100
  • Environment 3: Home: DHCP client





We can note that changing environment is not a easy task. Fortunately, there is a feature of Windows that will simplify our task.

Solution


As you already know netsh allow you to change most TCP/IP parameters via command line.
So we will simply configure for the environments that a mostly used.
  • Start with the "office" environment in the example above. We will of course enter the settings, step by step. When the NIC is configured, open a command prompt and simply type :


netsh -c interface dump >office.txt 



This is the first step,you just create a netsh configuration file.
  • For the client configuration, the procedure is the same:
    • configure the network card with the correct parameters
    • open a command prompt

netsh -c interface dump >client.txt 
  • And finally, the home setup:
    • configure the DHCP client card
    • open a command prompt

taper netsh -c interface dump >home.txt




How to move from one configuration to another? Just call the corresponding configuration file:
  • Office:
  • open a command prompt
    • type
      netsh -f office.txt
  • Client:
    • open a command prompt
    • type
      netsh -f client.txt
  • Home:
    • open a command prompt
    • type
      netsh -f home.txt
  • The benefits:
    • No need to input tedious when changing environment
    • If an environment changes, it directly modifies the corresponding txt file.
Best answers for « Quickly change IP configuration with netsh » in :
[Windows] knowing the IP configuration of a PC Show [Windows] knowing the IP configuration of a PC IP configuration of a PC Open a DOS command window: Open the Start menu Click on Run Type cmd Click on OK In the MS-DOS window, type the following command ipconfig/ all Note...
[EEEpc] Quickly change the orientation of its screen Show[EEEpc] Quickly change the orientation of its screen To quickly change the orientation of the screen, make the following key combinations: Normal screen: CTRL + ALT + ⇑ Screen at 90 ° to the left: CTRL + ALT + ⇐ Screen...
Having a static IP address under Ubuntu 8.10 ShowHaving a static IP address under Ubuntu 8.10 To have a fixed IP persistent: Configure manually the interfaces For a fix IP (10.0.0.1 on your eth1 interface) use: To make use of dynamic IP (e.g eth0): DNS NetworkManager is a...
[Gentoo Linux] Change the timeout of DHCP Show[Gentoo Linux] Change the timeout of DHCP DHCP is configured with a default timeout of 3 minutes, this time lap is really annoying if you want to connect to a wireless network at startup. The timout changes in the file /etc/conf.d/net ...
Download Safe XP ShowSafe Xp allows users to tweak quickly the various configurations related with the security and Windows XP features. The options include: - Media Player configuration, - service configuration (report of errors, time synchronization, registry...
Network tests and diagnostics ShowTesting the IP configuration Before doing anything else, you are advised to check the computer's IP configuration. Windows systems offer a command-line tool, called ipconfig, that lets you find out your computer's IP configuration. The output of...
IP address spoofing ShowIP address spoofing "IP address spoofing" is a technique that involves replacing the IP address of an IP packet's sender with another machine's IP address. This technique lets a pirate send packets anonymously. It is not a question of changing the...
Linux commands ShowTable of main Linux commands Command Description DOS equivalent ls lists the content of a directory dir cd change directory cd cd .. parent directory cd.. mkdir creates a new...