本文章仅作为个人笔记
- iptables相关:(更改完配置需运行/etc/rc.d/init.d/iptables save及service iptables restart使配置生效)
- iptables-save (保存当前更改好的防火墙规则,更改规则后一定记得最后运行,否则会导致重启后配置丢失)
- iptables -L(列出当前防火墙规则)
- iptables -F (清除预设表filter中的所有规则链的规则)
- iptables -X (清除预设表filter中使用者自定链中的规则)
- iptables -P [INPUT/OUTPUT/FORWARD] [DROP/ACCEPT]
- iptables -A [INPUT/OUTPUT/FORWARD] -p tcp –dport [0-n] -j [DROP/ACCEPT]
- 允许icmp包通过即允许ping
- iptables -A OUTPUT -p icmp -j ACCEPT
- iptables -A INPUT -p icmp -j ACCEPT
- 只允许指定ip访问某端口(例:指定172.31.18.47访问6379端口)
- iptables -I INPUT -p tcp –dport 6379 -j DROP
- iptables -I FORWARD -p tcp –dport 6379 -j DROP
- iptables -I INPUT -s 172.31.18.47/24 -p tcp –dport 6379 -j ACCEPT
- iptables -I FORWARD -s 172.31.18.47/24 -p tcp –dport 6379 -j ACCEPT
- 关闭防火墙
- systemctl stop firewalld.service
- systemctl disable firewalld.service