Old command 针对win7以下版本<包含win7>

Example 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

Example 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

Example 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 nameprotocol=udp localport=500

Example 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

Example 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 droppedconnections enable

netsh advfirewall set currentprofile logging allowedconnections enable

Example 6:启动防火墙

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

For more information, run the following command:

netsh advfirewall set currentprofile ?

Example 7: 恢复默认防火墙策略

Old command

New command

netsh firewall reset

netsh advfirewall reset

查看更多的信息,运行以下命令

netsh advfirewall reset ?

Example 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

最新文章

  1. display:inline-block会产生空隙
  2. MVC缓存02,使用数据层缓存,添加或修改时让缓存失效
  3. 转载:python发送HTTP请求
  4. 火狐和IE的window.event对象详解(转载)
  5. 服务接口API限流 Rate Limit
  6. 跨平台移动开发工具:PhoneGap与Titanium全方位比拼
  7. hdu 4848 搜索+剪枝 2014西安邀请赛
  8. SpringBoot 整合Dubbo
  9. mysql中Table is read only的解决方法
  10. Java bean 转 Map
  11. 机器学习总结(二)bagging与随机森林
  12. linux指令(1)
  13. Python基于Python实现批量上传文件或目录到不同的Linux服务器
  14. MATLAB 统计不同区间中元素的个数
  15. 数据源从druid迁移到HikariCP
  16. ul+li水平居中的几种方法
  17. nginx支持HTTP2的配置过程
  18. [vuejs] 深入响应式原理
  19. FIR滤波原理及verilog设计
  20. 【转载】oracle索引详解2

热门文章

  1. WebSocket IO和后端建立长连接,即时接受后端消息
  2. Rsyslog配置文件详解
  3. RML-怎样的语句会被归纳为同一类型(Unique Batches)
  4. Knockout.js是什么?
  5. oracle重建控制文件
  6. Bug测试报告--在线考试系统--金州勇士
  7. Eclipse中实现JAVA代码的自动提示功能
  8. C#中把Datatable转换为Json的5个代码实例
  9. SpringMVC访问静态资源的三种方式(转)
  10. Events in ASP.NET Master and Content Pages