blob: e28b9dd7af438a8d357b599ba3bac9653bde4ee7 [file] [log] [blame]
Bart De Schuymer9553d9c2002-07-23 21:13:05 +00001.TH EBTABLES 8 "23 July 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 Schuymer9553d9c2002-07-23 21:13:05 +000024ebtables (v.2.0) \- Ethernet bridge packet 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 Schuymer1abc55d2002-06-01 19:23:47 +000036.B "ebtables -L DB"
37.br
38.BR "ebtables -[b] [" "y/n" "]"
39.br
Bart De Schuymera02773a2002-07-15 19:42:11 +000040.BR "ebtables --init-table"
41.br
Bart De Schuymer234bce92002-07-14 21:25:08 +000042.BR "ebtables --atomic-init " file
43.br
44.BR "ebtables --atomic-save " file
45.br
46.BR "ebtables --atomic-commit " file
47.br
Bart De Schuymer1abc55d2002-06-01 19:23:47 +000048.SH DESCRIPTION
49.B ebtables
50is used to set up, maintain, and inspect the tables of Ethernet frame
51rules in the Linux kernel. It works analogous as iptables, but is less
52complicated. This man page is written with the man page of iptables
53next to it, so don't be surprised to see copied sentences and structure.
54
55There are three tables with built-in chains. Each chain is a list
56of rules which can match frames: each rule specifies what to do with a
57frame which matches. This is called a 'target'. The tables are used to
58divide functionality into different sets of chains.
59
60.SS TARGETS
61A firewall rule specifies criteria for a frame, and a target. If the
62frame does not match, the next rule in the chain is the examined one; if
63it does match, then the next thing to do is specified by the target.
64This target can be one of these values:
65.IR ACCEPT ,
66.IR DROP ,
67.IR CONTINUE ,
Bart De Schuymer29749c62002-06-25 21:27:57 +000068.IR RETURN ,
Bart De Schuymer1abc55d2002-06-01 19:23:47 +000069an extention.
70.PP
71.I ACCEPT
72means to let the frame through.
73.I DROP
74means the frame has to be dropped.
75.I CONTINUE
76means the next rule has to be checked. This can be handy to know how many
Bart De Schuymer29749c62002-06-25 21:27:57 +000077frames pass a certain point in the chain or to log those frames.
78.I RETURN
79means stop traversing this chain and resume at the next rule in the
80previous (calling) chain.
81For the
Bart De Schuymer1abc55d2002-06-01 19:23:47 +000082other targets see the
83.B "TARGET EXTENSIONS"
84section.
85.SS TABLES
86There are three tables.
87.TP
88.B "-t, --table"
89This option specifies the frame matching table which the command should
Bart De Schuymer29749c62002-06-25 21:27:57 +000090operate on. If specified it should be the first option. The tables are:
Bart De Schuymer1abc55d2002-06-01 19:23:47 +000091.BR filter ,
92this is the default table and contains three chains:
93.B INPUT
94(for frames destined for the bridge itself),
95.B OUTPUT
96(for locally-generated frames) and
97.B FORWARD
98(for frames being bridged).
99.BR nat ,
100this table is used to change the mac addresses and contains three chains:
101.B PREROUTING
102(for altering frames as soon as they come in),
103.B OUTPUT
104(for altering locally generated frames before they are bridged) and
105.B POSTROUTING
106(for altering frames as they are about to go out). A small note on the naming
107of chains POSTROUTING and PREROUTING: it would be more accurate to call them
108PREFORWARDING and POSTFORWARDING, but for all those who come from the
109.BR iptables " world to " ebtables
110it is easier to have the same names.
111.BR broute ,
112this table is used to make a brouter, it has one chain:
113.BR BROUTING .
114The targets
115.BR DROP " and " ACCEPT
116have special meaning in this table.
117.B DROP
118actually means the frame has to be routed, while
119.B ACCEPT
120means the frame has to be bridged. The
121.B BROUTING
122chain is traversed very early. It is only traversed by frames entering on
123a bridge enslaved nic that is in forwarding state. Normally those frames
124would be bridged, but you can decide otherwise here. The
125.B redirect
126target is very handy here.
127.SH OPTIONS
128The options can be divided into several different groups.
129.SS COMMANDS
130These options specify the specific actions to perform; only one of them
131can be specified on the command line (the
132.B -Z
133command is an exception). All these options only apply to the selected
134(or default) table.
135.TP
136.B "-A, --append"
137Append a rule to the end of the selected chain.
138.TP
139.B "-D, --delete"
140Delete the specified rule from the selected chain. There are two versions
141of this command. A rule number (starting at 1) or the complete rule can be
142specified.
143.TP
144.B "-I, --insert"
145Insert the specified rule into the selected chain at the specified rule number (1 meaning
146the head of the chain).
147.TP
148.B "-L, --list"
149List all rules in the selected chain. If no chain is selected, all chains
150are listed. If the chainname equals
151.BR DB ,
152.B ebtables
153will try to show the database. This database gives a survey of the kind of
154frames that pass the different bridge hooks. It uses the interfaces where
155the frame came in or will go out, the protocol field and the hook. This
156database is independent from the rest of
157.B ebtables
158and is in a different kernel module.
Bart De Schuymer234bce92002-07-14 21:25:08 +0000159.br
160The following three options change the output when not listing the
161database:
162.br
163.B "--Ln"
164.br
165Puts rule numbers in front of every rule.
166.br
167.B "--Lc"
168.br
169Puts the counter value at the end of every rule.
170.br
171.B "--Lx"
172.br
173The output is directly usable as executable commands in a script, to be
174run f.e. at bootup. This option is incompatible with the previous two
175options. When no chain name was specified for the
176.B "-L"
177command, all necessary commands for making the user defined chains and
178renaming the standard chains will be made.
Bart De Schuymer1abc55d2002-06-01 19:23:47 +0000179.TP
180.B "-F, --flush"
181Flush the selected chain. If no chain is selected, every chain will be
182flushed. This does not change the policy of the chain.
183.TP
Bart De Schuymera02773a2002-07-15 19:42:11 +0000184.B "--init-table"
185Replace the current table data by the initial table data.
186.TP
Bart De Schuymer1abc55d2002-06-01 19:23:47 +0000187.B "-Z, --zero"
188Put the counters of the selected chain on zero. If no chain is selected, all the counters
189are put on zero. This can be used in conjunction with the -L command (see above).
190This will cause the rule counters to be printed on the screen before they are put on zero.
191.TP
192.B "-P, --policy"
193Set the policy for the chain to the given target. The policy is either
194.B ACCEPT
195, either
196.BR DROP .
Bart De Schuymer29749c62002-06-25 21:27:57 +0000197.TP
198.B "-N, --new-chain"
199Create a new user-defined chain by the given name.
200.TP
201.B "-X, --delete-chain"
202Delete the specified user-defined chain. There must be no references to the
203chain,
204.B ebtables
205will complain if there are.
206.TP
207.B "-E, --rename-chain"
208Rename the specified chain to the new name. This has no effect on the
209structure of the table. It is also allowed to rename a base chain, f.e.
210if you like PREBRIDGING more than PREROUTING. Be sure to talk about the
211standard chain names when you would ask a question on a mailing list.
Bart De Schuymer234bce92002-07-14 21:25:08 +0000212.TP
213.B "--atomic-init"
Bart De Schuymera02773a2002-07-15 19:42:11 +0000214Copy the kernel's initial data of the table to the specified
Bart De Schuymer234bce92002-07-14 21:25:08 +0000215file. This can be used as the first action, after which rules are added
216to the file.
217.TP
218.B "--atomic-save"
Bart De Schuymera02773a2002-07-15 19:42:11 +0000219Copy the kernel's current data of the table to the specified
Bart De Schuymer234bce92002-07-14 21:25:08 +0000220file. This can be used as the first action, after which rules are added
221to the file.
222.TP
223.B "--atomic-commit"
224Replace the kernel table data with the data contained in the specified
225file. This is a useful command that allows you to put all your rules of a
226certain table into the kernel at once, saving the kernel a lot of precious
227time. The file which contains the table data is constructed by using
228either the
229.B "--atomic-init"
230or the
231.B "--atomic-save"
232command to get a starting file. After that, using the
233.B "--atomic"
234option when constructing rules allows you to extend the file and build up
235the complete wanted table.
Bart De Schuymer29749c62002-06-25 21:27:57 +0000236.SS
237PARAMETERS
Bart De Schuymer1abc55d2002-06-01 19:23:47 +0000238The following parameters make up a rule specification (as used in the add
239and delete commands). A "!" argument before the specification inverts the
240test for that specification. Apart from these standard parameters, there are others, see
241.BR "MATCH EXTENSIONS" .
242.TP
243.BR "-p, --protocol " "[!] \fIprotocol\fP"
244The protocol that was responsible for creating the frame. This can be a
245hexadecimal number, above
246.IR 0x0600 ,
247a name (e.g.
248.I ARP
249) or
250.BR LENGTH .
251The protocol field of the Ethernet frame can be used to denote the
252length of the header (802.2/802.3 networks). When the value of that field is
253below (or equals)
254.IR 0x0600 ,
255the value equals the size of the header and shouldn't be used as a
256protocol number. Instead, all frames where the protocol field is used as
257the length field are assumed to be of the same 'protocol'. The protocol
258name used in
259.B ebtables
260for these frames is
261.BR LENGTH .
262.br
263The file
264.B /etc/ethertypes
265can be used to show readable
266characters instead of hexadecimal numbers for the protocols. For example,
267.I 0x0800
268will be represented by
269.IR IPV4 .
270The use of this file is not case sensitive.
271See that file for more information. The flag
272.B --proto
273is an alias for this option.
274.TP
275.BR "-i, --in-interface " "[!] \fIname\fP"
276The interface via which a frame is received (for the
277.BR INPUT ,
278.BR FORWARD ,
279.BR PREROUTING " and " BROUTING
280chains). The flag
281.B --in-if
282is an alias for this option.
283.TP
284.BR "--logical-in " "[!] \fIname\fP"
285The (logical) bridge interface via which a frame is received (for the
286.BR INPUT ,
287.BR FORWARD ,
288.BR PREROUTING " and " BROUTING
289chains).
290.TP
291.BR "-o, --out-interface " "[!] \fIname\fP"
292The interface via which a frame is going to be sent (for the
293.BR OUTPUT ,
294.B FORWARD
295and
296.B POSTROUTING
297chains). The flag
298.B --out-if
299is an alias for this option.
300.TP
301.BR "--logical-out " "[!] \fIname\fP"
302The (logical) bridge interface via which a frame is going to be sent (for
303the
304.BR OUTPUT ,
305.B FORWARD
306and
307.B POSTROUTING
308chains).
309.TP
310.BR "-s, --source " "[!] \fIaddress\fP[/\fImask\fP]"
311The source mac address. Both mask and address are written as 6 hexadecimal
312numbers seperated by colons. Alternatively one can specify Unicast,
313Multicast or Broadcast.
314.br
315Unicast=00:00:00:00:00:00/01:00:00:00:00:00,
316Multicast=01:00:00:00:00:00/01:00:00:00:00:00 and
317Broadcast=ff:ff:ff:ff:ff:ff/ff:ff:ff:ff:ff:ff. Note that a broadcast
318address will also match the multicast specification. The flag
319.B --src
320is an alias for this option.
321.TP
322.BR "-d, --destination " "[!] \fIaddress\fP[/\fImask\fP]"
323The destination mac address. See -s (above) for more details. The flag
324.B --dst
325is an alias for this option.
326
327.SS OTHER OPTIONS
328.TP
329.B "-V, --version"
330Show the version of the userprogram.
331.TP
332.B "-h, --help"
333Give a brief description of the command syntax. Here you can also specify
334names of extensions and
335.B ebtables
336will try to write help about those extensions. E.g. ebtables -h snat log ip arp.
337.TP
Bart De Schuymer2ac6b742002-07-20 16:14:38 +0000338.BR "-b --db " [ "y/n" ]
Bart De Schuymer234bce92002-07-14 21:25:08 +0000339Enable (y) or disable (n) the database.
Bart De Schuymer1abc55d2002-06-01 19:23:47 +0000340.TP
341.BR "-j, --jump " "\fItarget\fP"
342The target of the rule. This is one of the following values:
343.BR ACCEPT ,
344.BR DROP ,
345.BR CONTINUE ,
346or a target extension, see
347.BR "TARGET EXTENSIONS" .
Bart De Schuymer86fe8602002-06-15 08:16:41 +0000348.TP
Bart De Schuymer2ac6b742002-07-20 16:14:38 +0000349.B --atomic file
Bart De Schuymer234bce92002-07-14 21:25:08 +0000350Let the command operate on the specified file. The data of the table to
351operate on will be extracted from the file and the result of the operation
352will be saved back into the file. If specified, this option should come
353before the command specification.
354.TP
Bart De Schuymer2ac6b742002-07-20 16:14:38 +0000355.B -M, --modprobe program
Bart De Schuymer234bce92002-07-14 21:25:08 +0000356When talking to the kernel, use this program to try to automatically load
357missing kernel modules.
Bart De Schuymer1abc55d2002-06-01 19:23:47 +0000358.SH MATCH EXTENSIONS
359.B ebtables
360extensions are precompiled into the userspace tool. So there is no need
361to explicitly load them with a -m option like in iptables. However, these
362extensions deal with functionality supported by supplemental kernel modules.
363.SS ip
364Specify ip specific fields. These will only work if the protocol equals
365.BR IPv4 .
366.TP
367.BR "--ip-source " "[!] \fIaddress\fP[/\fImask\fP]"
368The source ip address.
369The flag
370.B --ip-src
371is an alias for this option.
372.TP
373.BR "--ip-destination " "[!] \fIaddress\fP[/\fImask\fP]"
374The destination ip address.
375The flag
376.B --ip-dst
377is an alias for this option.
378.TP
379.BR "--ip-tos " "[!] \fItos\fP"
380The ip type of service, in hexadecimal numbers.
381.BR IPv4 .
382.TP
383.BR "--ip-protocol " "[!] \fIprotocol\fP"
384The ip protocol.
385The flag
386.B --ip-proto
387is an alias for this option.
388.SS arp
389Specify arp specific fields. These will only work if the protocol equals
390.BR ARP " or " RARP .
391.TP
392.BR "--arp-opcode " "[!] \fIopcode\fP"
Bart De Schuymer9553d9c2002-07-23 21:13:05 +0000393The (r)arp opcode (decimal or a string, for more details see
394.BR "ebtables -h arp" ).
Bart De Schuymer1abc55d2002-06-01 19:23:47 +0000395.TP
396.BR "--arp-htype " "[!] \fIhardware type\fP"
397The hardware type, this can be a decimal or the string "Ethernet". This
398is normally Ethernet (value 1).
399.TP
400.BR "--arp-ptype " "[!] \fIprotocol type\fP"
401The protocol type for which the (r)arp is used (hexadecimal or the string "IPv4").
402This is normally IPv4 (0x0800).
403.TP
404.BR "--arp-ip-src " "[!] \fIaddress\fP[/\fImask\fP]"
405The ARP IP source address specification.
406.TP
407.BR "--arp-ip-dst " "[!] \fIaddress\fP[/\fImask\fP]"
408The ARP IP destination address specification.
409.SS vlan
fnm3f794d5a2002-06-14 17:28:13 +0000410Specify 802.1Q Tag Control Information fields. These will only work if the protocol equals
fnm3ed7e9012002-06-25 16:43:23 +0000411.BR 802_1Q.
412Also see extension help by
Bart De Schuymer1abc55d2002-06-01 19:23:47 +0000413.BR "ebtables -h vlan" .
414.TP
415.BR "--vlan-id " "[!] \fIid\fP"
fnm3ed7e9012002-06-25 16:43:23 +0000416The VLAN identifier field, VID (decimal number from 0 to 4094).
Bart De Schuymer1abc55d2002-06-01 19:23:47 +0000417.TP
418.BR "--vlan-prio " "[!] \fIprio\fP"
fnm3ed7e9012002-06-25 16:43:23 +0000419The user_priority field, this can be a decimal number from 0 to 7.
420Required 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 +0000421.TP
fnm3ed7e9012002-06-25 16:43:23 +0000422.BR "--vlan-encap " "[!] \fItype\fP"
Bart De Schuymer9553d9c2002-07-23 21:13:05 +0000423The encapsulated Ethernet frame type/length, this can be a hexadecimal
424number from 0x0000 to 0xFFFF.
fnm3ed7e9012002-06-25 16:43:23 +0000425Usually it's 0x0800 (IPv4). See also
426.B /etc/ethertypes
427file.
Bart De Schuymer2ac6b742002-07-20 16:14:38 +0000428.SS mark_m
429.TP
Bart De Schuymer8a8ca612002-07-21 15:18:07 +0000430.BR "--mark " "[!] [\fIvalue\fP][/\fImask\fP]"
431Matches frames with the given unsigned mark value. If a mark value and
432mask is specified, the logical AND of the mark value of the frame and
433the user specified mask is taken before comparing with the user specified
434mark value. If only a mask is specified (start with '/') the logical AND
435of the mark value of the frame and the user specified mark is taken and
436the result is compared with zero.
Bart De Schuymer2ac6b742002-07-20 16:14:38 +0000437
Bart De Schuymer1abc55d2002-06-01 19:23:47 +0000438.SH WATCHER EXTENSION(S)
Bart De Schuymer9553d9c2002-07-23 21:13:05 +0000439Watchers are things that only look at frames passing by. These watchers only
440see the frame if the frame passes all the matches of the rule.
Bart De Schuymer1abc55d2002-06-01 19:23:47 +0000441.SS log
442The fact that the log module is a watcher lets us log stuff while giving a target
443by choice. Note that the log module therefore is not a target.
444.TP
445.B "--log"
446.br
447Use this if you won't specify any other log options, so if you want to use the default
448settings: log-prefix="", no arp logging, no ip logging, log-level=info.
449.TP
450.B --log-level "\fIlevel\fP"
451.br
452defines the logging level. For the possible values: ebtables -h log.
453The default level is
454.IR info .
455.TP
456.BR --log-prefix " \fItext\fP"
457.br
458defines the prefix to be printed before the logging information.
459.TP
460.B --log-ip
461.br
462will log the ip information when a frame made by the ip protocol matches
463the rule. The default is no ip information logging.
464.TP
465.B --log-arp
466.br
467will log the (r)arp information when a frame made by the (r)arp protocols
468matches the rule. The default is no (r)arp information logging.
469.SS TARGET EXTENSIONS
470.TP
471.B snat
472The
473.B snat
474target can only be used in the
475.BR POSTROUTING " chain of the " nat " table."
476It specifies that the source mac address has to be changed.
477.br
478.BR "--to-source " "\fIaddress\fP"
479.br
480The flag
481.B --to-src
482is an alias for this option.
483.br
484.BR "--snat-target " "\fItarget\fP"
485.br
486Specifies the standard target. After doing the snat, the rule still has
487to give a standard target so
488.B ebtables
489knows what to do.
490The default target is ACCEPT. Making it CONTINUE could let you use
491multiple target extensions on the same frame. Making it DROP doesn't
Bart De Schuymer29749c62002-06-25 21:27:57 +0000492make sense, but you could do that too. RETURN is also allowed. Note
Bart De Schuymer4c4447d2002-07-25 14:55:14 +0000493that using RETURN in a base chain is not allowed.
Bart De Schuymer1abc55d2002-06-01 19:23:47 +0000494.TP
495.B dnat
496The
497.B dnat
498target can only be used in the
499.BR BROUTING " chain of the " broute " table and the "
500.BR PREROUTING " and " OUTPUT " chains of the " nat " table."
501It specifies that the destination mac address has to be changed.
502.br
503.BR "--to-destination " "\fIaddress\fP"
504.br
505The flag
506.B --to-dst
507is an alias for this option.
508.br
509.BR "--dnat-target " "\fItarget\fP"
510.br
511Specifies the standard target. After doing the dnat, the rule still has to
512give a standard target so
513.B ebtables
514knows what to do.
515The default target is ACCEPT. Making it CONTINUE could let you use
516multiple target extensions on the same frame. Making it DROP only makes
517sense in the BROUTING chain but using the redirect target is more logical
Bart De Schuymer29749c62002-06-25 21:27:57 +0000518there. RETURN is also allowed. Note
Bart De Schuymer4c4447d2002-07-25 14:55:14 +0000519that using RETURN in a base chain is not allowed.
Bart De Schuymer1abc55d2002-06-01 19:23:47 +0000520.TP
521.B redirect
522The
523.B redirect
524target will change the MAC target address to that of the bridge device the
525frame arrived on. This target can only be used in the
526.BR BROUTING " chain of the " broute " table and the "
527.BR PREROUTING " chain of the " nat " table."
528.br
529.BR "--redirect-target " "\fItarget\fP"
530.br
531Specifies the standard target. After doing the MAC redirect, the rule
532still has to give a standard target so
533.B ebtables
534knows what to do.
535The default target is ACCEPT. Making it CONTINUE could let you use
536multiple target extensions on the same frame. Making it DROP in the
Bart De Schuymer29749c62002-06-25 21:27:57 +0000537BROUTING chain will let the frames be routed. RETURN is also allowed. Note
Bart De Schuymer4c4447d2002-07-25 14:55:14 +0000538that using RETURN in a base chain is not allowed.
Bart De Schuymer2ac6b742002-07-20 16:14:38 +0000539.TP
540.B mark
541The mark target can be used in every chain of every table. It is possible
542to use the marking of a frame/packet in both ebtables and iptables,
543if the br-nf code is compiled into the kernel. Both put the marking at the
544same place. So, you can consider this fact as a feature, or as something to
545watch out for.
546.br
547.BR "--mark-target " "\fItarget\fP"
548.br
549Specifies the standard target. After marking the frame, the rule
550still has to give a standard target so
551.B ebtables
552knows what to do.
553The default target is ACCEPT. Making it CONTINUE can let you do other
554things with the frame in other rules of the chain.
555.br
556.BR "--set-mark " "\fIvalue\fP"
557.br
558Mark the frame with the specified unsigned value.
559.br
Bart De Schuymer1abc55d2002-06-01 19:23:47 +0000560.SH FILES
561.I /etc/ethertypes
562.SH BUGS
563This won't work on an architecture with a user32/kernel64 situation like the Sparc64.
564.SH AUTHOR
565.IR "" "Bart De Schuymer <" bart.de.schuymer@pandora.be >
566.SH SEE ALSO
567.BR iptables "(8), " brctl (8)