windows开放和关闭防火墙端口

进入cmd或者powershell命令行

netsh /?

#查看netsh系统帮助文件
#netsh命令的子参数中有两个命令是防火墙相关的:
#firewall:防火墙配置的简单模式
#advfirewall:防火墙配置的高级模式

防火墙配置的简单模式:firewall

#防火墙开放21号端口
netsh firewall set portopening tcp 21 enable 
#防火墙关闭21号端口
netsh firewall delete portopening protocol=TCP port=3389

防火墙配置的高级模式:advfirewall

#防火墙开放21端口
netsh advfirewall firewall add rule name=peter的ftp dir=in action=allow protocol=TCP localport=21

#防火墙删除21端口
netsh advfirewall firewall delete rule name=peter的ftp protocol=tcp localport=21

这种方式和手动在 高级windows defender 防火墙是一样的

猜你喜欢

转载自blog.csdn.net/qq_23587541/article/details/86521411