Windows打开关闭防火墙
注:使用管理员权限打开cmd或者powershell
# 打开防火墙
netsh advfirewall set allprofiles state on
# 关闭防火墙
netsh advfirewall set allprofiles state off
windows 设置出入站规则
netsh advfirewall firewall add rule name=名字 dir=in action=allow protocol=协议 localport=端口
# advfirewall 高级防火墙功能
# firewall 防火墙
# add 添加新规则
# Rule 规则
# Name 规则的名字
# Dir 数据方向,in 表示进入 out 表示 发出
# action 动作 ,有 allow 允许 和 block 阻止
# protocol 协议 可以是 0-255|icmpv4|icmpv6|icmpv4:type,code|icmpv6:type,code|tcp|udp|any (default=any) 一般是TCP
# localport 本地使用的端口号
示例:
# 设置一个允许 HTTP 8080 端口的外来访问
netsh advfirewall firewall add rule name="Client Host Service" dir=in action=allow protocol=TCP localport=8080
netsh
advfirewall
查看防火墙现状 show