<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="http://wiki.jackslab.org/skins/common/feed.css?303"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="zh-cn">
		<id>http://wiki.jackslab.org/index.php?action=history&amp;feed=atom&amp;title=Iptables</id>
		<title>Iptables - 版本历史</title>
		<link rel="self" type="application/atom+xml" href="http://wiki.jackslab.org/index.php?action=history&amp;feed=atom&amp;title=Iptables"/>
		<link rel="alternate" type="text/html" href="http://wiki.jackslab.org/index.php?title=Iptables&amp;action=history"/>
		<updated>2026-10-15T08:26:09Z</updated>
		<subtitle>本wiki的该页面的版本历史</subtitle>
		<generator>MediaWiki 1.19.2</generator>

	<entry>
		<id>http://wiki.jackslab.org/index.php?title=Iptables&amp;diff=15817&amp;oldid=prev</id>
		<title>Comcat：/* Reference */</title>
		<link rel="alternate" type="text/html" href="http://wiki.jackslab.org/index.php?title=Iptables&amp;diff=15817&amp;oldid=prev"/>
				<updated>2022-10-10T08:35:13Z</updated>
		
		<summary type="html">&lt;p&gt;‎&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Reference&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
			&lt;tr valign='top'&gt;
			&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;←上一版本&lt;/td&gt;
			&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;2022年10月10日 (一) 08:35的版本&lt;/td&gt;
			&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;第188行：&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;第188行：&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;== Reference ==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;== Reference ==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;* https://linuxbg.eu/books/Linux%20Iptables%20Pocket%20Reference.pdf&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;* https://www.cnblogs.com/foxgab/p/6896957.html&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;* https://www.cnblogs.com/foxgab/p/6896957.html&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;* https://www.cnblogs.com/foxgab/p/6904627.html&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;* https://www.cnblogs.com/foxgab/p/6904627.html&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Comcat</name></author>	</entry>

	<entry>
		<id>http://wiki.jackslab.org/index.php?title=Iptables&amp;diff=15816&amp;oldid=prev</id>
		<title>Comcat：/* Overview */</title>
		<link rel="alternate" type="text/html" href="http://wiki.jackslab.org/index.php?title=Iptables&amp;diff=15816&amp;oldid=prev"/>
				<updated>2022-10-10T08:35:01Z</updated>
		
		<summary type="html">&lt;p&gt;‎&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Overview&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
			&lt;tr valign='top'&gt;
			&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;←上一版本&lt;/td&gt;
			&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;2022年10月10日 (一) 08:35的版本&lt;/td&gt;
			&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;第1行：&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;第1行：&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;== Overview ==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;== Overview ==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;* https://linuxbg.eu/books/Linux%20Iptables%20Pocket%20Reference.pdf&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;5 个 &amp;quot;hook points&amp;quot; ('''Chain'''): &amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;5 个 &amp;quot;hook points&amp;quot; ('''Chain'''): &amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Comcat</name></author>	</entry>

	<entry>
		<id>http://wiki.jackslab.org/index.php?title=Iptables&amp;diff=15815&amp;oldid=prev</id>
		<title>Comcat：/* Overview */</title>
		<link rel="alternate" type="text/html" href="http://wiki.jackslab.org/index.php?title=Iptables&amp;diff=15815&amp;oldid=prev"/>
				<updated>2022-10-10T08:34:44Z</updated>
		
		<summary type="html">&lt;p&gt;‎&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Overview&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
			&lt;tr valign='top'&gt;
			&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;←上一版本&lt;/td&gt;
			&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;2022年10月10日 (一) 08:34的版本&lt;/td&gt;
			&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;第2行：&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;第2行：&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;* https://linuxbg.eu/books/Linux%20Iptables%20Pocket%20Reference.pdf&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;* https://linuxbg.eu/books/Linux%20Iptables%20Pocket%20Reference.pdf&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;[[iptables]]&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;5 个 &amp;quot;hook points&amp;quot; ('''Chain'''): &amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;5 个 &amp;quot;hook points&amp;quot; ('''Chain'''): &amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Comcat</name></author>	</entry>

	<entry>
		<id>http://wiki.jackslab.org/index.php?title=Iptables&amp;diff=15814&amp;oldid=prev</id>
		<title>Comcat：以“== Overview ==  * https://linuxbg.eu/books/Linux%20Iptables%20Pocket%20Reference.pdf  iptables  5 个 &quot;hook points&quot; ('''Chain'''):  * PREROUTING * POSTROUTING * ...”为内容创建页面</title>
		<link rel="alternate" type="text/html" href="http://wiki.jackslab.org/index.php?title=Iptables&amp;diff=15814&amp;oldid=prev"/>
				<updated>2022-10-10T08:34:32Z</updated>
		
		<summary type="html">&lt;p&gt;以“== Overview ==  * https://linuxbg.eu/books/Linux%20Iptables%20Pocket%20Reference.pdf  &lt;a href=&quot;/Iptables&quot; title=&quot;Iptables&quot;&gt;iptables&lt;/a&gt;  5 个 &amp;quot;hook points&amp;quot; (&amp;#039;&amp;#039;&amp;#039;Chain&amp;#039;&amp;#039;&amp;#039;):  * PREROUTING * POSTROUTING * ...”为内容创建页面&lt;/p&gt;
&lt;p&gt;&lt;b&gt;新页面&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
* https://linuxbg.eu/books/Linux%20Iptables%20Pocket%20Reference.pdf&lt;br /&gt;
&lt;br /&gt;
[[iptables]]&lt;br /&gt;
&lt;br /&gt;
5 个 &amp;quot;hook points&amp;quot; ('''Chain'''): &lt;br /&gt;
* PREROUTING&lt;br /&gt;
* POSTROUTING&lt;br /&gt;
* FORWARD  # that flow through a gateway computer, coming in one interface and going right back out another&lt;br /&gt;
&lt;br /&gt;
* INPUT    # just before they are delivered to a local process&lt;br /&gt;
* OUTPUT  #  just after they are generated by a local process&lt;br /&gt;
&lt;br /&gt;
选择 chain:&lt;br /&gt;
&lt;br /&gt;
If you want to filter outgoing packets, it is best to do so in the OUTPUT chain because the POSTROUTING chain is not associated with the filter table.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3 个内建 '''Tables''':&lt;br /&gt;
* filter （不用 -t 指定 table，则默认使用此 table）&lt;br /&gt;
* mangle&lt;br /&gt;
* nat&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Targets:'''&lt;br /&gt;
* -j 指定&lt;br /&gt;
* DNAT&lt;br /&gt;
** DNAT 模式用来做目的网络地址转换，比如把某个目的端口包都转发到内网的地址端口，可以做某种类型的负载平衡&lt;br /&gt;
** 一般挂在 PREROUTING chain of the nat table。&lt;br /&gt;
** Destination NAT (DNAT) exposes specific services on an internal network to the outside world without linking the internal computers directly to the Internet.&lt;br /&gt;
* SNAT (gateway computer has a static IP address)&lt;br /&gt;
** SNAT 模式用于源网络地址转换，就是重写包的源 IP 地址。比如内网多台机器通过一个网关上网，网关负责将内网 ip 重写为网关的公网 ip&lt;br /&gt;
** 一般挂在 POSTROUTING chain of the nat table。&lt;br /&gt;
** Source NAT (SNAT) is used to share a single Internet connection among computers on a network。&lt;br /&gt;
* MASQUERADE (gateway computer has a dynamic IP address)&lt;br /&gt;
&lt;br /&gt;
* ACCEPT&lt;br /&gt;
* REDIRECT&lt;br /&gt;
* DROP&lt;br /&gt;
* QUEUE&lt;br /&gt;
* RETURN&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== 开启 ip4 forward ==&lt;br /&gt;
&lt;br /&gt;
Command line:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=bash&amp;gt;&lt;br /&gt;
$ sysctl -w net.ipv4.ip_forward=1&lt;br /&gt;
# 查看&lt;br /&gt;
$ sysctl -p&lt;br /&gt;
&lt;br /&gt;
# or &lt;br /&gt;
$ echo 1 &amp;gt; /proc/sys/net/ipv4/ip_forward&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Configuration:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=bash&amp;gt;&lt;br /&gt;
$ sudo vim /etc/sysctl.conf&lt;br /&gt;
&lt;br /&gt;
# Uncomment the next line to enable packet forwarding for IPv4&lt;br /&gt;
#net.ipv4.ip_forward=1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== 实例 ==&lt;br /&gt;
&lt;br /&gt;
网关端口映射到内网：&lt;br /&gt;
&amp;lt;source lang=bash&amp;gt;&lt;br /&gt;
$ iptables -t nat -A PREROUTING -i eth1 -p tcp --dport 80 -j DNAT --to-destination 192.168.1.87:8080&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
共享网关公网地址入网：&lt;br /&gt;
&amp;lt;source lang=bash&amp;gt;&lt;br /&gt;
# static ip&lt;br /&gt;
$ iptables -t nat -A POSTROUTING -o eth1 -j SNAT&lt;br /&gt;
&lt;br /&gt;
# dynamic IP&lt;br /&gt;
$ iptables -t nat -A POSTROUTING -o eth1 -j MASQUERADE&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If you have an HTTP proxy (such as Squid) configured to run as a transparent proxy on your firewall computer and listen on port 8888, you can add one rule to redirect outbound HTTP traffic to the HTTP proxy:&lt;br /&gt;
&amp;lt;source lang=bash&amp;gt;&lt;br /&gt;
$ iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 8888&lt;br /&gt;
# iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-ports 6666&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
将测试网段的端口的包转发到本机端口，其他网段则正常访问原端口：&lt;br /&gt;
&amp;lt;source lang=bash&amp;gt;&lt;br /&gt;
$ iptables -t nat -A PREROUTING -p tcp -s 192.168.10.0/24 --dport 1234 -j REDIRECT --to-ports 6666&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
端口转发，将源为 A 访问 B 的 1234 端口的包，转发到 C 的 6666 端口，其他的不管：&lt;br /&gt;
&amp;lt;source lang=bash&amp;gt;&lt;br /&gt;
$ iptables -t nat -A PREROUTING -s 192.168.10.2 -p tcp --dport 1234 -j DNAT --to-destination 192.168.10.6:6666 &lt;br /&gt;
$ iptables -t nat -A POSTROUTING --dst 192.168.10.2 -p tcp --dport 6666 -j MASQUERADE&lt;br /&gt;
&lt;br /&gt;
# 将目的端口 82 的包，全部转发到 xx.xx.xx.xx:83&lt;br /&gt;
$ iptables -t nat -I PREROUTING -p tcp --dport 82 -j DNAT --to-destination  xx.xx.xx.xx:83&lt;br /&gt;
$ iptables -t nat -I POSTROUTING -d  xx.xx.xx.xx  -p tcp --dport 83 -j MASQUERADE    # 目标为 xx.xx.xx.xx:83 的 tcp 包，自动获取当前网卡的 IP 地址进行源地址转换&lt;br /&gt;
&lt;br /&gt;
$ iptables -t nat -I POSTROUTING -j MASQUERADE    # 自动获取当前网卡的 IP 地址进行源地址转换&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
* -s [!] addr[/mask]  &amp;lt;===&amp;gt; --src &amp;lt;===&amp;gt; --source&lt;br /&gt;
* -d [!] addr[/mask]  &amp;lt;===&amp;gt; --dst &amp;lt;===&amp;gt; --destination&lt;br /&gt;
* DNAT 模式用来做目的网络地址转换，比如把某个目的端口包都转发到内网的地址端口，可以做某种类型的负载平衡。Destination NAT (DNAT) exposes specific services on an internal network to the outside world without linking the internal computers directly to the Internet.&lt;br /&gt;
* SNAT 模式用于源网络地址转换，就是重写包的源 IP 地址。一般挂在 POSTROUTING chain of the nat table。Source NAT (SNAT) is used to share a single Internet connection among computers on a network。&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
保存规则：&lt;br /&gt;
&amp;lt;source lang=bash&amp;gt;&lt;br /&gt;
$ service iptables save &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
关闭端口转发：&lt;br /&gt;
&amp;lt;source lang=bash&amp;gt;&lt;br /&gt;
$ service iptables stop&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== 策略 ==&lt;br /&gt;
&lt;br /&gt;
'''显示：'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=bash&amp;gt;&lt;br /&gt;
$ iptables [-t table] -S [chain]&lt;br /&gt;
$ iptables -t nat -S PREROUTING    # 显示指定的 chain 中当前生效的策略，如果不指定 chain，那么显示 table 中所有的 chain，如果不指定 table，默认为 filter table&lt;br /&gt;
$ iptables-save    # 显示所有 iptables 中生效的策略&lt;br /&gt;
&lt;br /&gt;
$ iptables [-t table] -L [-v] [-n] [--line-number ]    # 按照表格形式显示当前生效策略的方法&lt;br /&gt;
$ iptables -t nat -L -n --line-number&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* -L -n 等同于 -nL, --line 等同于 --line-number&lt;br /&gt;
* 使用 -v 参数可以显示额外的进出接口、包和流量统计信息。&lt;br /&gt;
* 使用 -n 参数表示用数字表示IP和端口号，默认会尝试查找 dns&lt;br /&gt;
* 使用 --line-number 参数显示策略行号，可以在插入、修改策略时用此参数查看 rule-num&lt;br /&gt;
* 可简写为： -nvL&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''追加：'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=bash&amp;gt;&lt;br /&gt;
$ iptables [-t table] -A chain rule-specification&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''插入：'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=bash&amp;gt;&lt;br /&gt;
$ iptables [-t table] -I chain [rule-num] rule-specification&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''删除：'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=bash&amp;gt;&lt;br /&gt;
$ iptables [-t table] -D rule-num&lt;br /&gt;
$ iptables -t nat -D PREROUTING 2&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''修改：'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=bash&amp;gt;&lt;br /&gt;
$ iptables [-t table] -R chain rule-num rule-specification&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''设置默认：'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=bash&amp;gt;&lt;br /&gt;
$ ipables [-t table] -P target&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
在 filter table 中，target 可以是 DROP 或者 ACCEPT，其它 table 默认都是 ACCEPT，貌似无法修改（存疑）&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Reference ==&lt;br /&gt;
&lt;br /&gt;
* https://www.cnblogs.com/foxgab/p/6896957.html&lt;br /&gt;
* https://www.cnblogs.com/foxgab/p/6904627.html&lt;br /&gt;
* https://blog.csdn.net/Criss_Leung/article/details/77988864&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Comcat</name></author>	</entry>

	</feed>