Hi,
here is a set of netsh command lines which I use very often.
Show Interface configuration
netsh interface ipv4 show config
Only IP Addresses of all LAN adapters
netsh interface ipv4 show address
Show global TCP/IP Parameters
netsh interface ipv4 show global
Disable and enable a Interface
netsh int set int name="ethernet" admin=disabled
netsh int set int name="ethernet" admin=enabled
Show all network interfaces and its link state
netsh interface ipv4 show interfaces
Print the routing table
netsh interface ipv4 show route
Show all tcp connections
netsh interface ipv4 show tcpconnections
Which Multicast groups are joined
netsh interface ipv4 show joins
Show dynamic portrange for outgoing connections
netsh interface ipv4 show dynamicportrange protocol=tcp
Set a static IP Address (172.16.254.2), Subnet Mask (255.255.255.192) and Gateway (172.16.254.1) on a specific interface (Local Area Connection 2) persistent
netsh interface ipv4 set address name="Local Area Connection 2" static 172.16.254.2 255.255.255.192 172.16.254.1 store=persistent
and temporary up to the next reboot and the parameters at full length. After the reboot the IP Address is empty.
netsh interface ipv4 set address name="Local Area Connection 2" static address=172.16.254.2 mask=255.255.255.192 gateway=172.16.254.1 store=active
Set DNS Servers without a DNS check, the set dnsservers
command supports only one server as argument
netsh interface ipv4 set dnsservers name="Local Area Connection 2" source=static address="172.16.254.250" validate=no
you have to add a second DNS Server with the add dnsservers
directive
netsh interface ipv4 add dnsservers name="Local Area Connection 2" address="172.16.254.251" validate=no index=2
Set IP Address assignment on Interface to DHCP
netsh interface ipv4 set address name="Local Area Connection 2" source=dhcp
and also the DNS Servers
netsh interface ipv4 set dnsservers name="Local Area Connection 2" source=dhcp
Add a route for subnet 172.16.1.0/24 over interface “Local Area Connection 2” and router 172.16.254.254
netsh interface add route prefix=172.16.1.0/24 interface="Local Area Connection 2" nexthop=172.16.254.254
Note: Since Windows Vista its not possible to set the dns search suffix with netsh, you have to use WMI for this.
To set the DNS search suffix use powershell and wmi.
Define your Domains
[string[]]$aDNSSearchSuffixes=@("subdomain.domain1.local","subdomain.domain2.local")
Get the WMI Class to invoke the static method SetDNSSuffixSearchOrder
$oNetworkadapterConfiguration=[wmiclass]"Win32_NetworkadapterConfiguration" $oNetworkadapterConfiguration.SetDNSSuffixSearchOrder($aDNSSearchSuffixes)
Or invoke the method directly by calling the Invoke-WmiMethod commandlet
Invoke-WmiMethod -Class Win32_NetworkadapterConfiguration -Name SetDNSSuffixSearchOrder -ArgumentList @(@("subdomain.domain1.local","subdomain.domain2.local"),$null)
or
Invoke-WmiMethod -Class Win32_NetworkadapterConfiguration -Name SetDNSSuffixSearchOrder -ArgumentList @($aDNSSearchSuffixes,$null)
Note: If the aDNSSearchSuffixes Array contains more then one element a second parameter of $null is requiered otherwise the Invoke-WmiMethod command failed with error: Invoke-WmiMethod : Unable to cast object of type ‘System.String’ to type ‘System.Array’.
Michael
I agree with your statement that it’s not possible to set Windows Vista dns search suffix with netsh, we have to use powershell as well as wmi for this problem. This is a really good read for me, Keep posting like this type of information.
netsh int set int name=”ethernet” admin=disabled
netsh int set int name=”ethernet” admin=enabled
Neither of these work in Windows XP.
They return “One or more essential parameters not specified. The syntax supplied for this command is not valid.”
Other netsh commands work with the same adapter name I am using, but these 2 will not.
is there a way to get interface names only or i have to extract through the text file after
“netsh interface ipv4 show interfaces”?