windows添加端口规则(入站规则):

单个端口:

 netsh advfirewall firewall add rule name ="1111111111111" dir=in localport=8888 protocol=tcp action=allow

 netsh advfirewall firewall add rule name=1111111111111 dir=in localport=111 protocol=TCP action=allow

端口段:

(放行):

netsh advfirewall firewall add rule name=111111111111端口段 dir=in localport=111-222 protocol=TCP action=allow

(拦截):

netsh advfirewall firewall add rule name=111111111111端口段 dir=in localport=111-222 protocol=TCP action=block

 

Linux添加端口规则:

单个端口:   iptables -A INPUT -p TCP --dport 1111 -j ACCEPT

端口段:       iptables -A INPUT -p TCP --dport 111:222 -j ACCEPT

拦截: iptables -A INPUT -p TCP --dport 111:222 -j REJECT

 

 

windows添加ip规则(入站):

netsh advfirewall firewall add rule name=测试规则放行192.168.0.10 protocol=any dir=in action=allow remoteip=192.168.0.10

 

linux添加ip规则:

(单个ip放行)iptables -I INPUT -s 192.168.0.10 -j ACCEPT

(ip段拦截)iptables -I INPUT -s 192.168.0.0/24 -j DROP

 

注意:Linux每次都需要重启防火墙

           windows的端口写法是111-222,linux是111:222

参考:https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2008-R2-and-2008/dd734783(v=ws.10)

GitHub 加速计划 / li / linux-dash
6
1
下载
A beautiful web dashboard for Linux
最近提交(Master分支:3 个月前 )
186a802e added ecosystem file for PM2 4 年前
5def40a3 Add host customization support for the NodeJS version 4 年前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐