blob: 7a885184b21a96502dd392a6795edfe0af90c3ac [file] [log] [blame]
Bart De Schuymeraac31142002-08-11 11:57:52 +00001.TH EBTABLES 8 "11 August 2002"
Bart De Schuymer1abc55d2002-06-01 19:23:47 +00002.\"
3.\" Man page written by Bart De Schuymer <bart.de.schuymer@pandora.be>
4.\" It is based on the iptables man page.
5.\"
6.\" Iptables page by Herve Eychenne March 2000.
7.\"
8.\" This program is free software; you can redistribute it and/or modify
9.\" it under the terms of the GNU General Public License as published by
10.\" the Free Software Foundation; either version 2 of the License, or
11.\" (at your option) any later version.
12.\"
13.\" This program is distributed in the hope that it will be useful,
14.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
15.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16.\" GNU General Public License for more details.
17.\"
18.\" You should have received a copy of the GNU General Public License
19.\" along with this program; if not, write to the Free Software
20.\" Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21.\"
22.\"
23.SH NAME
Bart De Schuymer63e2c702002-08-01 15:30:15 +000024ebtables (v.2.0) \- Ethernet bridge frame table administration
Bart De Schuymer1abc55d2002-06-01 19:23:47 +000025.SH SYNOPSIS
Bart De Schuymer29749c62002-06-25 21:27:57 +000026.BR "ebtables -[ADI] " "chain rule-specification " [ options ]
Bart De Schuymer1abc55d2002-06-01 19:23:47 +000027.br
28.BR "ebtables -P " "chain target"
29.br
30.BR "ebtables -[FLZ] [" "chain" "]"
31.br
Bart De Schuymer29749c62002-06-25 21:27:57 +000032.BR "ebtables -[NX] " chain
33.br
34.BR "ebtables -E " "old-chain-name new-chain-name"
35.br
Bart De Schuymera02773a2002-07-15 19:42:11 +000036.BR "ebtables --init-table"
37.br
Bart De Schuymer234bce92002-07-14 21:25:08 +000038.BR "ebtables --atomic-init " file
39.br
40.BR "ebtables --atomic-save " file
41.br
42.BR "ebtables --atomic-commit " file
43.br
Bart De Schuymer1abc55d2002-06-01 19:23:47 +000044.SH DESCRIPTION
45.B ebtables
46is used to set up, maintain, and inspect the tables of Ethernet frame
47rules in the Linux kernel. It works analogous as iptables, but is less
48complicated. This man page is written with the man page of iptables
49next to it, so don't be surprised to see copied sentences and structure.
50
51There are three tables with built-in chains. Each chain is a list
52of rules which can match frames: each rule specifies what to do with a
53frame which matches. This is called a 'target'. The tables are used to
54divide functionality into different sets of chains.
55
56.SS TARGETS
57A firewall rule specifies criteria for a frame, and a target. If the
58frame does not match, the next rule in the chain is the examined one; if
59it does match, then the next thing to do is specified by the target.
60This target can be one of these values:
61.IR ACCEPT ,
62.IR DROP ,
63.IR CONTINUE ,
Bart De Schuymer29749c62002-06-25 21:27:57 +000064.IR RETURN ,
Bart De Schuymer1abc55d2002-06-01 19:23:47 +000065an extention.
66.PP
67.I ACCEPT
68means to let the frame through.
69.I DROP
70means the frame has to be dropped.
71.I CONTINUE
72means the next rule has to be checked. This can be handy to know how many
Bart De Schuymer29749c62002-06-25 21:27:57 +000073frames pass a certain point in the chain or to log those frames.
74.I RETURN
75means stop traversing this chain and resume at the next rule in the
76previous (calling) chain.
77For the
Bart De Schuymer1abc55d2002-06-01 19:23:47 +000078other targets see the
79.B "TARGET EXTENSIONS"
80section.
81.SS TABLES
82There are three tables.
83.TP
84.B "-t, --table"
85This option specifies the frame matching table which the command should
Bart De Schuymer29749c62002-06-25 21:27:57 +000086operate on. If specified it should be the first option. The tables are:
Bart De Schuymer1abc55d2002-06-01 19:23:47 +000087.BR filter ,
88this is the default table and contains three chains:
89.B INPUT
90(for frames destined for the bridge itself),
91.B OUTPUT
92(for locally-generated frames) and
93.B FORWARD
94(for frames being bridged).
95.BR nat ,
96this table is used to change the mac addresses and contains three chains:
97.B PREROUTING
98(for altering frames as soon as they come in),
99.B OUTPUT
100(for altering locally generated frames before they are bridged) and
101.B POSTROUTING
102(for altering frames as they are about to go out). A small note on the naming
103of chains POSTROUTING and PREROUTING: it would be more accurate to call them
104PREFORWARDING and POSTFORWARDING, but for all those who come from the
105.BR iptables " world to " ebtables
106it is easier to have the same names.
107.BR broute ,
108this table is used to make a brouter, it has one chain:
109.BR BROUTING .
110The targets
111.BR DROP " and " ACCEPT
112have special meaning in this table.
113.B DROP
114actually means the frame has to be routed, while
115.B ACCEPT
116means the frame has to be bridged. The
117.B BROUTING
118chain is traversed very early. It is only traversed by frames entering on
119a bridge enslaved nic that is in forwarding state. Normally those frames
120would be bridged, but you can decide otherwise here. The
121.B redirect
122target is very handy here.
123.SH OPTIONS
124The options can be divided into several different groups.
125.SS COMMANDS
126These options specify the specific actions to perform; only one of them
127can be specified on the command line (the
128.B -Z
129command is an exception). All these options only apply to the selected
130(or default) table.
131.TP
132.B "-A, --append"
133Append a rule to the end of the selected chain.
134.TP
135.B "-D, --delete"
136Delete the specified rule from the selected chain. There are two versions
137of this command. A rule number (starting at 1) or the complete rule can be
138specified.
139.TP
140.B "-I, --insert"
141Insert the specified rule into the selected chain at the specified rule number (1 meaning
142the head of the chain).
143.TP
144.B "-L, --list"
145List all rules in the selected chain. If no chain is selected, all chains
Bart De Schuymeraac31142002-08-11 11:57:52 +0000146are listed.
Bart De Schuymer234bce92002-07-14 21:25:08 +0000147.br
Bart De Schuymeraac31142002-08-11 11:57:52 +0000148The following three options change the output:
Bart De Schuymer234bce92002-07-14 21:25:08 +0000149.br
150.B "--Ln"
151.br
152Puts rule numbers in front of every rule.
153.br
154.B "--Lc"
155.br
156Puts the counter value at the end of every rule.
157.br
158.B "--Lx"
159.br
160The output is directly usable as executable commands in a script, to be
161run f.e. at bootup. This option is incompatible with the previous two
162options. When no chain name was specified for the
163.B "-L"
164command, all necessary commands for making the user defined chains and
165renaming the standard chains will be made.
Bart De Schuymer1abc55d2002-06-01 19:23:47 +0000166.TP
167.B "-F, --flush"
168Flush the selected chain. If no chain is selected, every chain will be
169flushed. This does not change the policy of the chain.
170.TP
Bart De Schuymera02773a2002-07-15 19:42:11 +0000171.B "--init-table"
172Replace the current table data by the initial table data.
173.TP
Bart De Schuymer1abc55d2002-06-01 19:23:47 +0000174.B "-Z, --zero"
175Put the counters of the selected chain on zero. If no chain is selected, all the counters
176are put on zero. This can be used in conjunction with the -L command (see above).
177This will cause the rule counters to be printed on the screen before they are put on zero.
178.TP
179.B "-P, --policy"
180Set the policy for the chain to the given target. The policy is either
181.B ACCEPT
182, either
183.BR DROP .
Bart De Schuymer29749c62002-06-25 21:27:57 +0000184.TP
185.B "-N, --new-chain"
Bart De Schuymer63e2c702002-08-01 15:30:15 +0000186Create a new user-defined chain by the given name. The number of
187user-defined chains is unlimited. A chain name has max length of 31.
Bart De Schuymer29749c62002-06-25 21:27:57 +0000188.TP
189.B "-X, --delete-chain"
190Delete the specified user-defined chain. There must be no references to the
191chain,
192.B ebtables
193will complain if there are.
194.TP
195.B "-E, --rename-chain"
196Rename the specified chain to the new name. This has no effect on the
197structure of the table. It is also allowed to rename a base chain, f.e.
198if you like PREBRIDGING more than PREROUTING. Be sure to talk about the
199standard chain names when you would ask a question on a mailing list.
Bart De Schuymer234bce92002-07-14 21:25:08 +0000200.TP
201.B "--atomic-init"
Bart De Schuymera02773a2002-07-15 19:42:11 +0000202Copy the kernel's initial data of the table to the specified
Bart De Schuymer234bce92002-07-14 21:25:08 +0000203file. This can be used as the first action, after which rules are added
204to the file.
205.TP
206.B "--atomic-save"
Bart De Schuymera02773a2002-07-15 19:42:11 +0000207Copy the kernel's current data of the table to the specified
Bart De Schuymer234bce92002-07-14 21:25:08 +0000208file. This can be used as the first action, after which rules are added
209to the file.
210.TP
211.B "--atomic-commit"
212Replace the kernel table data with the data contained in the specified
213file. This is a useful command that allows you to put all your rules of a
214certain table into the kernel at once, saving the kernel a lot of precious
215time. The file which contains the table data is constructed by using
216either the
217.B "--atomic-init"
218or the
219.B "--atomic-save"
220command to get a starting file. After that, using the
221.B "--atomic"
222option when constructing rules allows you to extend the file and build up
223the complete wanted table.
Bart De Schuymer29749c62002-06-25 21:27:57 +0000224.SS
225PARAMETERS
Bart De Schuymer1abc55d2002-06-01 19:23:47 +0000226The following parameters make up a rule specification (as used in the add
227and delete commands). A "!" argument before the specification inverts the
228test for that specification. Apart from these standard parameters, there are others, see
229.BR "MATCH EXTENSIONS" .
230.TP
231.BR "-p, --protocol " "[!] \fIprotocol\fP"
232The protocol that was responsible for creating the frame. This can be a
233hexadecimal number, above
234.IR 0x0600 ,
235a name (e.g.
236.I ARP
237) or
238.BR LENGTH .
239The protocol field of the Ethernet frame can be used to denote the
240length of the header (802.2/802.3 networks). When the value of that field is
241below (or equals)
242.IR 0x0600 ,
243the value equals the size of the header and shouldn't be used as a
244protocol number. Instead, all frames where the protocol field is used as
245the length field are assumed to be of the same 'protocol'. The protocol
246name used in
247.B ebtables
248for these frames is
249.BR LENGTH .
250.br
251The file
252.B /etc/ethertypes
253can be used to show readable
254characters instead of hexadecimal numbers for the protocols. For example,
255.I 0x0800
256will be represented by
257.IR IPV4 .
258The use of this file is not case sensitive.
259See that file for more information. The flag
260.B --proto
261is an alias for this option.
262.TP
263.BR "-i, --in-interface " "[!] \fIname\fP"
264The interface via which a frame is received (for the
265.BR INPUT ,
266.BR FORWARD ,
267.BR PREROUTING " and " BROUTING
268chains). The flag
269.B --in-if
270is an alias for this option.
271.TP
272.BR "--logical-in " "[!] \fIname\fP"
273The (logical) bridge interface via which a frame is received (for the
274.BR INPUT ,
275.BR FORWARD ,
276.BR PREROUTING " and " BROUTING
277chains).
278.TP
279.BR "-o, --out-interface " "[!] \fIname\fP"
280The interface via which a frame is going to be sent (for the
281.BR OUTPUT ,
282.B FORWARD
283and
284.B POSTROUTING
285chains). The flag
286.B --out-if
287is an alias for this option.
288.TP
289.BR "--logical-out " "[!] \fIname\fP"
290The (logical) bridge interface via which a frame is going to be sent (for
291the
292.BR OUTPUT ,
293.B FORWARD
294and
295.B POSTROUTING
296chains).
297.TP
298.BR "-s, --source " "[!] \fIaddress\fP[/\fImask\fP]"
299The source mac address. Both mask and address are written as 6 hexadecimal
300numbers seperated by colons. Alternatively one can specify Unicast,
301Multicast or Broadcast.
302.br
303Unicast=00:00:00:00:00:00/01:00:00:00:00:00,
304Multicast=01:00:00:00:00:00/01:00:00:00:00:00 and
305Broadcast=ff:ff:ff:ff:ff:ff/ff:ff:ff:ff:ff:ff. Note that a broadcast
306address will also match the multicast specification. The flag
307.B --src
308is an alias for this option.
309.TP
310.BR "-d, --destination " "[!] \fIaddress\fP[/\fImask\fP]"
311The destination mac address. See -s (above) for more details. The flag
312.B --dst
313is an alias for this option.
314
315.SS OTHER OPTIONS
316.TP
317.B "-V, --version"
318Show the version of the userprogram.
319.TP
320.B "-h, --help"
321Give a brief description of the command syntax. Here you can also specify
322names of extensions and
323.B ebtables
324will try to write help about those extensions. E.g. ebtables -h snat log ip arp.
325.TP
Bart De Schuymer1abc55d2002-06-01 19:23:47 +0000326.BR "-j, --jump " "\fItarget\fP"
327The target of the rule. This is one of the following values:
328.BR ACCEPT ,
329.BR DROP ,
330.BR CONTINUE ,
Bart De Schuymer63e2c702002-08-01 15:30:15 +0000331.BR RETURN ,
332a target extension (see
333.BR "TARGET EXTENSIONS" ")"
334or a user defined chain name.
Bart De Schuymer86fe8602002-06-15 08:16:41 +0000335.TP
Bart De Schuymer2ac6b742002-07-20 16:14:38 +0000336.B --atomic file
Bart De Schuymer234bce92002-07-14 21:25:08 +0000337Let the command operate on the specified file. The data of the table to
338operate on will be extracted from the file and the result of the operation
339will be saved back into the file. If specified, this option should come
340before the command specification.
341.TP
Bart De Schuymer2ac6b742002-07-20 16:14:38 +0000342.B -M, --modprobe program
Bart De Schuymer234bce92002-07-14 21:25:08 +0000343When talking to the kernel, use this program to try to automatically load
344missing kernel modules.
Bart De Schuymer1abc55d2002-06-01 19:23:47 +0000345.SH MATCH EXTENSIONS
346.B ebtables
347extensions are precompiled into the userspace tool. So there is no need
348to explicitly load them with a -m option like in iptables. However, these
349extensions deal with functionality supported by supplemental kernel modules.
350.SS ip
351Specify ip specific fields. These will only work if the protocol equals
352.BR IPv4 .
353.TP
354.BR "--ip-source " "[!] \fIaddress\fP[/\fImask\fP]"
355The source ip address.
356The flag
357.B --ip-src
358is an alias for this option.
359.TP
360.BR "--ip-destination " "[!] \fIaddress\fP[/\fImask\fP]"
361The destination ip address.
362The flag
363.B --ip-dst
364is an alias for this option.
365.TP
366.BR "--ip-tos " "[!] \fItos\fP"
367The ip type of service, in hexadecimal numbers.
368.BR IPv4 .
369.TP
370.BR "--ip-protocol " "[!] \fIprotocol\fP"
371The ip protocol.
372The flag
373.B --ip-proto
374is an alias for this option.
375.SS arp
376Specify arp specific fields. These will only work if the protocol equals
377.BR ARP " or " RARP .
378.TP
379.BR "--arp-opcode " "[!] \fIopcode\fP"
Bart De Schuymer9553d9c2002-07-23 21:13:05 +0000380The (r)arp opcode (decimal or a string, for more details see
381.BR "ebtables -h arp" ).
Bart De Schuymer1abc55d2002-06-01 19:23:47 +0000382.TP
383.BR "--arp-htype " "[!] \fIhardware type\fP"
384The hardware type, this can be a decimal or the string "Ethernet". This
385is normally Ethernet (value 1).
386.TP
387.BR "--arp-ptype " "[!] \fIprotocol type\fP"
388The protocol type for which the (r)arp is used (hexadecimal or the string "IPv4").
389This is normally IPv4 (0x0800).
390.TP
391.BR "--arp-ip-src " "[!] \fIaddress\fP[/\fImask\fP]"
392The ARP IP source address specification.
393.TP
394.BR "--arp-ip-dst " "[!] \fIaddress\fP[/\fImask\fP]"
395The ARP IP destination address specification.
396.SS vlan
fnm3f794d5a2002-06-14 17:28:13 +0000397Specify 802.1Q Tag Control Information fields. These will only work if the protocol equals
fnm3ed7e9012002-06-25 16:43:23 +0000398.BR 802_1Q.
399Also see extension help by
Bart De Schuymer1abc55d2002-06-01 19:23:47 +0000400.BR "ebtables -h vlan" .
401.TP
402.BR "--vlan-id " "[!] \fIid\fP"
fnm3ed7e9012002-06-25 16:43:23 +0000403The VLAN identifier field, VID (decimal number from 0 to 4094).
Bart De Schuymer1abc55d2002-06-01 19:23:47 +0000404.TP
405.BR "--vlan-prio " "[!] \fIprio\fP"
fnm3ed7e9012002-06-25 16:43:23 +0000406The user_priority field, this can be a decimal number from 0 to 7.
407Required VID to be 0 (null VID) or not specified vlan-id parameter (in this case VID deliberately be set to 0).
fnm3f794d5a2002-06-14 17:28:13 +0000408.TP
fnm3ed7e9012002-06-25 16:43:23 +0000409.BR "--vlan-encap " "[!] \fItype\fP"
Bart De Schuymer9553d9c2002-07-23 21:13:05 +0000410The encapsulated Ethernet frame type/length, this can be a hexadecimal
411number from 0x0000 to 0xFFFF.
fnm3ed7e9012002-06-25 16:43:23 +0000412Usually it's 0x0800 (IPv4). See also
413.B /etc/ethertypes
414file.
Bart De Schuymer2ac6b742002-07-20 16:14:38 +0000415.SS mark_m
416.TP
Bart De Schuymer8a8ca612002-07-21 15:18:07 +0000417.BR "--mark " "[!] [\fIvalue\fP][/\fImask\fP]"
418Matches frames with the given unsigned mark value. If a mark value and
419mask is specified, the logical AND of the mark value of the frame and
420the user specified mask is taken before comparing with the user specified
421mark value. If only a mask is specified (start with '/') the logical AND
422of the mark value of the frame and the user specified mark is taken and
423the result is compared with zero.
Bart De Schuymer2ac6b742002-07-20 16:14:38 +0000424
Bart De Schuymer1abc55d2002-06-01 19:23:47 +0000425.SH WATCHER EXTENSION(S)
Bart De Schuymer9553d9c2002-07-23 21:13:05 +0000426Watchers are things that only look at frames passing by. These watchers only
427see the frame if the frame passes all the matches of the rule.
Bart De Schuymer1abc55d2002-06-01 19:23:47 +0000428.SS log
429The fact that the log module is a watcher lets us log stuff while giving a target
430by choice. Note that the log module therefore is not a target.
431.TP
432.B "--log"
433.br
434Use this if you won't specify any other log options, so if you want to use the default
435settings: log-prefix="", no arp logging, no ip logging, log-level=info.
436.TP
437.B --log-level "\fIlevel\fP"
438.br
439defines the logging level. For the possible values: ebtables -h log.
440The default level is
441.IR info .
442.TP
443.BR --log-prefix " \fItext\fP"
444.br
445defines the prefix to be printed before the logging information.
446.TP
447.B --log-ip
448.br
449will log the ip information when a frame made by the ip protocol matches
450the rule. The default is no ip information logging.
451.TP
452.B --log-arp
453.br
454will log the (r)arp information when a frame made by the (r)arp protocols
455matches the rule. The default is no (r)arp information logging.
456.SS TARGET EXTENSIONS
457.TP
458.B snat
459The
460.B snat
461target can only be used in the
462.BR POSTROUTING " chain of the " nat " table."
463It specifies that the source mac address has to be changed.
464.br
465.BR "--to-source " "\fIaddress\fP"
466.br
467The flag
468.B --to-src
469is an alias for this option.
470.br
471.BR "--snat-target " "\fItarget\fP"
472.br
473Specifies the standard target. After doing the snat, the rule still has
474to give a standard target so
475.B ebtables
476knows what to do.
477The default target is ACCEPT. Making it CONTINUE could let you use
478multiple target extensions on the same frame. Making it DROP doesn't
Bart De Schuymer29749c62002-06-25 21:27:57 +0000479make sense, but you could do that too. RETURN is also allowed. Note
Bart De Schuymer4c4447d2002-07-25 14:55:14 +0000480that using RETURN in a base chain is not allowed.
Bart De Schuymer1abc55d2002-06-01 19:23:47 +0000481.TP
482.B dnat
483The
484.B dnat
485target can only be used in the
486.BR BROUTING " chain of the " broute " table and the "
487.BR PREROUTING " and " OUTPUT " chains of the " nat " table."
488It specifies that the destination mac address has to be changed.
489.br
490.BR "--to-destination " "\fIaddress\fP"
491.br
492The flag
493.B --to-dst
494is an alias for this option.
495.br
496.BR "--dnat-target " "\fItarget\fP"
497.br
498Specifies the standard target. After doing the dnat, the rule still has to
499give a standard target so
500.B ebtables
501knows what to do.
502The default target is ACCEPT. Making it CONTINUE could let you use
503multiple target extensions on the same frame. Making it DROP only makes
504sense in the BROUTING chain but using the redirect target is more logical
Bart De Schuymer29749c62002-06-25 21:27:57 +0000505there. RETURN is also allowed. Note
Bart De Schuymer4c4447d2002-07-25 14:55:14 +0000506that using RETURN in a base chain is not allowed.
Bart De Schuymer1abc55d2002-06-01 19:23:47 +0000507.TP
508.B redirect
509The
510.B redirect
511target will change the MAC target address to that of the bridge device the
512frame arrived on. This target can only be used in the
513.BR BROUTING " chain of the " broute " table and the "
514.BR PREROUTING " chain of the " nat " table."
515.br
516.BR "--redirect-target " "\fItarget\fP"
517.br
518Specifies the standard target. After doing the MAC redirect, the rule
519still has to give a standard target so
520.B ebtables
521knows what to do.
522The default target is ACCEPT. Making it CONTINUE could let you use
523multiple target extensions on the same frame. Making it DROP in the
Bart De Schuymer29749c62002-06-25 21:27:57 +0000524BROUTING chain will let the frames be routed. RETURN is also allowed. Note
Bart De Schuymer4c4447d2002-07-25 14:55:14 +0000525that using RETURN in a base chain is not allowed.
Bart De Schuymer2ac6b742002-07-20 16:14:38 +0000526.TP
527.B mark
528The mark target can be used in every chain of every table. It is possible
529to use the marking of a frame/packet in both ebtables and iptables,
530if the br-nf code is compiled into the kernel. Both put the marking at the
531same place. So, you can consider this fact as a feature, or as something to
532watch out for.
533.br
534.BR "--mark-target " "\fItarget\fP"
535.br
536Specifies the standard target. After marking the frame, the rule
537still has to give a standard target so
538.B ebtables
539knows what to do.
540The default target is ACCEPT. Making it CONTINUE can let you do other
541things with the frame in other rules of the chain.
542.br
543.BR "--set-mark " "\fIvalue\fP"
544.br
545Mark the frame with the specified unsigned value.
546.br
Bart De Schuymer1abc55d2002-06-01 19:23:47 +0000547.SH FILES
548.I /etc/ethertypes
549.SH BUGS
550This won't work on an architecture with a user32/kernel64 situation like the Sparc64.
551.SH AUTHOR
552.IR "" "Bart De Schuymer <" bart.de.schuymer@pandora.be >
553.SH SEE ALSO
554.BR iptables "(8), " brctl (8)