开放被动模式FTP服务:
(1)装载ftp追踪时的专用的模块:
#modprobe nf_conntrack_ftp
(2)放行请求报文:
命令连接:NEW,ESTABLISHED
数据连接:RELATED,ESTABLISHED
# iptables -A INPUT -d LocalIP -p tcp --dport 21 -m state --stateNEW,ESTABLISHED -j ACCEPT
# iptables -A INPUT -d LocalIP -p tcp -m state --stateRELATED,ESTABLISHED -j ACCEPT
(3) 放行响应报文:
ESTABLISEHD
# iptables -A OUTPUT -s LocalIP -p tcp -m state --state ESTABLISHED -jACCEPT
保存及重载规则:
保存规则至指定文件:
iptables-save > /PATH/TO/SOMEFILE
从指定文件重载规则:
iptables-restore < /PATH/FROM/SOMEFILE
CentOS6:
service iptables save
iptables-save > /etc/sysconfig/iptables
service iptables restart
iptables-restore < /etc/sysconfig/iptables
CentOS7:
引入了新的iptables前端管理服务工具:firewalld
firewalld-cmd
firewalld-config
关于firewalld:
http://www.ibm.com/developerworks/cn/linux/1507_caojh/index.html