1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
| 需求1:禁止web端访问server端和client端 + 禁止web端访问server端 --- 本机处理 iptables -t filter -A INPUT -s 10.10.10.10 -j DROP + 禁止web端访问client端 --- 不是本机处理 iptables -t filter -A FORWARD -s 10.10.10.10 -j DROP
需求2:①只允许server端ping通其他主机,不允许其他主机ping通server端 ②允许client端ping通web端,不允许web端ping通client端 iptables -P INPUT DROP iptables -t filter -A INPUT -p icmp --icmp-type 0 -j ACCEPT - 0 应答包 | 8 请求包
iptables -P FORWARD DROP iptables -t filter -A FORWARD -s 192.168.10.1 -p icmp --icmp-type 8 -j ACCEPT iptables -t filter -A FORWARD -p icmp --icmp-type 0 -j ACCEPT
需求3:禁止web端访问client端的80和22号端口 iptables -t filter -A FORWARD -s 10.10.10.10 -p tcp --dport 80 -j DROP iptables -t filter -A FORWARD -s 10.10.10.10 -p tcp --dport 22 -j DROP iptables -t filter -A FORWARD -s 10.10.10.10 -p tcp -m multiport --dports 80,22 -j DROP - multiport模块优化规则,减少匹配量
需求4:禁止10.10.10.1 – 10.10.10.20网段内的主机访问server端的22和80号端口 iptables -t filter -A INPUT -m iprange --src-range 10.10.10.1-10.10.10.20 -p tcp -m multiport --dports 80,22 -j DROP - iprange模块优化规则,减少匹配量
需求5:只开放主机server端的FTP服务 vim /etc/sysconfig/iptables-config IPTABLES_MODULES="nf_conntrack_ftp"
iptables -P INPUT DROP iptables -t filter -A INPUT -p tcp --dport 20:21 -j ACCEPT iptables -t filter -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT - RELATED --- 基于原来的连接状态,再次建立连接
- https://www.zsythink.net/archives/tag/iptables/
|