Jan 4, 2013 08:30 AM
(This post was last modified: Mar 6, 2013 08:55 AM by LevelUp.)
What is the Netsh command?
Netsh has the ability to configure Windows Server networking and firewall functions, something which Powershell doesn't really touch on.
Let's get started. I'll be covering a list of useful commands, they are done via Command Prompt.
Network Configuration
To show the system's current IP configuration, you are able to use the following command to see if the system is using DHCP or static addressing but also to show the system's current IP address, submask, gateway address, and DNS server:
Netsh commands work with both Windows IPv4 and IPv6. To display your system's IPv4/IPv6 address, use the following Netsh command(s):
Netsh can work with the built-in Windows Firewall. Just so you know, if your using Windows XP/2003, the command is netsh firewall. The following commands show how to disable then re-enable the Windows Firewall in Windows 7:
You're also able to use Netsh to open ports in the firewall for different applications. This example in particular shows how to open TCP port 1434 for Microsoft SQL Server access:
The next example shows how you use Netsh to configure a network adapter to use a static IP address. This example specifically will set the IP address of the network adapter named Local Area Connection to 192.168.1.16, the subnet mask to 255.255.255.0, and finally the gateway address to 192.168.0.254:
When you change the system's IP address type to static, you usually need to change the DNS configuration also. This example shows how to use Netsh to configure the Local Area Connection to use a DNS server with the address 192.168.0.6:
And the next command is used to add another DNS Server
Netsh and Firewall Configuration
First things first, you'll want to use netsh to find out your Windows Firewall's current configuration properties using the following command
The next commands show how to turn Windows Firewall off and then back on:
If you make an absolute balls of something, it can be easily fixed by reverting to default settings:
Ermagherd someone's using ping -t -l 65500 and booting you off (lel) and you need to block their ping, this command will do just that.
If you want to enable/disable a port in your firewall, you can use the following
The final task I'll be showing is how to open Windows Firewall for a given program. The following example illustrates how to add a rule that enables LOIC (lel) to work through Windows Firewall:
Thanks for reading this tutorial. I didn't want to go too in-depth and I hope that I achieved at least making you understand some of the basic commands.
Netsh has the ability to configure Windows Server networking and firewall functions, something which Powershell doesn't really touch on.
Let's get started. I'll be covering a list of useful commands, they are done via Command Prompt.
Network Configuration
To show the system's current IP configuration, you are able to use the following command to see if the system is using DHCP or static addressing but also to show the system's current IP address, submask, gateway address, and DNS server:
Code
netsh interface ip show configNetsh commands work with both Windows IPv4 and IPv6. To display your system's IPv4/IPv6 address, use the following Netsh command(s):
Code
netsh interface ipv4 show address
or
netsh interface ipv6 show addressNetsh can work with the built-in Windows Firewall. Just so you know, if your using Windows XP/2003, the command is netsh firewall. The following commands show how to disable then re-enable the Windows Firewall in Windows 7:
Code
netsh advfirewall set currentprofile state off
netsh advfirewall set currentprofile state onYou're also able to use Netsh to open ports in the firewall for different applications. This example in particular shows how to open TCP port 1434 for Microsoft SQL Server access:
Code
netsh advfirewall firewall
add rule name="SQL Server"
dir=in action=allow
protocol=TCP localport=1434The next example shows how you use Netsh to configure a network adapter to use a static IP address. This example specifically will set the IP address of the network adapter named Local Area Connection to 192.168.1.16, the subnet mask to 255.255.255.0, and finally the gateway address to 192.168.0.254:
Code
netsh interface ip
set address "Local Area Connection"
static 192.168.1.16
255.255.255.0 192.168.0.254 1When you change the system's IP address type to static, you usually need to change the DNS configuration also. This example shows how to use Netsh to configure the Local Area Connection to use a DNS server with the address 192.168.0.6:
Code
netsh interface ip
set dns "Local Area Connection"
static 192.168.0.6And the next command is used to add another DNS Server
Code
netsh interface ip
add dnsserver "Local Area Connection"
192.168.0.4Netsh and Firewall Configuration
First things first, you'll want to use netsh to find out your Windows Firewall's current configuration properties using the following command
Code
netsh advfirewall firewall show rule name=allThe next commands show how to turn Windows Firewall off and then back on:
Code
netsh advfirewall set allprofiles state on
netsh advfirewall set allprofiles state offIf you make an absolute balls of something, it can be easily fixed by reverting to default settings:
Code
netsh advfirewall resetErmagherd someone's using ping -t -l 65500 and booting you off (lel) and you need to block their ping, this command will do just that.
Code
netsh advfirewall firewall add rule name="All ICMP V4" dir=in action=block protocol=icmpv4
Just change action=allow to make ping possible againIf you want to enable/disable a port in your firewall, you can use the following
Code
netsh advfirewall firewall add rule name="Open SQL Server Port 1337" dir=in action=allow protocol=TCP localport=1337
replace with
netsh advfirewall firewall delete rule name="Open SQL Server Port 1337" protocol=tcp localport=1337.. in order to close the portThe final task I'll be showing is how to open Windows Firewall for a given program. The following example illustrates how to add a rule that enables LOIC (lel) to work through Windows Firewall:
Code
netsh advfirewall firewall add rule name="Allow LOIC" dir=in action=allow program="C:\LOIC.exe"Thanks for reading this tutorial. I didn't want to go too in-depth and I hope that I achieved at least making you understand some of the basic commands.



