在控制之下用 习惯链保存你的防火墙规则
预先设定地
,
iptables 过滤器桌子由~所组成三链
: 输入
,转寄
, 和输出
. 你能同样地增加许多习惯当你喜欢帮助,用铁链锁住单一化管理大的规则组合
. 习惯链正如举止如内建的链
, 介绍一定被经过的逻辑在储存器的终极命运是坚决的之前
.
产生新的链,使用那 -N 开关:
root@mouse:~# iptables -L
Chain INPUT (policy ACCEPT)
target prot opt source destination
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
Chain fun-filter (0 references)
target prot opt source destination
为了要利用你的习惯链,你将会必须从某处跳到它. 让我们把一次跳跃加入乐趣- 过滤器用铁链锁住我们仅仅有产生来自输入链的直线:
root@mouse:~# iptables -A fun-filter -m mac -- mac-source 11:22:33:aa:bb:cc \
-j ACCEPT
root@mouse:~# iptables -A fun-filter -m mac -- mac-source de:ad:be:ef:00:42 \
-j ACCEPT
root@mouse:~# iptables -A fun-filter -m mac -- mac-source 00:22:44:fa:ca:de
-j REJECT -- reject-with icmp-host-unreachable
root@mouse:~# iptables -A fun-filter -j RETURN
回行的跳跃在~结束的时候桌子制造在叫做了这一个的链中处理履历表背面(在这情况,在输入链中回). 再一次, 表演你的全部桌子所看起来像的由于那 -L 开关:
root@mouse:~# iptables -L
Chain INPUT (policy ACCEPT)
target prot opt source destination
fun-filter all -- anywhere anywhere
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
Chain fun-filter (0 references)
target prot opt source destination
ACCEPT all -- anywhere anywhere MAC 11:22:33:AA:BB:CC
ACCEPT all -- anywhere anywhere
MAC
DE
:AD:BE:EF:00:42
REJECT all -- anywhere anywhere MAC 00:22:44:FA:CA:DE reject-with icmp-host-
unreachable
RETURN all -- anywhere anywhere所有的回返
-- 无论何处的无论何处
你能进入被定义链和甚至在他们之间跳跃的习惯任何的数字之内跳跃. 这有助於隔离你正在从标准的系统政策规则发展, 而且容易地使并且使失去能力能够他们的规则. 如果你想要停止暂时使用你的习惯链, 你能只是从~划除跳跃输入链 ( 并非脸发红整个的习惯链):
root@mouse:~# iptables -t filter -D INPUT -j fun-filter
如果你决定划除你的习惯链,使用 -X:
root@mouse:~# iptables -X fun-filter
注意能有是否你试着去划除它,不 关於~的任何叁考~你的习惯用铁链锁住
; 使用
- F 首先脸发红链是否仍然有规则表示
你的链
.
当适当地处理,是否你直觉的使用命名习惯链,甚至最复杂的 iptables rulesets 可能是容易地读.