2 .\" $FreeBSD: src/sbin/ip6fw/ip6fw.8,v 1.3.2.12 2003/02/23 20:17:15 trhodes Exp $
3 .\" $DragonFly: src/sbin/ip6fw/ip6fw.8,v 1.7 2008/09/02 11:50:45 matthias Exp $
7 .\" Copyright (C) 1998, 1999, 2000 and 2001 WIDE Project.
8 .\" All rights reserved.
10 .\" Redistribution and use in source and binary forms, with or without
11 .\" modification, are permitted provided that the following conditions
13 .\" 1. Redistributions of source code must retain the above copyright
14 .\" notice, this list of conditions and the following disclaimer.
15 .\" 2. Redistributions in binary form must reproduce the above copyright
16 .\" notice, this list of conditions and the following disclaimer in the
17 .\" documentation and/or other materials provided with the distribution.
18 .\" 3. Neither the name of the project nor the names of its contributors
19 .\" may be used to endorse or promote products derived from this software
20 .\" without specific prior written permission.
22 .\" THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
23 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
26 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
39 .Nd controlling utility for IPv6 firewall
46 .Ar macro Ns Op = Ns Ar value
80 .Op via Ar name | ipv6no
83 To ease configuration, rules can be put into a file which is
86 as shown in the first synopsis line.
91 will be read line by line and applied as arguments to the
95 Optionally, a preprocessor can be specified using
99 is to be piped through.
100 Useful preprocessors include
106 doesn't start with a slash
108 as its first character, the usual
110 name search is performed.
111 Care should be taken with this in environments where not all
112 file systems are mounted (yet) by the time
114 is being run (e.g. when they are mounted over NFS).
117 has been specified, optional
121 specifications can follow and will be passed on to the preprocessor.
122 This allows for flexible configuration files (like conditionalizing
123 them on the local hostname) and the use of macros to centralize
124 frequently required arguments like IP addresses.
128 code works by going through the rule-list for each packet,
129 until a match is found.
130 All rules have two associated counters, a packet count and
132 These counters are updated when a packet matches the rule.
134 The rules are ordered by a
136 from 1 to 65534 that is used
137 to order and delete rules.
138 Rules are tried in increasing order, and the
139 first rule that matches a packet applies.
140 Multiple rules may share the same number and apply in
141 the order in which they were added.
143 If a rule is added without a number, it is numbered 100 higher
144 than the previous rule.
145 If the highest defined rule number is
146 greater than 65434, new rules are appended to the last rule.
148 The delete operation deletes the first rule with number
152 The list command prints out the current rule set.
154 The show command is equivalent to `ip6fw -a list'.
156 The zero operation zeroes the counters associated with rule number
159 The flush operation removes all rules.
161 Any command beginning with a
163 or being all blank, is ignored.
165 One rule is always present:
166 .Bd -literal -offset center
167 65535 deny all from any to any
170 This rule is the default policy, i.e., don't allow anything at all.
171 Your job in setting up rules is to modify this policy to match your
174 The following options are available:
177 While listing, show counter values. See also
181 Don't ask for confirmation for commands that can cause problems if misused
184 if there is no tty associated with the process, this is implied.
186 While adding, zeroing or flushing, be quiet about actions (implies '-f').
187 This is useful for adjusting rules by executing multiple ip6fw commands in a
188 script (e.g. sh /etc/rc.firewall), or by processing a file of many ip6fw rules,
189 across a remote login session. If a flush is performed in normal
190 (verbose) mode, it prints a message. Because all rules are flushed, the
191 message cannot be delivered to the login session, the login session is
192 closed and the remainder of the ruleset is not processed. Access to the
193 console is required to recover.
195 While listing, show last match timestamp.
197 Try to resolve addresses and service names in output.
201 .Bl -hang -offset flag -width 16n
203 Allow packets that match rule.
204 The search terminates.
211 Discard packets that match this rule.
212 The search terminates.
217 (Deprecated.) Discard packets that match this rule, and try to send an ICMPv6
218 host unreachable notice.
219 The search terminates.
221 Discard packets that match this rule, and try to send an ICMPv6
222 unreachable notice with code
226 is a number from zero to 255, or one of these aliases:
233 The search terminates.
236 Discard packets that match this rule,
237 and try to send a TCP reset (RST) notice.
238 The search terminates
239 .Em ( "not working yet" ) .
241 Update counters for all packets that match rule.
242 The search continues with the next rule.
244 Skip all subsequent rules numbered less than
246 The search continues with the first rule numbered
251 If the kernel was compiled with
252 .Dv IPV6FIREWALL_VERBOSE ,
253 then when a packet matches a rule with the
255 keyword or a clear/resetlog is performed, a message will be logged to
257 or, if that fails, to the console. If the kernel was compiled with the
258 .Dv IPV6FIREWALL_VERBOSE_LIMIT
259 option, then logging will cease after the number of packets
260 specified by the option are received for that particular
262 When this limit is reached, the limit and rule number will be logged.
263 Logging may then be re-enabled by clearing
264 the packet counter for that entry.
268 logging and the default log limit are adjustable dynamically through the
273 .Bl -hang -offset flag -width 16n
280 Only TCP packets match.
282 Only UDP packets match.
284 Only ICMPv6 packets match.
286 Only packets for the specified protocol matches (see
288 for a complete list).
294 .Bl -hang -offset flag
295 .It Ar <address/prefixlen>
300 .Em <address/prefixlen>
302 .Bl -hang -offset flag -width 16n
304 An ipv6number of the form
306 .It Ar ipv6no/prefixlen
307 An ipv6number with a prefix length of the form
308 .Li fec0::1:2:3:4/112 .
311 The sense of the match can be inverted by preceding an address with the
313 modifier, causing all other addresses to be matched instead.
315 does not affect the selection of port numbers.
317 With the TCP and UDP protocols, optional
320 .Bl -hang -offset flag
321 .It Ns {port|port-port} Ns Op ,port Ns Op ,...
326 may be used instead of numeric port values.
327 A range may only be specified as the first value,
328 and the length of the port list is limited to
329 .Dv IPV6_FW_MAX_PORTS
331 .In net/ip6fw/ip6_fw.h )
334 Fragmented packets which have a non-zero offset (i.e. not the first
335 fragment) will never match a rule which has one or more port
336 specifications. See the
338 option for details on matching fragmented packets.
340 Rules can apply to packets when they are incoming, or outgoing, or both.
343 keyword indicates the rule should only match incoming packets.
346 keyword indicates the rule should only match outgoing packets.
348 To match packets going through a certain interface, specify
351 .Bl -hang -offset flag -width 16n
353 Packet must be going through interface
356 Packet must be going through interface
358 where X is any unit number.
360 Packet must be going through
364 Packet must be going through the interface having IPv6 address
370 keyword causes the interface to always be checked.
377 then the only receive or transmit interface (respectively) is checked.
378 By specifying both, it is possible to match packets based on both receive
379 and transmit interface, e.g.:
381 .Dl "ip6fw add 100 deny ip from any to any out recv ed0 xmit ed1"
385 interface can be tested on either incoming or outgoing packets, while the
387 interface can only be tested on outgoing packets.
403 A packet may not have a receive or transmit interface: packets originating
404 from the local host have no receive interface. while packets destined for
405 the local host have no transmit interface.
409 .Bl -hang -offset flag -width 16n
411 Matches if the packet is a fragment and this is not the first fragment
414 may not be used in conjunction with either
416 or TCP/UDP port specifications.
418 Matches if this packet was on the way in.
420 Matches if this packet was on the way out.
421 .It ipv6options Ar spec
422 Matches if the IPv6 header contains the comma separated list of
425 The supported IPv6 options are:
427 (hop-by-hop options header),
433 (encapsulating security payload),
435 (authentication header),
437 (no next header), and
439 (destination options header).
440 The absence of a particular option may be denoted
443 .Em ( "not working yet" ) .
445 Matches packets that have the RST or ACK bits set.
448 Matches packets that have the SYN bit set but no ACK bit.
451 Matches if the TCP header contains the comma separated list of
454 The supported TCP flags are:
462 The absence of a particular flag may be denoted
465 A rule which contains a
467 specification can never match a fragmented packet which has
468 a non-zero offset. See the
470 option for details on matching fragmented packets.
471 .It icmptypes Ar types
472 Matches if the ICMPv6 type is in the list
474 The list may be specified as any combination of ranges
475 or individual types separated by commas.
478 Here are some important points to consider when designing your
480 .Bl -bullet -offset flag
482 Remember that you filter both packets going in and out.
483 Most connections need packets going in both directions.
485 Remember to test very carefully.
486 It is a good idea to be near the console when doing this.
488 Don't forget the loopback interface.
491 There is one kind of packet that the firewall will always discard,
492 that is an IPv6 fragment with a fragment offset of one.
493 This is a valid packet, but it only has one use, to try to circumvent
496 If you are logged in over a network, loading the KLD version of
498 is probably not as straightforward as you would think
499 .Em ( "not supported" ) .
500 I recommend this command line:
501 .Bd -literal -offset center
502 kldload /boot/modules/ip6fw_mod.o && \e
503 ip6fw add 32000 allow all from any to any
506 Along the same lines, doing an
507 .Bd -literal -offset center
511 in similar surroundings is also a bad idea.
515 This command adds an entry which denies all tcp packets from
517 to the telnet port of
519 from being forwarded by the host:
521 .Dl ip6fw add deny tcp from hacker.evil.org to wolf.tambov.su 23
523 This one disallows any connection from the entire hackers network to
526 .Dl ip6fw add deny all from fec0::123:45:67:0/112 to my.host.org
528 Here is a good usage of the list command to see accounting records
529 and timestamp information:
533 or in short form without timestamps:
547 utility first appeared in
550 .An Ugen J. S. Antsilevich ,
551 .An Poul-Henning Kamp ,
556 API based upon code written by
560 .Em WARNING!!WARNING!!WARNING!!WARNING!!WARNING!!WARNING!!WARNING!!
562 This program can put your computer in rather unusable state.
564 using it for the first time, work on the console of the computer, and
567 do anything you don't understand.
569 When manipulating/adding chain entries, service and protocol names are