Gestione di Windows Firewall da riga di comando

Con Windows Server 2008 e Windows Vista è stato introdotto Windows Firewall with Advanced Security che rappresenta l’evoluzione del Windows Firewall disponibile in Windows Server 2003 e Windows XP.

Per gestire Windows Firewall with Advanced Security è stato reso disponibile il contesto netsh advfirewall firewall che va a sostituire il precedente netsh firewall.

Di seguito alcuni comandi che possono tornare utili per gestire il firewall ad esempio nelle istallazioni in modalità core o per la gestione automatizzata tramite scripts.

Visualizzazione delle impostazioni del firewall (Global Settings, Domain Profile Settings, Private Profile Settings e Public Profile Settings):

netsh advfirewall monitor show firewall

Visualizzazione delle rule Inboud attive:

netsh advfirewall monitor show firewall rule name=all dir=in profile=active verbose

Visualizzazione di tutte le rule:

netsh advfirewall firewall show rule name = all

Visualizzazione delle porte TCP/UDP dinamiche IPv4 e/o IPv6:

netsh int ipv4 show dynamicport tcp

netsh int ipv6 show dynamicport tcp

Intervallo porte dinamiche tcp protocollo
——————————————-
Porta iniziale : 49152
Numero di porte : 16384 -> (max 65535)

netsh int ipv4 show dynamicport udp

netsh int ipv6 show dynamicport udp

Intervallo porte dinamiche udp protocollo
——————————————-
Porta iniziale : 49152
Numero di porte : 16384 -> (max 65535)

A titolo d’informazione in Windows Server 2008 e Windows Vista il range delle porte dinamiche è stato modificato da 1024-5000 delle versioni precedenti di Windows a 49152-65535.

A riguardo si veda The default dynamic port range for TCP/IP has changed in Windows Vista and in Windows Server 2008:

“To comply with Internet Assigned Numbers Authority (IANA) recommendations, Microsoft has increased the dynamic client port range for outgoing connections in Windows Vista and in Windows Server 2008. The new default start port is 49152, and the default end port is 65535. This is a change from the configuration of earlier versions of Windows that used a default port range of 1025 through 5000.”

Abilitazione/Disabilitazione di una firewall rule:

netsh advfirewall firewall set rule name=”Rule name” new enable=yes

netsh advfirewall firewall set rule name=”Rule name” new enable=no

Reset delle impostazioni ai valori di default:

netsh advfirewall reset 

Per ulteriori informazioni si vedano: