当前位置: 首页 > 图文教程 > 操作系统 > Unix/Linux > iptables 规则速查

Unix/Linux
PostgreSQL Hardware Performance Tuning
Firefox 1.0.6简体中文版发布,提供下载
包过滤防火墙配置实例.
linux中的时间流
Rsync Server +Rsync client 配置完全实践笔记
mysql数据库root口令忘记自动恢复脚本
自动修改linux下的网卡ip和掩码脚本
将指定文件列表中的文件内容逐个替换成想要的内容的小脚本
用nmap扫描端口并写到一个静态网页脚本(转贴)
配置xdm远程连接
解决如何修改mysql服务器监听端口的问题。
CC2001关于计算机科学的教学大纲
Linux命令Man解释:losetup:设定与控制loopdevices
Linux网管123---第6章.一般系统管理问题-2.建立使用者帐号
汉化你的RedHat全攻略(4)-FAQ和一些总结
"/dev/tty0"不见了怎麽救回来?
/dev下cua*被删除,该如何恢复?
Linux网管123---第7章.自订的组态及管理内容-1.HTTP
vi介绍编(2)参数简介
Linux命令Man解释:mkfs:建立linux文件系统

Unix/Linux 中的 iptables 规则速查


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-01   浏览: 106 ::
收藏到网摘: n/a


iptables的命令规则速查,没有为了方便
iptables -A INPUT -p TCP --dport 22 -j ULOG --ulog-nlgroup 2iptables -A INPUT -p TCP --dport 22 -j ULOG \ --ulog-prefix "SSH connection attempt: "iptables -A INPUT -p TCP --dport 22 -j ULOG --ulog-cprange 100iptables -A INPUT -p TCP --dport 22 -j ULOG --ulog-qthreshold 10
通用匹配:! 表取反options: -p, --protocolexample: iptables -A INPUT -p tcpcomment: 不分大小写,缺省ALL。[协议列表: -p tcp,udp,icmp;取反: -p ! tcp]options: -s, --src, --sourceexample: iptables -A INPUT -s 192.168.1.1comment: 单个,如192.168.1.1或192.168.1.1/255.255.255.255或192.168.1.1/32 网络,如192.168.0.0/24或192.168.0.0/255.255.255.0options: -d, --dst, --destinationexample: iptables -A INPUT -d 192.168.1.1comment: 同 -soptions: -i, --in-interfaceexample: iptables -A INPUT -i eth0comment: 只能用于INPUT,FORWARD, PREROUTING这三个链。 接口名称,如:eth0、ppp0等。 通配符+,-i + 匹配所有的包。-i eth+ 所有Ethernet接口。options: -o, --out-interfaceexample: iptables -A FORWARD -o eth0comment: 同 -ioptions: -f, --fragmentexample: iptables -A INPUT ! -fcomment: 用来匹配一个被分片的包的第二片或及以后的部分。(注意碎片攻击)TCP 匹配:options: --sport, --source-portexample: iptables -A INPUT -p tcp --sport 22comment: 默认所有端口。连续端口 22:80,80:22,[0]:80,22:[65535], ! 22:80options: --dport, --destination-portexample: iptables -A INPUT -p tcp --dport 22comment: 默认所有端口。连续端口 22:80,80:22,[0]:80,22:[65535], ! 22:80options: --tcp-flagsexample: iptables -p tcp --tcp-flags SYN,FIN,ACK SYNcomment: --tcp-flags ALL NONE匹配所有标记都未置1的包。UDP 匹配:options: --sport, --source-portexample: iptables -A INPUT -p udp --sport 22comment: 同 tcpoptions: --dport, --destination-portexample: iptables -A INPUT -p udp --dport 22comment: 同 tcpICMP匹配:options: --icmp-typeexample: iptables -A INPUT -p icmp --icmp-type 8comment: iptables --protocol icmp --help 查看类型显式匹配:iptables -A INPUT -m limit --limit 3/houriptables -A INPUT -m limit --limit-burst 5iptables -A INPUT -m mac --mac-source 00:00:00:00:00:01iptables -t mangle -A INPUT -m mark --mark 1iptables -A INPUT -p tcp -m multiport --source-port 22,53,80,110iptables -A INPUT -p tcp -m multiport --destination-port 22,53,80,110iptables -A INPUT -p tcp -m multiport --port 22,53,80,110iptables -A OUTPUT -m owner --uid-owner 500iptables -A OUTPUT -m owner --gid-owner 0iptables -A OUTPUT -m owner --pid-owner 78iptables -A OUTPUT -m owner --sid-owner 100iptables -A INPUT -m state --state RELATED,ESTABLISHED iptables -A INPUT -p tcp -m tos --tos 0x16iptables -A OUTPUT -m ttl --ttl 60目标和动作:iptables -N tcp_packetsiptables -A INPUT -p tcp -j tcp_packetsiptables -A INPUT -p tcp -j ACCEPTiptables -A INPUT -p tcp -j DROPiptables -t nat -A PREROUTING -p tcp -d 15.45.23.67 --dport 80 \ -j DNAT --to-destination 192.168.1.1-192.168.1.10 iptables -A FORWARD -p tcp -j LOG --log-level debug iptables -A INPUT -p tcp -j LOG --log-prefix "INPUT packets"iptables -A INPUT -p tcp -j LOG --log-tcp-sequenceiptables -A FORWARD -p tcp -j LOG --log-tcp-optionsiptables -A FORWARD -p tcp -j LOG --log-ip-optionsiptables -t mangle -A PREROUTING -p tcp --dport 22 -j MARK --set-mark 2iptables -t nat -A POSTROUTING -p TCP -j MASQUERADE --to-ports 1024-31000iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-ports 8080iptables -A FORWARD -p TCP --dport 22 -j REJECT --reject-with tcp-resetiptables -t nat -A POSTROUTING -p tcp -o eth0 -j SNAT \ --to-source 194.236.50.155-194.236.50.160:1024-32000 iptables -t mangle -A PREROUTING -p TCP --dport 22 -j TOS --set-tos 0x10iptables -t mangle -A PREROUTING -i eth0 -j TTL --ttl-set 64iptables -t mangle -A PREROUTING -i eth0 -j TTL --ttl-dec 1iptables -t mangle -A PREROUTING -i eth0 -j TTL --ttl-inc 1iptables -A INPUT -p TCP --dport 22 -j ULOG --ulog-nlgroup 2iptables -A INPUT -p TCP --dport 22 -j ULOG \ --ulog-prefix "SSH connection attempt: "iptables -A INPUT -p TCP --dport 22 -j ULOG --ulog-cprange 100iptables -A INPUT -p TCP --dport 22 -j ULOG --ulog-qthreshold 10参考文献: Iptables homepageIptables Tutor