ebtables 用法

ebtables是一个用于设置和维护以太网帧(Ethernet frames)规则表的应用程序。
其中有三个主要的概念:表(tables)、链(chains)、目标(targets)

# 链(chains)
每组规则称为链,每个链都是一个有序的规则列表,可以匹配以太网帧。
如果一个规则匹配到一个以太网帧,那么有一个处理规范告诉我们如何匹配到的帧,这个处理规范称为目标(targets)
如果以太网帧没有匹配到当前的规则,就会去检查下一个规则。

# 目标(targets)
防火墙规则指定以太网帧和一个称为目标的帧处理规范的标准。
当帧匹配一个规则(rule)时,下一个动作(action)由target指定。
targets由四个:
(1)ACCEPT:意味着让一个帧通过
(2)DROP:意味着帧已经被dropped。在BROUTING chain中,(1)(2)有特殊的意思
(3)CONTINUE:意味着下一个规则(rule)将被检查
(4)RETURN:意味着停止遍历此链,并在前一个调用链的下一条规则中恢复。

# 表(tables)
Linux内核中有三个内建的ebtables 表(filter,nat,broute),这些表用于将功能划分为不同的规则集。
(1)filter 是默认的表,包含三个内建的chains:
INPUT(对于已经决定的帧,在MAC目的地址层)
OUTPUT(对于局部产生的或(b)routed 帧)
FORWARD(对于由bridge传输的帧)
(2)nat 经常用于改变MAC地址,包含三个内建的chains:
PREROUTING(为了改变帧当它们已进入)
OUTPUT(为了改变局部产生的或(b)routed 帧 ,在它们被bridge之前)
POSTROUTING(为了改变帧,在它们出去的时候)
(3)broute 用于产生一个桥路器(brouter),包含一个内建chain:
BROUTING 在最早的地方遍历,只能在帧以forwarding状态进入到bridge port的时候才会被遍历。
target DROP和ACCEPT在broute表中有特殊的含义。DROP表示帧已经被route;ACCEPT表示帧已经被bridge

# 用法
ebtables [-t table ] -[ACDI] chain rule specification [match extensions] [watcher extensions] target    // append, delete, change-counters, insert
ebtables [-t table ] -P chain ACCEPT | DROP | RETURN                                                                      // policy, Set the policy for the chain to the given target
ebtables [-t table ] -F [chain]                                                                                                           // flush, Flush the selected chain
ebtables [-t table ] -Z [chain]                                                                                                           // zero, Set the counters of the selected chain to zero
ebtables [-t table ] -L [-Z] [chain] [ [--Ln] | [--Lx] ] [--Lc] [--Lmac2]                                                  // list, List all rules in the selected chain. If no chain is selected, all chains are listed.
                              // -L -Z , When both the -Z and -L commands are used together in this way, the rule counters are printed on the screen before they are set to zero.
                              // -L --Ln, Shows the counters at the end of each rule displayed by the -L command.
ebtables [-t table ] -N chain [-P ACCEPT | DROP | RETURN]                                                               // new-chain
ebtables [-t table ] -X [chain]                                                                                                           // delete-chain
ebtables [-t table ] -E old-chain-name new-chain-name                                                                    // rename-chain
ebtables [-t table ] --init-table                                                                                                         // Replace the current table data by the initial table data
ebtables [-t table ] [--atomic-file file] --atomic-commit
ebtables [-t table ] [--atomic-file file] --atomic-init
ebtables [-t table ] [--atomic-file file] --atomic-save

参考文献



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值