[转帖]Windows 使用netsh 命令行方式处理 windows防火墙的方法
Windows防火墙命令行手册
简介
- 域(Domain)
- 私有(Private)
- 公共(Public)
Old command 针对Win7以下版本<包含Win7>
详细信息
示例 1︰ 启用程序
Old command | New command |
---|---|
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 | Run the following commands:
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 |
示例 2︰ 启用端口
Old command | New command |
---|---|
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 |
For more information about how to add firewall rules, run the following command:
示例 3︰ 删除启用的程序或端口
Old command | New command |
---|---|
netsh firewall delete allowedprogram C:\MyApp\MyApp.exe | netsh advfirewall firewall delete rule name=rule nameprogram="C:\MyApp\MyApp.exe" |
delete portopening protocol=UDP port=500 | netsh advfirewall firewall delete rule name=rule name protocol=udp localport=500 |
示例 4︰ 配置 ICMP 设置
Old command | New command |
---|---|
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 |
示例 5︰设置日志记录
Old command | New command |
---|---|
netsh firewall set logging %systemroot%\system32\LogFiles\Firewall\pfirewall.log 4096 ENABLE ENABLE | Run the following commands:
netsh advfirewall set currentprofile logging filename %systemroot%\system32\LogFiles\Firewall\pfirewall.log netsh advfirewall set currentprofile logging maxfilesize 4096 netsh advfirewall set currentprofile logging allowedconnections enable |
currentprofile 可以使用/Domainprofile/Privateprofile/Publicprofile/选项替换
示例 6︰ 启用 Windows 防火墙
Old command | New command |
---|---|
netsh firewall set opmode ENABLE | netsh advfirewall set currentprofile state on |
netsh firewall set opmode mode=ENABLE exceptions=enable | Run the following commands:
Netsh advfirewall set currentprofile state on netsh advfirewall set currentprofile firewallpolicy blockinboundalways,allowoutbound |
netsh firewall set opmode mode=enable exceptions=disable profile=domain | Run the following commands:
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 |
currentprofile 可以使用/Domainprofile/Privateprofile/Publicprofile/选项替换
示例 7︰ 还原默认策略设置
Old command | New command |
---|---|
netsh firewall reset | netsh advfirewall reset |
例如 8︰ 启用特定服务
Old command | New command |
---|---|
netsh firewall set service FileAndPrint | netsh advfirewall firewall set rule group="File and Printer Sharing" new enable=Yes |
netsh firewall set service RemoteDesktop enable | netsh advfirewall firewall set rule group="remote desktop" new enable=Yes |
netsh firewall set service RemoteDesktop enable profile=ALL | Run the following commands:
netsh advfirewall firewall set rule group="remote desktop" new enable=Yes profile=domain netsh advfirewall firewall set rule group="remote desktop" new enable=Yes profile=private |
[转帖]Windows 使用netsh 命令行方式处理 windows防火墙的方法的更多相关文章
- ResHacker 用命令行方式修改 windows PE文件版本号
由于工作需要在詹金斯(genkins)集成环境打包,打包避免不了需要修改版本号,写入版本号最简单的方式通过修改windows rc文件 这就意味着,每次构建新版本前需要修改一次源文件 这个在用詹金斯集 ...
- 批处理脚本命令行方式关闭Windows服务
对于一些不常用的Windows Services,可以通过设置其启动类型为"禁用"而将其关闭.这种关闭方式是长期性的,电脑重启之后仍然起作用. 有时候希望在批处理脚本里通过命令行方 ...
- [转]Windows中使用命令行方式编译打包Android项目
http://my.oschina.net/liux/blog/37875 网上很多用Ant来编译打包Android应用的文章,毕竟Ant是纯Java语言编写的,具有很好的跨平台性.今天想写个纯win ...
- Windows Server 2016-命令行方式管理Windows服务
Microsoft Windows 服务(过去称为 NT 服务)允许用户创建可在其自身的 Windows 会话中长时间运行的可执行应用程序. 这些服务可在计算机启动时自动启动,可以暂停和重启,并且不显 ...
- Sqlserver 命令行方式修改 用户密码的方法
1. 之前写了一个 可以使用 ssms 的方式修改密码的情况 2. 还有办法是执行命令 exec sp_password null,'newpassword','sa' # sa 是用户名 newp ...
- 用命令行方式关闭linux防火墙
#/sbin/iptables -I INPUT -p tcp --dport 80 -j ACCEPT #/sbin/iptables -I INPUT -p tcp --dport 22 -j A ...
- 用命令行方式关闭CentOS防火墙
#/sbin/iptables -I INPUT -p tcp --dport 80 -j ACCEPT #/sbin/iptables -I INPUT -p tcp --dport 22 -j A ...
- 使用命令行方式运行 JMeter 脚本
For non-interactive testing, you may choose to run JMeter without the GUI. To do so, use the followi ...
- 玩转Windows服务系列——命令行管理Windows服务
说到Windows服务的管理就不得不说通过命令行的方式管理Windows服务,因为无论是系统管理员,还是通过编程的方式调用cmd命令,命令行都是非常方便以及强大的工具. 接下来就看一下如何通过cmd命 ...
随机推荐
- 恶意代码技术第一二部分——P201421410029
学 号:201421410029 中国人民公安大学 Chinese people’ public security university 网络对抗技术 实验报告 实验四 恶意代码技术 ...
- windows 下配置 Nginx 常见问题
因为最近的项目需要用到负载均衡,不用考虑,当然用大名鼎鼎的Nginx啦.至于Nginx的介绍,这里就不多说了,直接进入主题如何在Windows下配置. 我的系统是win7旗舰版的,到官网下载最新版本 ...
- 使用uploadify多文件上传,单个删除上传成功的图片
总体思路:在用uploadify上传成功一张图片,用js生成相应的元素,放到指定的位置,并且加上删除的标志.在保存的时候,把是img的所有的值,放到对应到字段里. jsp: <tr> &l ...
- VMware虚拟机下Linux系统的全屏显示
在VMware虚拟机下的Linux无法全屏的问题的解决方案如下: 1. 启动虚拟机,并启动Redhat6.4. 2. 点击“view”——然后将Autofit window这个选项勾选.(一般 ...
- WorldWind源码剖析系列:相机类CameraBase
相机基类CameraBase PluginSDK中的相机类CameraBase是三维计算机图形学中的概念.观察者在三维场景中漫游时,通过眼睛看到的场景和相机拍摄过程非常一致.实际上,Direct3D和 ...
- GitHub上最火的74个Android开源项目(三)
此前,推出的GitHub平台上“最受欢迎的开源项目”系列文章引发了许多读者的热议,在“GitHub上最火的40个Android开源项目(一).(二)中,我们也相继盘点了40个GitHub上最受欢迎的A ...
- 设置ssh key后push为什么还要输入用户名和密码
$ git push Username for 'https://github.com': Password for 'https://Username@github.com': Counting o ...
- 大数据入门第十四天——Hbase详解(一)入门与安装配置
一.概述 1.什么是Hbase 根据官网:https://hbase.apache.org/ Apache HBase™ is the Hadoop database, a distributed, ...
- vb6/ASP FORMAT MM/DD/YYYY
VB6或者ASP 格式化时间为 MM/dd/yyyy 格式,竟然没有好的办法, Format 或者FormatDateTime 竟然结果和系统设置的区域语言的日期和时间格式相关.意思是尽管你用诸如 F ...
- 20155209林虹宇 Exp7 网络欺诈防范
Exp7 网络欺诈防范 简单应用SET工具建立冒名网站 kali要作为web服务器让靶机访问冒名网站,所以要使用阿帕奇web服务器软件. 要阿帕奇使用80端口.进入配置文件/etc/apache2/p ...