使用命令添加window和Linux端口规则和ip规则iptables ,netsh advfirewall firewall

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)

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值