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

Unix/Linux
FreeBSD 数据转移办法
Freebsd 下运行QQ For Linux 的方法
FreeBSD, Debian, CentOS一个网卡绑定多个IP
freebsd下切换到root下 su: Sorry 的解决办法
Freebsd挂载光驱和软驱
FREEBSD下运行调试asterisk
一些 freebsd 的常用命令
笔记本上安装freebsd的小知识
FreeBSD系统下添加中文字体
FreeBSD挂载DOS分区,正确显示中文
FreeBSD挂载DOS分区时显示中文的方法
freebsd7.0安装系统图解(最新版)
服务器的时间同步设置方法
FreeBSD FTP 的架设教程
FreeBSD mpd VPN服务器安装步骤
更新FreeBSD Port Tree的几种方法小结
portupgrade 中文手册(翻译)
freebsd 服务器 ARP绑定脚本
在Ubuntu系统中定制 Compiz Fusion 特效
Ubuntu 7.10 绑定IP及MAC地址

Unix/Linux 中的 iptables 规则速查


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