blob: 525b55d0dc3b47b472f2c36a3e676172007a8594 [file] [log] [blame]
Bart De Schuymer29749c62002-06-25 21:27:57 +00001.TH EBTABLES 8 "26 June 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
fnm3f794d5a2002-06-14 17:28:13 +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 Schuymer234bce92002-07-14 21:25:08 +0000338.BR "-b --db [" "y/n" "]"
339Enable (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 Schuymer234bce92002-07-14 21:25:08 +0000349.BR "--atomic " file
350Let 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
355.BR "-M, --modprobe " "program"
356When 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"
393The (r)arp opcode (decimal or a string, for more details see ebtables -h arp).
394.TP
395.BR "--arp-htype " "[!] \fIhardware type\fP"
396The hardware type, this can be a decimal or the string "Ethernet". This
397is normally Ethernet (value 1).
398.TP
399.BR "--arp-ptype " "[!] \fIprotocol type\fP"
400The protocol type for which the (r)arp is used (hexadecimal or the string "IPv4").
401This is normally IPv4 (0x0800).
402.TP
403.BR "--arp-ip-src " "[!] \fIaddress\fP[/\fImask\fP]"
404The ARP IP source address specification.
405.TP
406.BR "--arp-ip-dst " "[!] \fIaddress\fP[/\fImask\fP]"
407The ARP IP destination address specification.
408.SS vlan
fnm3f794d5a2002-06-14 17:28:13 +0000409Specify 802.1Q Tag Control Information fields. These will only work if the protocol equals
fnm3ed7e9012002-06-25 16:43:23 +0000410.BR 802_1Q.
411Also see extension help by
Bart De Schuymer1abc55d2002-06-01 19:23:47 +0000412.BR "ebtables -h vlan" .
413.TP
414.BR "--vlan-id " "[!] \fIid\fP"
fnm3ed7e9012002-06-25 16:43:23 +0000415The VLAN identifier field, VID (decimal number from 0 to 4094).
Bart De Schuymer1abc55d2002-06-01 19:23:47 +0000416.TP
417.BR "--vlan-prio " "[!] \fIprio\fP"
fnm3ed7e9012002-06-25 16:43:23 +0000418The user_priority field, this can be a decimal number from 0 to 7.
419Required 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 +0000420.TP
fnm3ed7e9012002-06-25 16:43:23 +0000421.BR "--vlan-encap " "[!] \fItype\fP"
422The encapsulated ethernet frame type/length, this can be a hexadecimal number from 0x0000 to 0xFFFF.
423Usually it's 0x0800 (IPv4). See also
424.B /etc/ethertypes
425file.
Bart De Schuymer1abc55d2002-06-01 19:23:47 +0000426.SH WATCHER EXTENSION(S)
427Watchers are things that only look at frames passing by. These watchers only see the
428frame if the frame passes all the matches of the rule.
429.SS log
430The fact that the log module is a watcher lets us log stuff while giving a target
431by choice. Note that the log module therefore is not a target.
432.TP
433.B "--log"
434.br
435Use this if you won't specify any other log options, so if you want to use the default
436settings: log-prefix="", no arp logging, no ip logging, log-level=info.
437.TP
438.B --log-level "\fIlevel\fP"
439.br
440defines the logging level. For the possible values: ebtables -h log.
441The default level is
442.IR info .
443.TP
444.BR --log-prefix " \fItext\fP"
445.br
446defines the prefix to be printed before the logging information.
447.TP
448.B --log-ip
449.br
450will log the ip information when a frame made by the ip protocol matches
451the rule. The default is no ip information logging.
452.TP
453.B --log-arp
454.br
455will log the (r)arp information when a frame made by the (r)arp protocols
456matches the rule. The default is no (r)arp information logging.
457.SS TARGET EXTENSIONS
458.TP
459.B snat
460The
461.B snat
462target can only be used in the
463.BR POSTROUTING " chain of the " nat " table."
464It specifies that the source mac address has to be changed.
465.br
466.BR "--to-source " "\fIaddress\fP"
467.br
468The flag
469.B --to-src
470is an alias for this option.
471.br
472.BR "--snat-target " "\fItarget\fP"
473.br
474Specifies the standard target. After doing the snat, the rule still has
475to give a standard target so
476.B ebtables
477knows what to do.
478The default target is ACCEPT. Making it CONTINUE could let you use
479multiple target extensions on the same frame. Making it DROP doesn't
Bart De Schuymer29749c62002-06-25 21:27:57 +0000480make sense, but you could do that too. RETURN is also allowed. Note
481that using RETURN in a base chain will result in the CONTINUE behaviour.
Bart De Schuymer1abc55d2002-06-01 19:23:47 +0000482.TP
483.B dnat
484The
485.B dnat
486target can only be used in the
487.BR BROUTING " chain of the " broute " table and the "
488.BR PREROUTING " and " OUTPUT " chains of the " nat " table."
489It specifies that the destination mac address has to be changed.
490.br
491.BR "--to-destination " "\fIaddress\fP"
492.br
493The flag
494.B --to-dst
495is an alias for this option.
496.br
497.BR "--dnat-target " "\fItarget\fP"
498.br
499Specifies the standard target. After doing the dnat, the rule still has to
500give a standard target so
501.B ebtables
502knows what to do.
503The default target is ACCEPT. Making it CONTINUE could let you use
504multiple target extensions on the same frame. Making it DROP only makes
505sense in the BROUTING chain but using the redirect target is more logical
Bart De Schuymer29749c62002-06-25 21:27:57 +0000506there. RETURN is also allowed. Note
507that using RETURN in a base chain will result in the CONTINUE behaviour.
Bart De Schuymer1abc55d2002-06-01 19:23:47 +0000508.TP
509.B redirect
510The
511.B redirect
512target will change the MAC target address to that of the bridge device the
513frame arrived on. This target can only be used in the
514.BR BROUTING " chain of the " broute " table and the "
515.BR PREROUTING " chain of the " nat " table."
516.br
517.BR "--redirect-target " "\fItarget\fP"
518.br
519Specifies the standard target. After doing the MAC redirect, the rule
520still has to give a standard target so
521.B ebtables
522knows what to do.
523The default target is ACCEPT. Making it CONTINUE could let you use
524multiple target extensions on the same frame. Making it DROP in the
Bart De Schuymer29749c62002-06-25 21:27:57 +0000525BROUTING chain will let the frames be routed. RETURN is also allowed. Note
526that using RETURN in a base chain will result in the CONTINUE behaviour.
Bart De Schuymer1abc55d2002-06-01 19:23:47 +0000527.SH FILES
528.I /etc/ethertypes
529.SH BUGS
530This won't work on an architecture with a user32/kernel64 situation like the Sparc64.
531.SH AUTHOR
532.IR "" "Bart De Schuymer <" bart.de.schuymer@pandora.be >
533.SH SEE ALSO
534.BR iptables "(8), " brctl (8)