NETSH?

Posted under TrainPro Tech Center by Adrian.Yeow on Wednesday 15 April 2009 at 12:43 pm

Setting IP Address Configuration using Netsh command?

Have anyone ever had the frustration that setting an IP Address to the computer seems to be rather tedious? Or have anyone thought off setting IP Address using command prompt or batch file while makes life a lot better? Well, Netsh is the command prompt which available to configure for Interfaces, DHCP, RRAS(Routing and Remote Access Service), Routing, WINS and etc.

With Netsh tool, you can direct the context commands you enter to the appropriate helper, and the helper then carries out the command. To display a list of sub contexts, and command that can be used in a context, type the context name followed by a space and a “?” at the netsh> command prompt. For example, to display a list of sub contexts of DHCP, just type “dhcp ?” at the netsh> command prompt and press ENTER.

Bellow are a list of context and its explanation over it;

/dhcp – Changes Dynamic Host Configuration Protocol context

/ras – Changes the Remote Access Server (RAS) context

/routing – Changes the routing context

/wins – Changes the Windows Internet Name Service (WINS) context

“?” can be a very good friend of you, it will show the context with appropriate helper. Well, how are you able to assign IP Address quickly and if you are a slow typist? Well, this is normally what I will do, I will save the netsh command into a notepad and then save the file as a “.bat”, batch file. Thus, when I was to use it, I will just double click the appropriate file. Some examples below;

netsh interface ip set address "Local Area Connection" dhcp
netsh interface ip set dns "Local Area Connection" dhcp

Save this two lines into the notepad, and save the file accordingly. This file when executed will assign the Interface with the name “Local Area Connection” to obtain IP Address automatically and start to contact the DHCP server. Besides, it also able to set the DNS option to be assigned with IP Address automatically. Another example below;

netsh interface ip set address “Local Area Connection” static 10.1.1.29 255.255.255.0 10.1.1.235 1
netsh interface ip set dns "Local Area Connection" static 10.1.1.2 primary
netsh interface ip add dns "Local Area Connection" 10.1.1.3 2

The above example when executed will then assign the static IP Address of 10.1.1.29 with the subnet prefix /24(255.255.255.0) to the interface name Local Area Connection with the gateway of 10.1.1.235 and the last number at the end of the command is the metric of the gateway. Also, the netsh command can assign Primary DNS and Alternate DNS to the interface too!

Guys, enjoy the Netsh command! Hope this pieces of information is benefiting you!


No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a comment

Copyright © 2010 TrainPro Blog. WP Theme created by Web Top.