| 3TGKB-0054 | |
|
Last Edited : |
11-08-05 |
|
Revision : |
1.0 |
The wonders of NetSH!
NetSH is one of the most powerful command line tools available to Windows XP
and Windows Server 2003.
I thought I would give you two examples of it's power and then an outline of
some of the other commands followed by some links to the Microsoft Web Site.
One of my students Peter also sent me an email which spurred my on to finally put something up here about netsh. I have placed his tip at the bottom, thanks Peter.
Netsh interface ip set
I use this command to change the ip addressing details on my network cards when I move my laptop between home and work. For example...
netsh interface ip set address name="Xircom" source=static 192.168.22.200
255.255.255.0 192.168.22.1 10
netsh interface ip set dns name="Xircom" static 192.168.22.201 primary
netsh interface ip set address name="3Com" source=dhcp
Netsh diag ping gateway
this command will automatically ping all of the computers default gateways
without needing to know what they are. See the example output below...
| Default Gateways 1. [00000002] 3Com 3C920 Integrated Fast Ethernet Controller (3C905C-TX Compatible) DefaultIPGateway = 172.31.0.1 Same Subnet Pinging 172.31.0.1 with 32 bytes of data: Reply from 172.31.0.1: bytes=32 time=1ms TTL=1 Reply from 172.31.0.1: bytes=32 time=1ms TTL=1 Reply from 172.31.0.1: bytes=32 time=1ms TTL=1 Reply from 172.31.0.1: bytes=32 time=1ms TTL=1 Ping statistics for 172.31.0.1: Packets: Sent = 4, Received = 4, Lost = 0 (0% loss) Approximate round trip times in milli-seconds: Minimum = 1ms, Maximum = 1ms, Average = 1ms 2. [00000011] Xircom CardBus Ethernet 100 + Modem 56 (Ethernet Interface) DefaultIPGateway = 192.168.250.1 Same Subnet Pinging 192.168.250.1 with 32 bytes of data: Reply from 192.168.250.1: bytes=32 time=1ms TTL=1 Reply from 192.168.250.1: bytes=32 time<1ms TTL=0 Reply from 192.168.250.1: bytes=32 time<1ms TTL=0 Reply from 192.168.250.1: bytes=32 time<1ms TTL=0 Ping statistics for 192.168.250.1: Packets: Sent = 4, Received = 4, Lost = 0 (0% loss) Approximate round trip times in milli-seconds: Minimum = 0ms, Maximum = 1ms, Average = 0ms |
The following commands are available:
Netsh diag show
Commands in this context
| show adapter | Displays all of the Adapters. |
| show all | Displays all categories. |
| show client | Displays all network clients. |
| show computer | Displays computer information. |
| show dhcp | Displays the DHCP servers for each adapter. |
| show dns | Displays the DNS servers for each adapter. |
| show gateway | Displays the default gateway servers for each adapter. |
| show ieproxy | Displays Internet Explorer's server name and port number. |
| show ip | Displays the IP address for each adapter. |
| show mail | Displays the mail server name and port number. |
| show modem | Displays all modems. |
| show news | Displays the news server name and port number. |
| show os | Displays operating system information. |
| show test | Displays all categories and performs all tests |
| show version | Displays the Windows and WMI version. |
| show wins | Displays the primary and secondary WINS servers for each adapter. |
Netsh diag connect
Commands in this context:
| connect ieproxy | Connect to Internet Explorer's proxy. |
| connect iphost | Connect to user specified IP host. |
| connect mail | Connect to the mail server. |
| connect news | Connect to the news server . |
Netsh diag ping
Commands in this context:
| ping adapter | Ping all of the Adapters. |
| ping dhcp | Ping the DHCP servers for each Adapter. |
| ping dns | Ping the DNS servers for each adapter. |
| ping gateway | Ping the default gateway servers for each adapter. |
| ping ieproxy | Ping Internet Explorer's proxy. |
| ping ip | Ping all IP addresses for each Adapter. |
| ping iphost | Ping an IP address or host name. |
| ping loopback | Ping loopback (127.0.0.1). |
| ping mail | Ping Outlook Express mail server. |
| ping news | Ping the news server. |
| ping wins | Ping the primary and secondary WINS servers for each Adapter. |
NetSH diag gui

netsh interactive mode - netsh
netsh>?
The following commands are available:
Commands in this context:
| .. | Goes up one context level. |
| ? | Displays a list of commands. |
| abort | Discards changes made while in offline mode. |
| add | Adds a configuration entry to a list of entries. |
| alias | Adds an alias. |
| bridge | Changes to the `netsh bridge' context. |
| bye | Exits the program. |
| commit | Commits changes made while in offline mode. |
| delete | Deletes a configuration entry from a list of entries. |
| diag | Changes to the `netsh diag' context. |
| dump | Displays a configuration script. |
| exec | Runs a script file. |
| exit | Exits the program. |
| firewall | Changes to the `netsh firewall' context. |
| help | Displays a list of commands. |
| interface | Changes to the `netsh interface' context. |
| offline | Sets the current mode to offline. |
| online | Sets the current mode to online. |
| popd | Pops a context from the stack. |
| pushd | Pushes current context on stack. |
| quit | Exits the program. |
| ras | Changes to the `netsh ras' context. |
| routing | Changes to the `netsh routing' context. |
| set | Updates configuration settings. |
| show | Displays information. |
| unalias | Deletes an alias. |
| wins | Changes to the `netsh wins' context. |
| winsock | Changes to the `netsh winsock' context. |
The following sub-contexts are available:
bridge diag firewall interface ras routing wins winsock
To view help for a command, type the command, followed by a space, and then
type ?.
Other Links:
Peters Tip:
============================================================================
"Local Area Connection" as used below is seen as the name in windows "Network
Connections" window
STATIC
SET STATIC IP
netsh interface ip set address "Local Area Connection" static 192.168.0.10
255.255.255.0 192.168.0.254 1
SET STATIC DNS
netsh interface ip set dns "Local Area Connection" static 192.168.2.10
ADD ANOTHER DNS SERVER
netsh interface ip add dns "Local Area Connection" 192.168.2.10
SET STATIC WINS
netsh interface ip set wins "Local Area Connection" static 192.168.2.10
ADD ANOTHER WINS SERVER
netsh interface ip add wins "Local Area Connection" 192.168.2.10
DHCP
SET DHCP IP
netsh interface ip set address "Local Area Connection" dhcp
SET DHCP DNS
netsh interface ip set dns "Local Area Connection" dhcp
SET DHCP WINS
netsh interface ip set wins "Local Area Connection" dhcp
DISABLE or ENABLE
netsh interface set interface "local area connection" enabled
netsh interface set interface "local area connection" disabled
============================================================================
Tip submitted by Peter Bond <peterb@legallybond.com> please email updates,
corrections and additions
============================================================================
Regards
Matt Rowston
KB Keywords: wonderful, netsh, ip, interface, ping, diagnosis