{"id":1586,"date":"2014-01-08T23:23:35","date_gmt":"2014-01-08T22:23:35","guid":{"rendered":"http:\/\/michlstechblog.info\/blog\/?p=1586"},"modified":"2016-04-07T08:51:20","modified_gmt":"2016-04-07T06:51:20","slug":"windows-show-and-configure-network-settings-using-netsh","status":"publish","type":"post","link":"https:\/\/michlstechblog.info\/blog\/windows-show-and-configure-network-settings-using-netsh\/","title":{"rendered":"Windows: Show and configure network settings using netsh"},"content":{"rendered":"<div class=\"twoclick_social_bookmarks_post_1586 social_share_privacy clearfix 1.6.4 locale-en_US sprite-en_US\"><\/div><div class=\"twoclick-js\"><script type=\"text\/javascript\">\/* <![CDATA[ *\/\njQuery(document).ready(function($){if($('.twoclick_social_bookmarks_post_1586')){$('.twoclick_social_bookmarks_post_1586').socialSharePrivacy({\"services\":{\"flattr\":{\"uid\":\"Michl\",\"status\":\"on\",\"the_title\":\"Windows%3A%20Show%20and%20configure%20network%20settings%20using%20netsh\",\"the_excerpt\":\"Hi%2C%0D%0A%0D%0Ahere%20is%20a%20set%20of%20netsh%20command%20lines%20which%20I%20use%20very%20often.%0D%0A%0D%0AShow%20Interface%20configuration%0D%0A%0D%0Anetsh%20interface%20ipv4%20show%20config%0D%0A%0D%0AOnly%20IP%20Addresses%20of%20all%20LAN%20adapters%0D%0A%0D%0Anetsh%20interface%20ipv4%20show%20address%0D%0A%0D%0A%0D%0AShow%20global%20TCP%2FIP%20Parameters%0D%0A%0D%0Anetsh%20interface%20ipv4%20show%20global%0D%0A%0D%0A%0D%0ADisable%20and%20enable%20a%20Interface%0D%0A%0D%0Anetsh%20int%20set%20int%20name%3D%22ethernet%22%20admin%3Ddisabled%0D%0Anetsh%20int%20set%20int%20name%20...\",\"txt_info\":\"2 clicks for more data protection:\\r\\n\\r\\nOnly when you click here, the button will be come active and you can send your recommendation to Flattr. When activating, data are transmitted to third parties. \",\"perma_option\":\"off\"}},\"txt_help\":\"When you activate these fields by clicking, information to Flattr may be transferred abroad, and probably may also stored there.\",\"settings_perma\":\"Enable permanently and accept data transmission. \",\"info_link\":\"http:\\\/\\\/www.heise.de\\\/ct\\\/artikel\\\/2-Klicks-fuer-mehr-Datenschutz-1333879.html\",\"uri\":\"https:\\\/\\\/michlstechblog.info\\\/blog\\\/windows-show-and-configure-network-settings-using-netsh\\\/\",\"post_id\":1586,\"post_title_referrer_track\":\"Windows%3A+Show+and+configure+network+settings+using+netsh\",\"display_infobox\":\"on\"});}});\n\/* ]]> *\/<\/script><\/div><p>Hi,<\/p>\n<p>here is a set of netsh command lines which I use very often.<\/p>\n<p>Show Interface configuration<\/p>\n<p><code>netsh interface ipv4 show config<\/code><\/p>\n<p>Only IP Addresses of all LAN adapters<\/p>\n<p><code>netsh interface ipv4 show address<br \/>\n<\/code><\/p>\n<p>Show global TCP\/IP Parameters<\/p>\n<p><code>netsh interface ipv4 show global<br \/>\n<\/code><\/p>\n<p>Disable and enable a Interface<br \/>\n<code><br \/>\nnetsh int set int name=\"ethernet\" admin=disabled<br \/>\nnetsh int set int name=\"ethernet\" admin=enabled<br \/>\n<\/code><\/p>\n<p>Show all network\u00a0 interfaces and its link state<\/p>\n<p><code>netsh interface ipv4 show interfaces<\/code><br \/>\n<!--more--><br \/>\nPrint the routing table<\/p>\n<p><code>netsh interface ipv4 show route<\/code><\/p>\n<p>Show all tcp connections<\/p>\n<p><code>netsh interface ipv4 show tcpconnections<\/code><\/p>\n<p>Which Multicast groups are joined<br \/>\n<code>netsh interface ipv4 show joins<\/code><\/p>\n<p>Show dynamic portrange for outgoing connections<br \/>\n<code>netsh interface ipv4 show dynamicportrange protocol=tcp<\/code><\/p>\n<p>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<\/p>\n<p><code>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<\/code><\/p>\n<p>and temporary up to the next reboot and the parameters at full length. After the reboot the IP Address is empty.<br \/>\n<code>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<\/code><\/p>\n<p>Set DNS Servers without a DNS check, the\u00a0 <code>set dnsservers<\/code> command supports only one server as argument<\/p>\n<p><code>netsh interface ipv4 set dnsservers name=\"Local Area Connection 2\"\u00a0 source=static address=\"172.16.254.250\" validate=no<\/code><\/p>\n<p>you have to add a second DNS Server with the <code> add dnsservers<\/code> directive<\/p>\n<p><code>netsh interface ipv4 add dnsservers name=\"Local Area Connection 2\" address=\"172.16.254.251\" validate=no index=2<\/code><\/p>\n<p>Set IP Address assignment on Interface to DHCP<\/p>\n<p><code>netsh interface ipv4 set address name=\"Local Area Connection 2\" source=dhcp<\/code><\/p>\n<p>and also the DNS Servers<\/p>\n<p><code>netsh interface ipv4 set dnsservers name=\"Local Area Connection 2\" source=dhcp<\/code><\/p>\n<p>Add a route\u00a0 for subnet 172.16.1.0\/24 over interface\u00a0&#8220;Local Area Connection 2&#8221; and router 172.16.254.254<\/p>\n<p><code>netsh interface add route prefix=172.16.1.0\/24 interface=\"Local Area Connection 2\" nexthop=172.16.254.254<\/code><\/p>\n<p>Note: Since Windows Vista its not possible to set the dns search suffix with netsh, you have to use WMI for this.<br \/>\nTo set the DNS search suffix use powershell and wmi.<br \/>\nDefine your Domains<\/p>\n<pre class=\"brush: powershell; title: ; notranslate\" title=\"\">&#x5B;string&#x5B;]]$aDNSSearchSuffixes=@(&quot;subdomain.domain1.local&quot;,&quot;subdomain.domain2.local&quot;)<\/pre>\n<p>Get the WMI Class to invoke the static method SetDNSSuffixSearchOrder<\/p>\n<pre class=\"brush: powershell; title: ; notranslate\" title=\"\">$oNetworkadapterConfiguration=&#x5B;wmiclass]&quot;Win32_NetworkadapterConfiguration&quot; $oNetworkadapterConfiguration.SetDNSSuffixSearchOrder($aDNSSearchSuffixes)<\/pre>\n<p>Or invoke the method directly by calling the Invoke-WmiMethod commandlet<\/p>\n<pre class=\"brush: powershell; title: ; notranslate\" title=\"\">Invoke-WmiMethod -Class Win32_NetworkadapterConfiguration -Name SetDNSSuffixSearchOrder -ArgumentList @(@(&quot;subdomain.domain1.local&quot;,&quot;subdomain.domain2.local&quot;),$null)<\/pre>\n<p>or<\/p>\n<pre class=\"brush: powershell; title: ; notranslate\" title=\"\">\r\nInvoke-WmiMethod -Class Win32_NetworkadapterConfiguration -Name SetDNSSuffixSearchOrder -ArgumentList @($aDNSSearchSuffixes,$null)<\/pre>\n<p>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: <strong>Invoke-WmiMethod : Unable to cast object of type &#8216;System.String&#8217; to type &#8216;System.Array&#8217;.<\/strong><\/p>\n<p>Michael<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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=&#8221;ethernet&#8221; admin=disabled netsh &hellip; <a href=\"https:\/\/michlstechblog.info\/blog\/windows-show-and-configure-network-settings-using-netsh\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Windows: Show and configure network settings using netsh<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,5],"tags":[407,23,405,404,408,406,401,402,20],"class_list":["post-1586","post","type-post","status-publish","format-standard","hentry","category-windows","category-windowsknowhow","tag-add-route","tag-command-line","tag-default-gateway","tag-dns","tag-invoke-wmimethod-unable-to-cast-object-of-type-system-string-to-type-system-array","tag-multiple-dns-servers","tag-netsh","tag-static-ip-address","tag-windows-2"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/posts\/1586","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/comments?post=1586"}],"version-history":[{"count":23,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/posts\/1586\/revisions"}],"predecessor-version":[{"id":3634,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/posts\/1586\/revisions\/3634"}],"wp:attachment":[{"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/media?parent=1586"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/categories?post=1586"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/tags?post=1586"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}