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

Unix/Linux
Ubuntu Linux有多流行?数据告诉你
轻松制作Linux系统启动盘的四种方法
忘记Linux密码后的另类解决方法
Linux中安装Realplayer的方法
Linux桌面环境GNOME和KDE的切换
在Linux操作系统下安装与运行GAMIT软件
学习Linux系统的九条忠告
Linux系统发展空间探索
Linux与Windows Vista系统的比较
Linux刷新主板BIOS的好方法
Linux下学C语言开发要学些什么
Ubuntu 8.04 Alpha 3新功能初体验
Ubuntu Linux下用Firefox来安装软件
客户对Linux电脑的需求的确不高
带你一起认识下linux的各种版本
手把手教你学Ubuntu
双系统卸载linux系统的方法
linux系统下的U盘病毒清除法
Linux系统22端口修改的方法
理解和掌握Linux 体验Linux的方式

Unix/Linux 中的 iptables 规则速查


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-01   浏览: 54 ::
收藏到网摘: 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