小编Jam*_*son的帖子

如何仅允许某些 IPSet 集使用 iptables 访问某个端口?

我正在使用 IPSet 为不同国家/地区构建 IP 范围,如下所示:

# Canada
ipset -F ca.zone
ipset -N ca.zone nethash
for IP in $(wget -O - http://www.ipdeny.com/ipblocks/data/countries/ca.zone)
        do ipset -A ca.zone $IP 
        echo $IP
done
Run Code Online (Sandbox Code Playgroud)

然后,我使用以下 iptables 规则从服务器上的某些端口阻止这些国家/地区:

iptables -A INPUT -m set --match-set fr.zone src -p tcp --dport 15765 -j DROP
iptables -A INPUT -m set --match-set cn.zone src -p tcp --dport 15765 -j DROP
iptables -A INPUT -m set --match-set ca.zone src -p tcp --dport 16247 -j DROP
iptables -A INPUT -m set --match-set …
Run Code Online (Sandbox Code Playgroud)

networking linux firewall iptables ipsec

6
推荐指数
1
解决办法
7186
查看次数

标签 统计

firewall ×1

ipsec ×1

iptables ×1

linux ×1

networking ×1