iptables规则

屏蔽无关端口号

ipset create allowed_ips hash:net   #创建ipset存储白名单

iptables -A INPUT -m set --match-set allowed_ips src -j ACCEPT  #允许白名单内的所有ip访问
iptables -A INPUT -j REJECT #拒绝非白名单内的ip

ipset add allowed_ips 172.37.47.74  #添加ip
ipset add allowed_ips 172.37.47.75
ipset add allowed_ips 10.233.0.0/16
ipset add allowed_ips 10.234.0.0/16
......

##后续如果不需要了,则删除ipset和规则
iptables -D INPUT  xxxx       #先删规则
ipset  destroy allowed_ips    #删除ipset 

ipset  list  allowed_ips            #查看ip列表
ipset  del   allowed_ips  x.x.x.x   #删除某条ip

 

© 版权声明
THE END
喜欢就支持一下吧
点赞0 分享
评论 抢沙发
头像
欢迎您留下宝贵的见解!
提交
头像

昵称

取消
昵称表情代码图片

    暂无评论内容