Di bawah ini dari: https://support.microsoft.com/en-us/kb/947709
Contoh 1: Mengaktifkan program
Perintah lama Perintah baru
netsh firewall add allowedprogram C:\MyApp\MyApp.exe "My Application" ENABLE
netsh advfirewall firewall add rule name="My Application" dir=in action=allow program="C:\MyApp\MyApp.exe" enable=yes
netsh firewall add allowedprogram program=C:\MyApp\MyApp.exe name="My Application" mode=ENABLE scope=CUSTOM addresses=157.60.0.1,172.16.0.0/16,LocalSubnet profile=Domain netsh advfirewall firewall add rule name="My Application" dir=in action=allow program="C:\MyApp\MyApp.exe" enable=yes remoteip=157.60.0.1,172.16.0.0/16,LocalSubnet profile=domain
netsh firewall add allowedprogram program=C:\MyApp\MyApp.exe name="My Application" mode=ENABLE scope=CUSTOM addresses=157.60.0.1,172.16.0.0/16,LocalSubnet profile=ALL
Jalankan perintah berikut:
netsh advfirewall firewall add rule name="My Application" dir=in action=allow program="C:\MyApp\MyApp.exe" enable=yes remoteip=157.60.0.1,172.16.0.0/16,LocalSubnet profile=domain
netsh advfirewall firewall add rule name="My Application" dir=in action=allow program="C:\MyApp\MyApp.exe" enable=yes remoteip=157.60.0.1,172.16.0.0/16,LocalSubnet profile=private
Untuk informasi lebih lanjut tentang cara menambahkan aturan firewall, jalankan perintah berikut:
netsh advfirewall firewall add rule ?
Contoh 2: Mengaktifkan port
Perintah lama Perintah baru
netsh firewall add portopening TCP 80 "Open Port 80"
netsh advfirewall firewall add rule name="Open Port 80" dir=in action=allow protocol=TCP localport=80
Untuk informasi lebih lanjut tentang cara menambahkan aturan firewall, jalankan perintah berikut:
netsh advfirewall firewall add rule ?
Contoh 3: Hapus program atau port yang diaktifkan
Perintah lama Perintah baru
netsh firewall delete allowedprogram C:\MyApp\MyApp.exe netsh advfirewall firewall delete rule name=rule name program="C:\MyApp\MyApp.exe"
delete portopening protocol=UDP port=500 netsh advfirewall firewall delete rule name=rule name protocol=udp localport=500
Untuk informasi lebih lanjut tentang cara menghapus aturan firewall, jalankan perintah berikut:
netsh advfirewall firewall delete rule ?
Contoh 4: Konfigurasikan pengaturan ICMP
Perintah lama Perintah baru
netsh firewall set icmpsetting 8 netsh advfirewall firewall add rule name="ICMP Allow incoming V4 echo request" protocol=icmpv4:8,any dir=in action=allow
netsh firewall set icmpsetting type=ALL mode=enable netsh advfirewall firewall add rule name="All ICMP V4" protocol=icmpv4:any,any dir=in action=allow
netsh firewall set icmpsetting 13 disable all netsh advfirewall firewall add rule name="Block Type 13 ICMP V4" protocol=icmpv4:13,any dir=in action=block
Untuk informasi lebih lanjut tentang cara mengkonfigurasi pengaturan ICMP, jalankan perintah berikut:
netsh advfirewall firewall add rule ?
Contoh 5: Atur logging
Perintah lama Perintah baru
netsh firewall set logging %systemroot%\system32\LogFiles\Firewall\pfirewall.log 4096 ENABLE ENABLE
Jalankan perintah berikut:
netsh advfirewall set currentprofile logging filename %systemroot%\system32\LogFiles\Firewall\pfirewall.log
netsh advfirewall set currentprofile logging maxfilesize 4096
netsh advfirewall set currentprofile logging droppedconnections enable
netsh advfirewall set currentprofile logging allowedconnections enable
Untuk informasi lebih lanjut, jalankan perintah berikut:
netsh advfirewall set currentprofile ?
Jika Anda ingin mengatur pencatatan untuk profil tertentu, gunakan salah satu dari opsi berikut alih-alih opsi "profil saat ini":
Domainprofile
Privateprofile
Publicprofile
Contoh 6: Aktifkan Windows Firewall
Perintah lama Perintah baru
netsh firewall set opmode ENABLE netsh advfirewall set currentprofile state on
netsh firewall set opmode mode=ENABLE exceptions=enable
Jalankan perintah berikut:
Netsh advfirewall set currentprofile state on
netsh advfirewall set currentprofile firewallpolicy blockinboundalways,allowoutbound
netsh firewall set opmode mode=enable exceptions=disable profile=domain
Jalankan perintah berikut:
Netsh advfirewall set domainprofile state on
netsh advfirewall set domainprofile firewallpolicy blockinbound,allowoutbound
netsh firewall set opmode mode=enable profile=ALL Run the following commands:
netsh advfirewall set domainprofile state on
netsh advfirewall set privateprofile state on
Untuk informasi lebih lanjut, jalankan perintah berikut:
netsh advfirewall set currentprofile ?
Jika Anda ingin mengatur keadaan firewall untuk profil tertentu, gunakan salah satu opsi berikut daripada opsi "profil saat ini": Domainprofile
Privateprofile
Publicprofile
Contoh 7: Kembalikan default kebijakan
Perintah lama Perintah baru
netsh firewall reset
netsh advfirewall reset
Untuk informasi lebih lanjut, jalankan perintah berikut: netsh advfirewall reset? Contoh 8: Mengaktifkan layanan spesifik
Perintah lama Perintah baru netsh firewall mengatur layanan FileAndPrint netsh firewall advfirewall mengatur grup aturan = "Berbagi File dan Printer" baru mengaktifkan = Ya firewall set layanan netsh RemoteDesktop mengaktifkan netsh firewall advfirewall mengatur aturan grup = "remote desktop" baru aktifkan = Ya firewall netsh ditetapkan service RemoteDesktop enable profile = ALL Jalankan perintah berikut:
firewall netsh advfirewall mengatur grup aturan = "remote desktop" baru aktifkan = Ya profil = domain
firewall netsh advfirewall mengatur grup aturan = "remote desktop" baru aktifkan = Ya profil = pribadi