Busybox: Upgrade to 1.21.1 (stable). lsof active.
[tomato.git] / release / src / router / ebtables / ebtables.8
blobf9b72345f77db7b59fd7104103f30861edffbd95
1 .TH EBTABLES 8  "July 2011"
2 .\"
3 .\" Man page written by Bart De Schuymer <bdschuym@pandora.be>
4 .\" It is based on the iptables man page.
5 .\"
6 .\" The man page was edited, February 25th 2003, by 
7 .\"      Greg Morgan <" dr_kludge_at_users_sourceforge_net >
8 .\"
9 .\" Iptables page by Herve Eychenne March 2000.
10 .\"
11 .\"     This program is free software; you can redistribute it and/or modify
12 .\"     it under the terms of the GNU General Public License as published by
13 .\"     the Free Software Foundation; either version 2 of the License, or
14 .\"     (at your option) any later version.
15 .\"
16 .\"     This program is distributed in the hope that it will be useful,
17 .\"     but WITHOUT ANY WARRANTY; without even the implied warranty of
18 .\"     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19 .\"     GNU General Public License for more details.
20 .\"
21 .\"     You should have received a copy of the GNU General Public License
22 .\"     along with this program; if not, write to the Free Software
23 .\"     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 .\"     
25 .\"
26 .SH NAME
27 ebtables (v2.0.10-2) \- Ethernet bridge frame table administration
28 .SH SYNOPSIS
29 .BR "ebtables " [ -t " table ] " - [ ACDI "] chain rule specification [match extensions] [watcher extensions] target"
30 .br
31 .BR "ebtables " [ -t " table ] " -P " chain " ACCEPT " | " DROP " | " RETURN
32 .br
33 .BR "ebtables " [ -t " table ] " -F " [chain]"
34 .br
35 .BR "ebtables " [ -t " table ] " -Z " [chain]"
36 .br
37 .BR "ebtables " [ -t " table ] " -L " [" -Z "] [chain] [ [" --Ln "] | [" --Lx "] ] [" --Lc "] [" --Lmac2 ]
38 .br
39 .BR "ebtables " [ -t " table ] " -N " chain [" "-P ACCEPT " | " DROP " | " RETURN" ]
40 .br
41 .BR "ebtables " [ -t " table ] " -X " [chain]"
42 .br
43 .BR "ebtables " [ -t " table ] " -E " old-chain-name new-chain-name"
44 .br
45 .BR "ebtables " [ -t " table ] " --init-table
46 .br
47 .BR "ebtables " [ -t " table ] [" --atomic-file " file] " --atomic-commit
48 .br
49 .BR "ebtables " [ -t " table ] [" --atomic-file " file] " --atomic-init
50 .br
51 .BR "ebtables " [ -t " table ] [" --atomic-file " file] " --atomic-save
52 .br
53 .SH DESCRIPTION
54 .B ebtables
55 is an application program used to set up and maintain the
56 tables of rules (inside the Linux kernel) that inspect
57 Ethernet frames.
58 It is analogous to the
59 .B iptables
60 application, but less complicated, due to the fact that the Ethernet protocol
61 is much simpler than the IP protocol.
62 .SS CHAINS
63 There are three ebtables tables with built-in chains in the
64 Linux kernel. These tables are used to divide functionality into
65 different sets of rules. Each set of rules is called a chain.
66 Each chain is an ordered list of rules that can match Ethernet frames. If a
67 rule matches an Ethernet frame, then a processing specification tells
68 what to do with that matching frame. The processing specification is
69 called a 'target'. However, if the frame does not match the current
70 rule in the chain, then the next rule in the chain is examined and so forth.
71 The user can create new (user-defined) chains that can be used as the 'target'
72 of a rule. User-defined chains are very useful to get better performance
73 over the linear traversal of the rules and are also essential for structuring
74 the filtering rules into well-organized and maintainable sets of rules.
75 .SS TARGETS
76 A firewall rule specifies criteria for an Ethernet frame and a frame
77 processing specification called a target.  When a frame matches a rule,
78 then the next action performed by the kernel is specified by the target.
79 The target can be one of these values:
80 .BR ACCEPT ,
81 .BR DROP ,
82 .BR CONTINUE ,
83 .BR RETURN ,
84 an 'extension' (see below) or a jump to a user-defined chain.
85 .PP
86 .B ACCEPT
87 means to let the frame through.
88 .B DROP
89 means the frame has to be dropped. In the
90 .BR BROUTING " chain however, the " ACCEPT " and " DROP " target have different"
91 meanings (see the info provided for the
92 .BR -t " option)."
93 .B CONTINUE
94 means the next rule has to be checked. This can be handy, f.e., to know how many
95 frames pass a certain point in the chain, to log those frames or to apply multiple
96 targets on a frame.
97 .B RETURN
98 means stop traversing this chain and resume at the next rule in the
99 previous (calling) chain.
100 For the extension targets please refer to the
101 .B "TARGET EXTENSIONS"
102 section of this man page.
103 .SS TABLES
104 As stated earlier, there are three ebtables tables in the Linux
105 kernel.  The table names are
106 .BR filter ", " nat " and " broute .
107 Of these three tables,
108 the filter table is the default table that the command operates on.
109 If you are working with the filter table, then you can drop the '-t filter'
110 argument to the ebtables command.  However, you will need to provide
111 the -t argument for the other two tables.  Moreover, the -t argument must be the
112 first argument on the ebtables command line, if used. 
114 .B "-t, --table"
116 .B filter
117 is the default table and contains three built-in chains:
118 .B INPUT 
119 (for frames destined for the bridge itself, on the level of the MAC destination address), 
120 .B OUTPUT 
121 (for locally-generated or (b)routed frames) and
122 .B FORWARD 
123 (for frames being forwarded by the bridge).
126 .B nat
127 is mostly used to change the mac addresses and contains three built-in chains:
128 .B PREROUTING 
129 (for altering frames as soon as they come in), 
130 .B OUTPUT 
131 (for altering locally generated or (b)routed frames before they are bridged) and 
132 .B POSTROUTING
133 (for altering frames as they are about to go out). A small note on the naming
134 of chains PREROUTING and POSTROUTING: it would be more accurate to call them
135 PREFORWARDING and POSTFORWARDING, but for all those who come from the
136 iptables world to ebtables it is easier to have the same names. Note that you
137 can change the name
138 .BR "" ( -E )
139 if you don't like the default.
142 .B broute
143 is used to make a brouter, it has one built-in chain:
144 .BR BROUTING .
145 The targets
146 .BR DROP " and " ACCEPT
147 have a special meaning in the broute table (these names are used instead of
148 more descriptive names to keep the implementation generic).
149 .B DROP
150 actually means the frame has to be routed, while
151 .B ACCEPT
152 means the frame has to be bridged. The
153 .B BROUTING
154 chain is traversed very early. However, it is only traversed by frames entering on
155 a bridge port that is in forwarding state. Normally those frames
156 would be bridged, but you can decide otherwise here. The
157 .B redirect
158 target is very handy here.
159 .SH EBTABLES COMMAND LINE ARGUMENTS
160 After the initial ebtables '-t table' command line argument, the remaining
161 arguments can be divided into several groups.  These groups
162 are commands, miscellaneous commands, rule specifications, match extensions,
163 watcher extensions and target extensions.
164 .SS COMMANDS
165 The ebtables command arguments specify the actions to perform on the table
166 defined with the -t argument.  If you do not use the -t argument to name
167 a table, the commands apply to the default filter table.
168 Only one command may be used on the command line at a time, except when
169 the commands
170 .BR -L " and " -Z
171 are combined, the commands
172 .BR -N " and " -P
173 are combined, or when
174 .B --atomic-file
175 is used.
177 .B "-A, --append"
178 Append a rule to the end of the selected chain.
180 .B "-D, --delete"
181 Delete the specified rule or rules from the selected chain. There are two ways to
182 use this command. The first is by specifying an interval of rule numbers
183 to delete (directly after
184 .BR -D ).
185 Syntax: \fIstart_nr\fP[\fI:end_nr\fP] (use
186 .B -L --Ln
187 to list the rules with their rule number). When \fIend_nr\fP is omitted, all rules starting
188 from \fIstart_nr\fP are deleted. Using negative numbers is allowed, for more
189 details about using negative numbers, see the
190 .B -I
191 command. The second usage is by
192 specifying the complete rule as it would have been specified when it was added. Only
193 the first encountered rule that is the same as this specified rule, in other
194 words the matching rule with the lowest (positive) rule number, is deleted.
196 .B "-C, --change-counters"
197 Change the counters of the specified rule or rules from the selected chain. There are two ways to
198 use this command. The first is by specifying an interval of rule numbers
199 to do the changes on (directly after
200 .BR -C ).
201 Syntax: \fIstart_nr\fP[\fI:end_nr\fP] (use
202 .B -L --Ln
203 to list the rules with their rule number). The details are the same as for the
204 .BR -D " command. The second usage is by"
205 specifying the complete rule as it would have been specified when it was added. Only
206 the counters of the first encountered rule that is the same as this specified rule, in other
207 words the matching rule with the lowest (positive) rule number, are changed.
208 In the first usage, the counters are specified directly after the interval specification,
209 in the second usage directly after
210 .BR -C .
211 First the packet counter is specified, then the byte counter. If the specified counters start
212 with a '+', the counter values are added to the respective current counter values.
213 If the specified counters start with a '-', the counter values are decreased from the respective
214 current counter values. No bounds checking is done. If the counters don't start with '+' or '-',
215 the current counters are changed to the specified counters.
217 .B "-I, --insert"
218 Insert the specified rule into the selected chain at the specified rule number. If the
219 rule number is not specified, the rule is added at the head of the chain.
220 If the current number of rules equals
221 .IR N ,
222 then the specified number can be
223 between
224 .IR -N " and " N+1 .
225 For a positive number
226 .IR i ,
227 it holds that
228 .IR i " and " i-N-1
229 specify the same place in the chain where the rule should be inserted. The rule number
230 0 specifies the place past the last rule in the chain and using this number is therefore
231 equivalent to using the
232 .BR -A " command."
233 Rule numbers structly smaller than 0 can be useful when more than one rule needs to be inserted
234 in a chain.
236 .B "-P, --policy"
237 Set the policy for the chain to the given target. The policy can be
238 .BR ACCEPT ", " DROP " or " RETURN .
240 .B "-F, --flush"
241 Flush the selected chain. If no chain is selected, then every chain will be
242 flushed. Flushing a chain does not change the policy of the
243 chain, however.
245 .B "-Z, --zero"
246 Set the counters of the selected chain to zero. If no chain is selected, all the counters
247 are set to zero. The
248 .B "-Z"
249 command can be used in conjunction with the 
250 .B "-L"
251 command.
252 When both the
253 .B "-Z"
255 .B "-L"
256 commands are used together in this way, the rule counters are printed on the screen
257 before they are set to zero.
259 .B "-L, --list"
260 List all rules in the selected chain. If no chain is selected, all chains
261 are listed.
263 The following options change the output of the
264 .B "-L"
265 command.
267 .B "--Ln"
269 Places the rule number in front of every rule. This option is incompatible with the
270 .BR --Lx " option."
272 .B "--Lc"
274 Shows the counters at the end of each rule displayed by the
275 .B "-L"
276 command. Both a frame counter (pcnt) and a byte counter (bcnt) are displayed.
277 The frame counter shows how many frames have matched the specific rule, the byte
278 counter shows the sum of the frame sizes of these matching frames. Using this option
279 .BR "" "in combination with the " --Lx " option causes the counters to be written out"
280 .BR "" "in the '" -c " <pcnt> <bcnt>' option format."
282 .B "--Lx"
284 Changes the output so that it produces a set of ebtables commands that construct
285 the contents of the chain, when specified.
286 If no chain is specified, ebtables commands to construct the contents of the
287 table are given, including commands for creating the user-defined chains (if any).
288 You can use this set of commands in an ebtables boot or reload
289 script.  For example the output could be used at system startup.
290 The 
291 .B "--Lx"
292 option is incompatible with the
293 .B "--Ln"
294 listing option. Using the
295 .BR --Lx " option together with the " --Lc " option will cause the counters to be written out"
296 .BR "" "in the '" -c " <pcnt> <bcnt>' option format."
298 .B "--Lmac2"
300 Shows all MAC addresses with the same length, adding leading zeroes
301 if necessary. The default representation omits leading zeroes in the addresses.
303 .B "-N, --new-chain"
304 Create a new user-defined chain with the given name. The number of
305 user-defined chains is limited only by the number of possible chain names.
306 A user-defined chain name has a maximum
307 length of 31 characters. The standard policy of the user-defined chain is
308 ACCEPT. The policy of the new chain can be initialized to a different standard
309 target by using the
310 .B -P
311 command together with the
312 .B -N
313 command. In this case, the chain name does not have to be specified for the
314 .B -P
315 command.
317 .B "-X, --delete-chain"
318 Delete the specified user-defined chain. There must be no remaining references (jumps)
319 to the specified chain, otherwise ebtables will refuse to delete it. If no chain is
320 specified, all user-defined chains that aren't referenced will be removed.
322 .B "-E, --rename-chain"
323 Rename the specified chain to a new name.  Besides renaming a user-defined
324 chain, you can rename a standard chain to a name that suits your
325 taste. For example, if you like PREFORWARDING more than PREROUTING,
326 then you can use the -E command to rename the PREROUTING chain. If you do
327 rename one of the standard ebtables chain names, please be sure to mention
328 this fact should you post a question on the ebtables mailing lists.
329 It would be wise to use the standard name in your post. Renaming a standard
330 ebtables chain in this fashion has no effect on the structure or functioning
331 of the ebtables kernel table.
333 .B "--init-table"
334 Replace the current table data by the initial table data.
336 .B "--atomic-init"
337 Copy the kernel's initial data of the table to the specified
338 file. This can be used as the first action, after which rules are added
339 to the file. The file can be specified using the
340 .B --atomic-file
341 command or through the
342 .IR EBTABLES_ATOMIC_FILE " environment variable."
344 .B "--atomic-save"
345 Copy the kernel's current data of the table to the specified
346 file. This can be used as the first action, after which rules are added
347 to the file. The file can be specified using the
348 .B --atomic-file
349 command or through the
350 .IR EBTABLES_ATOMIC_FILE " environment variable."
352 .B "--atomic-commit"
353 Replace the kernel table data with the data contained in the specified
354 file. This is a useful command that allows you to load all your rules of a
355 certain table into the kernel at once, saving the kernel a lot of precious
356 time and allowing atomic updates of the tables. The file which contains
357 the table data is constructed by using either the
358 .B "--atomic-init"
359 or the
360 .B "--atomic-save"
361 command to generate a starting file. After that, using the
362 .B "--atomic-file"
363 command when constructing rules or setting the
364 .IR EBTABLES_ATOMIC_FILE " environment variable"
365 allows you to extend the file and build the complete table before
366 committing it to the kernel. This command can be very useful in boot scripts
367 to populate the ebtables tables in a fast way.
368 .SS MISCELLANOUS COMMANDS
370 .B "-V, --version"
371 Show the version of the ebtables userspace program.
373 .BR "-h, --help " "[\fIlist of module names\fP]"
374 Give a brief description of the command syntax. Here you can also specify
375 names of extensions and ebtables will try to write help about those
376 extensions. E.g.
377 .IR "ebtables -h snat log ip arp" .
378 Specify
379 .I list_extensions
380 to list all extensions supported by the userspace
381 utility.
383 .BR "-j, --jump " "\fItarget\fP"
384 The target of the rule. This is one of the following values:
385 .BR ACCEPT ,
386 .BR DROP ,
387 .BR CONTINUE ,
388 .BR RETURN ,
389 a target extension (see
390 .BR "TARGET EXTENSIONS" ")"
391 or a user-defined chain name.
393 .B --atomic-file "\fIfile\fP"
394 Let the command operate on the specified
395 .IR file .
396 The data of the table to
397 operate on will be extracted from the file and the result of the operation
398 will be saved back into the file. If specified, this option should come
399 before the command specification. An alternative that should be preferred,
400 is setting the
401 .IR EBTABLES_ATOMIC_FILE " environment variable."
403 .B -M, --modprobe "\fIprogram\fP"
404 When talking to the kernel, use this
405 .I program
406 to try to automatically load missing kernel modules.
408 .B --concurrent
409 Use a file lock to support concurrent scripts updating the ebtables kernel tables.
412 RULE SPECIFICATIONS
413 The following command line arguments make up a rule specification (as used 
414 in the add and delete commands). A "!" option before the specification 
415 inverts the test for that specification. Apart from these standard rule 
416 specifications there are some other command line arguments of interest.
417 See both the 
418 .BR "MATCH EXTENSIONS" 
419 and the
420 .BR "WATCHER EXTENSIONS" 
421 below.
423 .BR "-p, --protocol " "[!] \fIprotocol\fP"
424 The protocol that was responsible for creating the frame. This can be a
425 hexadecimal number, above 
426 .IR 0x0600 ,
427 a name (e.g.
428 .I ARP
429 ) or
430 .BR LENGTH .
431 The protocol field of the Ethernet frame can be used to denote the
432 length of the header (802.2/802.3 networks). When the value of that field is
433 below or equals
434 .IR 0x0600 ,
435 the value equals the size of the header and shouldn't be used as a
436 protocol number. Instead, all frames where the protocol field is used as
437 the length field are assumed to be of the same 'protocol'. The protocol
438 name used in ebtables for these frames is
439 .BR LENGTH .
441 The file
442 .B /etc/ethertypes
443 can be used to show readable
444 characters instead of hexadecimal numbers for the protocols. For example,
445 .I 0x0800
446 will be represented by 
447 .IR IPV4 .
448 The use of this file is not case sensitive. 
449 See that file for more information. The flag 
450 .B --proto
451 is an alias for this option.
452 .TP 
453 .BR "-i, --in-interface " "[!] \fIname\fP"
454 The interface (bridge port) via which a frame is received (this option is useful in the
455 .BR INPUT ,
456 .BR FORWARD ,
457 .BR PREROUTING " and " BROUTING
458 chains). If the interface name ends with '+', then
459 any interface name that begins with this name (disregarding '+') will match.
460 The flag
461 .B --in-if
462 is an alias for this option.
464 .BR "--logical-in " "[!] \fIname\fP"
465 The (logical) bridge interface via which a frame is received (this option is useful in the
466 .BR INPUT ,
467 .BR FORWARD ,
468 .BR PREROUTING " and " BROUTING
469 chains).
470 If the interface name ends with '+', then
471 any interface name that begins with this name (disregarding '+') will match.
473 .BR "-o, --out-interface " "[!] \fIname\fP"
474 The interface (bridge port) via which a frame is going to be sent (this option is useful in the
475 .BR OUTPUT ,
476 .B FORWARD
478 .B POSTROUTING
479 chains). If the interface name ends with '+', then
480 any interface name that begins with this name (disregarding '+') will match.
481 The flag
482 .B --out-if
483 is an alias for this option.
485 .BR "--logical-out " "[!] \fIname\fP"
486 The (logical) bridge interface via which a frame is going to be sent (this option
487 is useful in the
488 .BR OUTPUT ,
489 .B FORWARD
491 .B POSTROUTING
492 chains).
493 If the interface name ends with '+', then
494 any interface name that begins with this name (disregarding '+') will match.
496 .BR "-s, --source " "[!] \fIaddress\fP[/\fImask\fP]"
497 The source MAC address. Both mask and address are written as 6 hexadecimal
498 numbers separated by colons. Alternatively one can specify Unicast,
499 Multicast, Broadcast or BGA (Bridge Group Address):
501 .IR "Unicast" "=00:00:00:00:00:00/01:00:00:00:00:00,"
502 .IR "Multicast" "=01:00:00:00:00:00/01:00:00:00:00:00,"
503 .IR "Broadcast" "=ff:ff:ff:ff:ff:ff/ff:ff:ff:ff:ff:ff or"
504 .IR "BGA" "=01:80:c2:00:00:00/ff:ff:ff:ff:ff:ff."
505 Note that a broadcast
506 address will also match the multicast specification. The flag
507 .B --src
508 is an alias for this option.
510 .BR "-d, --destination " "[!] \fIaddress\fP[/\fImask\fP]"
511 The destination MAC address. See
512 .B -s
513 (above) for more details on MAC addresses. The flag
514 .B --dst
515 is an alias for this option.
517 .BR "-c, --set-counter " "\fIpcnt bcnt\fP"
518 If used with
519 .BR -A " or " -I ", then the packet and byte counters of the new rule will be set to
520 .IR pcnt ", resp. " bcnt ".
521 If used with the
522 .BR -C " or " -D " commands, only rules with a packet and byte count equal to"
523 .IR pcnt ", resp. " bcnt " will match."
525 .SS MATCH EXTENSIONS
526 Ebtables extensions are dynamically loaded into the userspace tool,
527 there is therefore no need to explicitly load them with a
528 -m option like is done in iptables.
529 These extensions deal with functionality supported by kernel modules supplemental to
530 the core ebtables code.
531 .SS 802_3
532 Specify 802.3 DSAP/SSAP fields or SNAP type.  The protocol must be specified as
533 .IR "LENGTH " "(see the option " " -p " above).
535 .BR "--802_3-sap " "[!] \fIsap\fP"
536 DSAP and SSAP are two one byte 802.3 fields.  The bytes are always
537 equal, so only one byte (hexadecimal) is needed as an argument.
539 .BR "--802_3-type " "[!] \fItype\fP"
540 If the 802.3 DSAP and SSAP values are 0xaa then the SNAP type field must
541 be consulted to determine the payload protocol.  This is a two byte
542 (hexadecimal) argument.  Only 802.3 frames with DSAP/SSAP 0xaa are
543 checked for type.
544 .SS among
545 Match a MAC address or MAC/IP address pair versus a list of MAC addresses
546 and MAC/IP address pairs.
547 A list entry has the following format:
548 .IR xx:xx:xx:xx:xx:xx[=ip.ip.ip.ip][,] ". Multiple"
549 list entries are separated by a comma, specifying an IP address corresponding to
550 the MAC address is optional. Multiple MAC/IP address pairs with the same MAC address
551 but different IP address (and vice versa) can be specified. If the MAC address doesn't
552 match any entry from the list, the frame doesn't match the rule (unless "!" was used).
554 .BR "--among-dst " "[!] \fIlist\fP"
555 Compare the MAC destination to the given list. If the Ethernet frame has type
556 .IR IPv4 " or " ARP ,
557 then comparison with MAC/IP destination address pairs from the
558 list is possible.
560 .BR "--among-src " "[!] \fIlist\fP"
561 Compare the MAC source to the given list. If the Ethernet frame has type
562 .IR IPv4 " or " ARP ,
563 then comparison with MAC/IP source address pairs from the list
564 is possible.
566 .BR "--among-dst-file " "[!] \fIfile\fP"
567 Same as
568 .BR --among-dst " but the list is read in from the specified file."
570 .BR "--among-src-file " "[!] \fIfile\fP"
571 Same as
572 .BR --among-src " but the list is read in from the specified file."
573 .SS arp
574 Specify (R)ARP fields. The protocol must be specified as
575 .IR ARP " or " RARP .
577 .BR "--arp-opcode " "[!] \fIopcode\fP"
578 The (R)ARP opcode (decimal or a string, for more details see
579 .BR "ebtables -h arp" ).
581 .BR "--arp-htype " "[!] \fIhardware type\fP"
582 The hardware type, this can be a decimal or the string
583 .I Ethernet
584 (which sets
585 .I type
586 to 1). Most (R)ARP packets have Eternet as hardware type.
588 .BR "--arp-ptype " "[!] \fIprotocol type\fP"
589 The protocol type for which the (r)arp is used (hexadecimal or the string
590 .IR IPv4 ,
591 denoting 0x0800).
592 Most (R)ARP packets have protocol type IPv4.
594 .BR "--arp-ip-src " "[!] \fIaddress\fP[/\fImask\fP]"
595 The (R)ARP IP source address specification.
597 .BR "--arp-ip-dst " "[!] \fIaddress\fP[/\fImask\fP]"
598 The (R)ARP IP destination address specification.
600 .BR "--arp-mac-src " "[!] \fIaddress\fP[/\fImask\fP]"
601 The (R)ARP MAC source address specification.
603 .BR "--arp-mac-dst " "[!] \fIaddress\fP[/\fImask\fP]"
604 The (R)ARP MAC destination address specification.
606 .BR "" "[!]" " --arp-gratuitous"
607 Checks for ARP gratuitous packets: checks equality of IPv4 source
608 address and IPv4 destination address inside the ARP header.
609 .SS ip
610 Specify IPv4 fields. The protocol must be specified as
611 .IR IPv4 .
613 .BR "--ip-source " "[!] \fIaddress\fP[/\fImask\fP]"
614 The source IP address.
615 The flag
616 .B --ip-src
617 is an alias for this option.
619 .BR "--ip-destination " "[!] \fIaddress\fP[/\fImask\fP]"
620 The destination IP address.
621 The flag
622 .B --ip-dst
623 is an alias for this option.
625 .BR "--ip-tos " "[!] \fItos\fP"
626 The IP type of service, in hexadecimal numbers.
627 .BR IPv4 .
629 .BR "--ip-protocol " "[!] \fIprotocol\fP"
630 The IP protocol.
631 The flag
632 .B --ip-proto
633 is an alias for this option.
635 .BR "--ip-source-port " "[!] \fIport1\fP[:\fIport2\fP]"
636 The source port or port range for the IP protocols 6 (TCP), 17
637 (UDP), 33 (DCCP) or 132 (SCTP). The
638 .B --ip-protocol
639 option must be specified as
640 .IR TCP ", " UDP ", " DCCP " or " SCTP .
642 .IR port1 " is omitted, " 0:port2 " is used; if " port2 " is omitted but a colon is specified, " port1:65535 " is used."
643 The flag
644 .B --ip-sport
645 is an alias for this option.
647 .BR "--ip-destination-port " "[!] \fIport1\fP[:\fIport2\fP]"
648 The destination port or port range for ip protocols 6 (TCP), 17
649 (UDP), 33 (DCCP) or 132 (SCTP). The
650 .B --ip-protocol
651 option must be specified as
652 .IR TCP ", " UDP ", " DCCP " or " SCTP .
654 .IR port1 " is omitted, " 0:port2 " is used; if " port2 " is omitted but a colon is specified, " port1:65535 " is used."
655 The flag
656 .B --ip-dport
657 is an alias for this option.
658 .SS ip6
659 Specify IPv6 fields. The protocol must be specified as
660 .IR IPv6 .
662 .BR "--ip6-source " "[!] \fIaddress\fP[/\fImask\fP]"
663 The source IPv6 address.
664 The flag
665 .B --ip6-src
666 is an alias for this option.
668 .BR "--ip6-destination " "[!] \fIaddress\fP[/\fImask\fP]"
669 The destination IPv6 address.
670 The flag
671 .B --ip6-dst
672 is an alias for this option.
674 .BR "--ip6-tclass " "[!] \fItclass\fP"
675 The IPv6 traffic class, in hexadecimal numbers.
677 .BR "--ip6-protocol " "[!] \fIprotocol\fP"
678 The IP protocol.
679 The flag
680 .B --ip6-proto
681 is an alias for this option.
683 .BR "--ip6-source-port " "[!] \fIport1\fP[:\fIport2\fP]"
684 The source port or port range for the IPv6 protocols 6 (TCP), 17
685 (UDP), 33 (DCCP) or 132 (SCTP). The
686 .B --ip6-protocol
687 option must be specified as
688 .IR TCP ", " UDP ", " DCCP " or " SCTP .
690 .IR port1 " is omitted, " 0:port2 " is used; if " port2 " is omitted but a colon is specified, " port1:65535 " is used."
691 The flag
692 .B --ip6-sport
693 is an alias for this option.
695 .BR "--ip6-destination-port " "[!] \fIport1\fP[:\fIport2\fP]"
696 The destination port or port range for IPv6 protocols 6 (TCP), 17
697 (UDP), 33 (DCCP) or 132 (SCTP). The
698 .B --ip6-protocol
699 option must be specified as
700 .IR TCP ", " UDP ", " DCCP " or " SCTP .
702 .IR port1 " is omitted, " 0:port2 " is used; if " port2 " is omitted but a colon is specified, " port1:65535 " is used."
703 The flag
704 .B --ip6-dport
705 is an alias for this option.
707 .BR "--ip6-icmp-type " "[!] {\fItype\fP[:\fItype\fP]/\fIcode\fP[:\fIcode\fP]|\fItypename\fP}"
708 Specify ipv6\-icmp type and code to match.
709 Ranges for both type and code are supported. Type and code are
710 separated by a slash. Valid numbers for type and range are 0 to 255.
711 To match a single type including all valid codes, symbolic names can
712 be used instead of numbers. The list of known type names is shown by the command
714   ebtables \-\-help ip6
716 This option is only valid for \-\-ip6-prococol ipv6-icmp.
717 .SS limit
718 This module matches at a limited rate using a token bucket filter.
719 A rule using this extension will match until this limit is reached.
720 It can be used with the
721 .B --log
722 watcher to give limited logging, for example. Its use is the same
723 as the limit match of iptables.
725 .BR "--limit " "[\fIvalue\fP]"
726 Maximum average matching rate: specified as a number, with an optional
727 .IR /second ", " /minute ", " /hour ", or " /day " suffix; the default is " 3/hour .
729 .BR "--limit-burst " "[\fInumber\fP]"
730 Maximum initial number of packets to match: this number gets recharged by
731 one every time the limit specified above is not reached, up to this
732 number; the default is
733 .IR 5 .
734 .SS mark_m
736 .BR "--mark " "[!] [\fIvalue\fP][/\fImask\fP]"
737 Matches frames with the given unsigned mark value. If a
738 .IR value " and " mask " are specified, the logical AND of the mark value of the frame and"
739 the user-specified
740 .IR mask " is taken before comparing it with the"
741 user-specified mark
742 .IR value ". When only a mark "
743 .IR value " is specified, the packet"
744 only matches when the mark value of the frame equals the user-specified
745 mark
746 .IR value .
747 If only a
748 .IR mask " is specified, the logical"
749 AND of the mark value of the frame and the user-specified
750 .IR mask " is taken and the frame matches when the result of this logical AND is"
751 non-zero. Only specifying a
752 .IR mask " is useful to match multiple mark values."
753 .SS pkttype
755 .BR "--pkttype-type " "[!] \fItype\fP"
756 Matches on the Ethernet "class" of the frame, which is determined by the
757 generic networking code. Possible values:
758 .IR broadcast " (MAC destination is the broadcast address),"
759 .IR multicast " (MAC destination is a multicast address),"
760 .IR host " (MAC destination is the receiving network device), or "
761 .IR otherhost " (none of the above)."
762 .SS stp
763 Specify stp BPDU (bridge protocol data unit) fields. The destination
764 address
765 .BR "" ( -d ") must be specified as the bridge group address"
766 .IR "" ( BGA ).
767 For all options for which a range of values can be specified, it holds that
768 if the lower bound is omitted (but the colon is not), then the lowest possible lower bound
769 for that option is used, while if the upper bound is omitted (but the colon again is not), the
770 highest possible upper bound for that option is used.
772 .BR "--stp-type " "[!] \fItype\fP"
773 The BPDU type (0-255), recognized non-numerical types are
774 .IR config ", denoting a configuration BPDU (=0), and"
775 .IR tcn ", denothing a topology change notification BPDU (=128)."
777 .BR "--stp-flags " "[!] \fIflag\fP"
778 The BPDU flag (0-255), recognized non-numerical flags are
779 .IR topology-change ", denoting the topology change flag (=1), and"
780 .IR topology-change-ack ", denoting the topology change acknowledgement flag (=128)."
782 .BR "--stp-root-prio " "[!] [\fIprio\fP][:\fIprio\fP]"
783 The root priority (0-65535) range.
785 .BR "--stp-root-addr " "[!] [\fIaddress\fP][/\fImask\fP]"
786 The root mac address, see the option
787 .BR -s " for more details."
789 .BR "--stp-root-cost " "[!] [\fIcost\fP][:\fIcost\fP]"
790 The root path cost (0-4294967295) range.
792 .BR "--stp-sender-prio " "[!] [\fIprio\fP][:\fIprio\fP]"
793 The BPDU's sender priority (0-65535) range.
795 .BR "--stp-sender-addr " "[!] [\fIaddress\fP][/\fImask\fP]"
796 The BPDU's sender mac address, see the option
797 .BR -s " for more details."
799 .BR "--stp-port " "[!] [\fIport\fP][:\fIport\fP]"
800 The port identifier (0-65535) range.
802 .BR "--stp-msg-age " "[!] [\fIage\fP][:\fIage\fP]"
803 The message age timer (0-65535) range.
805 .BR "--stp-max-age " "[!] [\fIage\fP][:\fIage\fP]"
806 The max age timer (0-65535) range.
808 .BR "--stp-hello-time " "[!] [\fItime\fP][:\fItime\fP]"
809 The hello time timer (0-65535) range.
811 .BR "--stp-forward-delay " "[!] [\fIdelay\fP][:\fIdelay\fP]"
812 The forward delay timer (0-65535) range.
813 .SS vlan
814 Specify 802.1Q Tag Control Information fields.
815 The protocol must be specified as
816 .IR 802_1Q " (0x8100)."
818 .BR "--vlan-id " "[!] \fIid\fP"
819 The VLAN identifier field (VID). Decimal number from 0 to 4095.
821 .BR "--vlan-prio " "[!] \fIprio\fP"
822 The user priority field, a decimal number from 0 to 7.
823 The VID should be set to 0 ("null VID") or unspecified
824 (in the latter case the VID is deliberately set to 0).
826 .BR "--vlan-encap " "[!] \fItype\fP"
827 The encapsulated Ethernet frame type/length.
828 Specified as a hexadecimal
829 number from 0x0000 to 0xFFFF or as a symbolic name
830 from
831 .BR /etc/ethertypes .
833 .SS WATCHER EXTENSIONS
834 Watchers only look at frames passing by, they don't modify them nor decide
835 to accept the frames or not. These watchers only
836 see the frame if the frame matches the rule, and they see it before the
837 target is executed.
838 .SS log
839 The log watcher writes descriptive data about a frame to the syslog.
841 .B "--log"
843 Log with the default loggin options: log-level=
844 .IR info ,
845 log-prefix="", no ip logging, no arp logging.
847 .B --log-level "\fIlevel\fP"
849 Defines the logging level. For the possible values, see
850 .BR "ebtables -h log" .
851 The default level is 
852 .IR info .
854 .BR --log-prefix " \fItext\fP"
856 Defines the prefix
857 .I text
858 to be printed at the beginning of the line with the logging information.
860 .B --log-ip 
862 Will log the ip information when a frame made by the ip protocol matches 
863 the rule. The default is no ip information logging.
865 .B --log-ip6 
867 Will log the ipv6 information when a frame made by the ipv6 protocol matches 
868 the rule. The default is no ipv6 information logging.
870 .B --log-arp
872 Will log the (r)arp information when a frame made by the (r)arp protocols
873 matches the rule. The default is no (r)arp information logging.
874 .SS nflog
875 The nflog watcher passes the packet to the loaded logging backend
876 in order to log the packet. This is usually used in combination with
877 nfnetlink_log as logging backend, which will multicast the packet
878 through a
879 .IR netlink
880 socket to the specified multicast group. One or more userspace processes
881 may subscribe to the group to receive the packets.
883 .B "--nflog"
885 Log with the default logging options
887 .B --nflog-group "\fInlgroup\fP"
889 The netlink group (1 - 2^32-1) to which packets are (only applicable for
890 nfnetlink_log). The default value is 1.
892 .B --nflog-prefix "\fIprefix\fP"
894 A prefix string to include in the log message, up to 30 characters
895 long, useful for distinguishing messages in the logs.
897 .B --nflog-range "\fIsize\fP"
899 The number of bytes to be copied to userspace (only applicable for
900 nfnetlink_log). nfnetlink_log instances may specify their own
901 range, this option overrides it.
903 .B --nflog-threshold "\fIsize\fP"
905 Number of packets to queue inside the kernel before sending them
906 to userspace (only applicable for nfnetlink_log). Higher values
907 result in less overhead per packet, but increase delay until the
908 packets reach userspace. The default value is 1.
909 .SS ulog
910 The ulog watcher passes the packet to a userspace
911 logging daemon using netlink multicast sockets. This differs
912 from the log watcher in the sense that the complete packet is
913 sent to userspace instead of a descriptive text and that
914 netlink multicast sockets are used instead of the syslog.
915 This watcher enables parsing of packets with userspace programs, the
916 physical bridge in and out ports are also included in the netlink messages.
917 The ulog watcher module accepts 2 parameters when the module is loaded
918 into the kernel (e.g. with modprobe):
919 .B nlbufsiz
920 specifies how big the buffer for each netlink multicast
921 group is. If you say
922 .IR nlbufsiz=8192 ,
923 for example, up to eight kB of packets will
924 get accumulated in the kernel until they are sent to userspace. It is
925 not possible to allocate more than 128kB. Please also keep in mind that
926 this buffer size is allocated for each nlgroup you are using, so the
927 total kernel memory usage increases by that factor. The default is 4096.
928 .B flushtimeout
929 specifies after how many hundredths of a second the queue should be
930 flushed, even if it is not full yet. The default is 10 (one tenth of
931 a second).
933 .B "--ulog"
935 Use the default settings: ulog-prefix="", ulog-nlgroup=1,
936 ulog-cprange=4096, ulog-qthreshold=1.
938 .B --ulog-prefix "\fItext\fP"
940 Defines the prefix included with the packets sent to userspace.
942 .BR --ulog-nlgroup " \fIgroup\fP"
944 Defines which netlink group number to use (a number from 1 to 32).
945 Make sure the netlink group numbers used for the iptables ULOG
946 target differ from those used for the ebtables ulog watcher.
947 The default group number is 1.
949 .BR --ulog-cprange " \fIrange\fP"
951 Defines the maximum copy range to userspace, for packets matching the
952 rule. The default range is 0, which means the maximum copy range is
953 given by
954 .BR nlbufsiz .
955 A maximum copy range larger than
956 128*1024 is meaningless as the packets sent to userspace have an upper
957 size limit of 128*1024.
959 .BR --ulog-qthreshold " \fIthreshold\fP"
961 Queue at most
962 .I threshold
963 number of packets before sending them to
964 userspace with a netlink socket. Note that packets can be sent to
965 userspace before the queue is full, this happens when the ulog
966 kernel timer goes off (the frequency of this timer depends on
967 .BR flushtimeout ).
968 .SS TARGET EXTENSIONS
969 .SS arpreply
971 .B arpreply
972 target can be used in the
973 .BR PREROUTING " chain of the " nat " table."
974 If this target sees an ARP request it will automatically reply
975 with an ARP reply. The used MAC address for the reply can be specified.
976 The protocol must be specified as
977 .IR ARP .
978 When the ARP message is not an ARP request or when the ARP request isn't
979 for an IP address on an Ethernet network, it is ignored by this target
980 .BR "" ( CONTINUE ).
981 When the ARP request is malformed, it is dropped
982 .BR "" ( DROP ).
984 .BR "--arpreply-mac " "\fIaddress\fP"
985 Specifies the MAC address to reply with: the Ethernet source MAC and the
986 ARP payload source MAC will be filled in with this address.
988 .BR "--arpreply-target " "\fItarget\fP"
989 Specifies the standard target. After sending the ARP reply, the rule still
990 has to give a standard target so ebtables knows what to do with the ARP request.
991 The default target
992 .BR "" "is " DROP .
993 .SS dnat
995 .B dnat
996 target can only be used in the
997 .BR BROUTING " chain of the " broute " table and the "
998 .BR PREROUTING " and " OUTPUT " chains of the " nat " table."
999 It specifies that the destination MAC address has to be changed.
1001 .BR "--to-destination " "\fIaddress\fP"
1003 Change the destination MAC address to the specified
1004 .IR address .
1005 The flag
1006 .B --to-dst
1007 is an alias for this option.
1009 .BR "--dnat-target " "\fItarget\fP"
1011 Specifies the standard target. After doing the dnat, the rule still has to
1012 give a standard target so ebtables knows what to do with the dnated frame.
1013 The default target is
1014 .BR ACCEPT .
1015 Making it
1016 .BR CONTINUE " could let you use"
1017 multiple target extensions on the same frame. Making it
1018 .BR DROP " only makes"
1019 sense in the
1020 .BR BROUTING " chain but using the " redirect " target is more logical there. " RETURN " is also allowed. Note that using " RETURN
1021 in a base chain is not allowed (for obvious reasons).
1022 .SS mark
1023 .BR "" "The " mark " target can be used in every chain of every table. It is possible"
1024 to use the marking of a frame/packet in both ebtables and iptables,
1025 if the bridge-nf code is compiled into the kernel. Both put the marking at the
1026 same place. This allows for a form of communication between ebtables and iptables.
1028 .BR "--mark-set " "\fIvalue\fP"
1030 Mark the frame with the specified non-negative
1031 .IR value .
1033 .BR "--mark-or " "\fIvalue\fP"
1035 Or the frame with the specified non-negative
1036 .IR value .
1038 .BR "--mark-and " "\fIvalue\fP"
1040 And the frame with the specified non-negative
1041 .IR value .
1043 .BR "--mark-xor " "\fIvalue\fP"
1045 Xor the frame with the specified non-negative
1046 .IR value .
1048 .BR "--mark-target " "\fItarget\fP"
1050 Specifies the standard target. After marking the frame, the rule
1051 still has to give a standard target so ebtables knows what to do.
1052 The default target is
1053 .BR ACCEPT ". Making it " CONTINUE " can let you do other"
1054 things with the frame in subsequent rules of the chain.
1055 .SS redirect
1057 .B redirect
1058 target will change the MAC target address to that of the bridge device the
1059 frame arrived on. This target can only be used in the
1060 .BR BROUTING " chain of the " broute " table and the "
1061 .BR PREROUTING " chain of the " nat " table."
1062 In the
1063 .BR BROUTING " chain, the MAC address of the bridge port is used as destination address,"
1064 .BR "" "in the " PREROUTING " chain, the MAC address of the bridge is used."
1066 .BR "--redirect-target " "\fItarget\fP"
1068 Specifies the standard target. After doing the MAC redirect, the rule
1069 still has to give a standard target so ebtables knows what to do.
1070 The default target is
1071 .BR ACCEPT ". Making it " CONTINUE " could let you use"
1072 multiple target extensions on the same frame. Making it
1073 .BR DROP " in the " BROUTING " chain will let the frames be routed. " RETURN " is also allowed. Note"
1074 .BR "" "that using " RETURN " in a base chain is not allowed."
1075 .SS snat
1077 .B snat
1078 target can only be used in the
1079 .BR POSTROUTING " chain of the " nat " table."
1080 It specifies that the source MAC address has to be changed.
1082 .BR "--to-source " "\fIaddress\fP"
1084 Changes the source MAC address to the specified
1085 .IR address ". The flag"
1086 .B --to-src
1087 is an alias for this option.
1089 .BR "--snat-target " "\fItarget\fP"
1091 Specifies the standard target. After doing the snat, the rule still has 
1092 to give a standard target so ebtables knows what to do.
1093 .BR "" "The default target is " ACCEPT ". Making it " CONTINUE " could let you use"
1094 .BR "" "multiple target extensions on the same frame. Making it " DROP " doesn't"
1095 .BR "" "make sense, but you could do that too. " RETURN " is also allowed. Note"
1096 .BR "" "that using " RETURN " in a base chain is not allowed."
1099 .BR "--snat-arp "
1101 Also change the hardware source address inside the arp header if the packet is an
1102 arp message and the hardware address length in the arp header is 6 bytes.
1104 .SH FILES
1105 .I /etc/ethertypes
1106 .I /var/lib/ebtables/lock
1107 .SH ENVIRONMENT VARIABLES
1108 .I EBTABLES_ATOMIC_FILE
1109 .SH MAILINGLISTS
1110 .BR "" "See " http://netfilter.org/mailinglists.html
1111 .SH SEE ALSO
1112 .BR iptables "(8), " brctl "(8), " ifconfig "(8), " route (8)
1114 .BR "" "See " http://ebtables.sf.net