iptables添加IP段白名单
生活随笔
收集整理的這篇文章主要介紹了
iptables添加IP段白名单
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
背景
要求指定的IP段才能訪問主機的 3306 端口
安裝iptables
yum install -y iptables-services systemctl enable iptables service iptables start添加IP段白名單
iptables -I INPUT -p tcp --dport 3306 -j DROP && \ iptables -I INPUT -m iprange --src-range 172.50.49.13-172.50.49.42 -p tcp --dport 3306 -j ACCEPT && \ iptables -I INPUT -m iprange --src-range 172.29.145.10-172.29.145.40 -p tcp --dport 3306 -j ACCEPT三條命命令的含義
iptables -I INPUT -p tcp --dport 3306 -j DROP 禁止訪問呢3306
iptables -I INPUT -m iprange --src-range 172.50.49.13-172.50.49.42 -p tcp --dport 3306 -j ACCEPT 允許172.50.49.13-172.50.49.42 段的IP訪問3306
iptables -I INPUT -m iprange --src-range 172.29.145.10-172.29.145.40 -p tcp --dport 3306 -j ACCEPT 允許172.29.145.10-172.29.145.40 段的IP訪問3306
添加一整段IP白名單
iptables -I INPUT -p tcp -s 10.178.0.0/16 -j ACCEPT表示 10.178 開頭的IP都加入白名單
使其生效
systemctl reload iptables service iptables save總結
以上是生活随笔為你收集整理的iptables添加IP段白名单的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: IP白名单校验工具
- 下一篇: ZooKeeper设置ACL权限控制--