View | Details | Raw Unified | Return to bug 44541
Collapse All | Expand All

(-)ipfw.8 (-50 / +49 lines)
Lines 89-114 Link Here
89
.Fx
89
.Fx
90
STABLE still uses
90
STABLE still uses
91
.Nm ipfw1
91
.Nm ipfw1
92
unless the kernel is compiled with
92
unless 
93
.Cm options IPFW2 ,
94
and
95
.Nm /sbin/ipfw
93
.Nm /sbin/ipfw
96
and
94
and
97
.Nm /usr/lib/libalias
95
.Nm /usr/lib/libalias
98
are recompiled with
96
are recompiled with
99
.Cm -DIPFW2
97
.Cm -DIPFW2
100
and reinstalled (the same effect can be achieved by adding
98
and reinstalled (this can be achieved by adding
101
.Cm IPFW2=TRUE
99
.Cm IPFW2=TRUE
102
to
100
to
103
.Nm /etc/make.conf
101
.Nm /etc/make.conf
104
before a buildworld).
102
before a buildworld) and the kernel is recompiled with
103
.Cm options IPFW2 .
105
.Pp
104
.Pp
106
See the
105
See the
107
.Sx IPFW2 ENHANCEMENTS
106
.Sx IPFW2 ENHANCEMENTS
108
Section for a list of features which are not present in
107
section for a list of features which are not present in
109
.Nm ipfw1 .
108
.Nm ipfw1 .
110
This list can also be useful to revise your rules and
109
This list can also be provide hints for revising your rules and
111
write them more efficiently.
110
writing them more efficiently.
112
.Pp
111
.Pp
113
An
112
An
114
.Nm
113
.Nm
Lines 119-125 Link Here
119
numbered from 1 to 65535.
118
numbered from 1 to 65535.
120
Packets are passed to
119
Packets are passed to
121
.Nm
120
.Nm
122
in a number of different places in the protocol stack
121
from a number of different places in the protocol stack
123
(depending on the source and destination of the packet,
122
(depending on the source and destination of the packet,
124
it is possible that
123
it is possible that
125
.Nm
124
.Nm
Lines 171-177 Link Here
171
.Sx STATEFUL FIREWALL
170
.Sx STATEFUL FIREWALL
172
and
171
and
173
.Sx EXAMPLES
172
.Sx EXAMPLES
174
Sections below for more information on the stateful behaviour of
173
sections below for more information on the stateful behaviour of
175
.Nm .
174
.Nm .
176
.Pp
175
.Pp
177
All rules (including dynamic ones) have a few associated counters:
176
All rules (including dynamic ones) have a few associated counters:
Lines 205-213 Link Here
205
.Nm
204
.Nm
206
commands to atomically manipulate sets, such as enable,
205
commands to atomically manipulate sets, such as enable,
207
disable, swap sets, move all rules in a set to another
206
disable, swap sets, move all rules in a set to another
208
one, delete all rules in a set. These can be useful to
207
one, and delete all rules in a set. These can be useful to
209
install temporary configurations, or to test them.
208
install temporary configurations, or to test them.
210
See Section
209
See section
211
.Sx SETS OF RULES
210
.Sx SETS OF RULES
212
for more information on
211
for more information on
213
.Em sets .
212
.Em sets .
Lines 253-259 Link Here
253
.Ql sh\ /etc/rc.firewall ) ,
252
.Ql sh\ /etc/rc.firewall ) ,
254
or by processing a file of many
253
or by processing a file of many
255
.Nm
254
.Nm
256
rules,
255
rules
257
across a remote login session.
256
across a remote login session.
258
If a
257
If a
259
.Cm flush
258
.Cm flush
Lines 261-267 Link Here
261
configuration), it prints a message.
260
configuration), it prints a message.
262
Because all rules are flushed, the message might not be delivered
261
Because all rules are flushed, the message might not be delivered
263
to the login session, causing the remote login session to be closed
262
to the login session, causing the remote login session to be closed
264
and the remainder of the ruleset is not processed.
263
and the remainder of the ruleset to not be processed.
265
Access to the console would then be required to recover.
264
Access to the console would then be required to recover.
266
.It Fl S
265
.It Fl S
267
While listing rules, show the
266
While listing rules, show the
Lines 271-277 Link Here
271
listed.
270
listed.
272
.It Fl s Op Ar field
271
.It Fl s Op Ar field
273
While listing pipes, sort according to one of the four
272
While listing pipes, sort according to one of the four
274
counters (total and current packets or bytes).
273
counters (total and current, packets or bytes).
275
.It Fl t
274
.It Fl t
276
While listing, show last match timestamp.
275
While listing, show last match timestamp.
277
.El
276
.El
Lines 325-331 Link Here
325
.Cm queue
324
.Cm queue
326
commands are used to configure the traffic shaper, as shown in the
325
commands are used to configure the traffic shaper, as shown in the
327
.Sx TRAFFIC SHAPER CONFIGURATION
326
.Sx TRAFFIC SHAPER CONFIGURATION
328
Section below.
327
section below.
329
.Sh PACKET FLOW
328
.Sh PACKET FLOW
330
.Nm
329
.Nm
331
can be invoked from multiple places in the protocol stack,
330
can be invoked from multiple places in the protocol stack,
Lines 371-377 Link Here
371
.Nm
370
.Nm
372
is invoked, or the source of the packet.
371
is invoked, or the source of the packet.
373
If a rule contains some match patterns or actions which are not valid
372
If a rule contains some match patterns or actions which are not valid
374
for the place of invokation (e.g. trying
373
for the place of invocation (e.g. trying
375
to match a MAC header when
374
to match a MAC header when
376
.Nm
375
.Nm
377
is called from
376
is called from
Lines 381-387 Link Here
381
operator in front of such patterns will cause the pattern to
380
operator in front of such patterns will cause the pattern to
382
.Em always
381
.Em always
383
match on those packets, which might cause undesired results.
382
match on those packets, which might cause undesired results.
384
It is thus responsibility of
383
It is thus the responsibility of
385
the programmer, if necessary, to write a suitable ruleset to
384
the programmer, if necessary, to write a suitable ruleset to
386
differentiate among the possible places.
385
differentiate among the possible places.
387
.Cm skipto
386
.Cm skipto
Lines 423-429 Link Here
423
TCP, UDP, ICMP, etc.
422
TCP, UDP, ICMP, etc.
424
.It Source and dest. addresses and ports
423
.It Source and dest. addresses and ports
425
.It Direction
424
.It Direction
426
See Section
425
See section
427
.Sx PACKET FLOW
426
.Sx PACKET FLOW
428
.It Transmit and receive interface
427
.It Transmit and receive interface
429
By name or address
428
By name or address
Lines 440-446 Link Here
440
.It ICMP types
439
.It ICMP types
441
for ICMP packets
440
for ICMP packets
442
.It User/group ID
441
.It User/group ID
443
When the packet can be associate to a local socket.
442
When the packet can be associated with a local socket.
444
.El
443
.El
445
.Pp
444
.Pp
446
Note that some of the above information, e.g. source MAC or IP addresses and
445
Note that some of the above information, e.g. source MAC or IP addresses and
Lines 467-476 Link Here
467
.Ar net.inet.ip.fw.autoinc_step
466
.Ar net.inet.ip.fw.autoinc_step
468
which defaults to 100.
467
which defaults to 100.
469
If this is not possible (e.g. because we would go beyond the
468
If this is not possible (e.g. because we would go beyond the
470
maximum allowed rule number), the same number of the last
469
maximum allowed rule number), the number of the last
471
non-default value is used instead.
470
non-default value is used instead.
472
.It Cm set Ar set_number
471
.It Cm set Ar set_number
473
Each rule is associated to a
472
Each rule is associated with a
474
.Ar set_number
473
.Ar set_number
475
in the range 0..31, with the latter reserved for the
474
in the range 0..31, with the latter reserved for the
476
.Em default
475
.Em default
Lines 504-510 Link Here
504
(which is the default when the kernel is compiled with
503
(which is the default when the kernel is compiled with
505
.Dv IPFIREWALL_VERBOSE
504
.Dv IPFIREWALL_VERBOSE
506
) and the number of packets logged so far for that
505
) and the number of packets logged so far for that
507
particular rule does not exceed ther
506
particular rule does not exceed the
508
.Cm logamount
507
.Cm logamount
509
parameter.
508
parameter.
510
If no
509
If no
Lines 516-522 Link Here
516
.Pp
515
.Pp
517
Once the limit is reached, logging can be re-enabled by
516
Once the limit is reached, logging can be re-enabled by
518
clearing the logging counter
517
clearing the logging counter
519
or the packet counter for that entry, see the
518
or the packet counter for that entry; see the
520
.Cm resetlog
519
.Cm resetlog
521
command.
520
command.
522
.Pp
521
.Pp
Lines 558-564 Link Here
558
.It Cm fwd | forward Ar ipaddr Ns Op , Ns Ar port
557
.It Cm fwd | forward Ar ipaddr Ns Op , Ns Ar port
559
Change the next-hop on matching packets to
558
Change the next-hop on matching packets to
560
.Ar ipaddr ,
559
.Ar ipaddr ,
561
which can be an IP address in dotted quad or a host name.
560
which can be an IP address in dotted quad format or a host name.
562
The search terminates if this rule matches.
561
The search terminates if this rule matches.
563
.Pp
562
.Pp
564
If
563
If
Lines 600-606 Link Here
600
(for bandwidth limitation, delay, etc.).
599
(for bandwidth limitation, delay, etc.).
601
See the
600
See the
602
.Sx TRAFFIC SHAPER CONFIGURATION
601
.Sx TRAFFIC SHAPER CONFIGURATION
603
Section for further information.
602
section for further information.
604
The search terminates; however, on exit from the pipe and if
603
The search terminates; however, on exit from the pipe and if
605
the
604
the
606
.Xr sysctl 8
605
.Xr sysctl 8
Lines 633-639 Link Here
633
socket bound to port
632
socket bound to port
634
.Ar port .
633
.Ar port .
635
The search terminates and the original packet is accepted
634
The search terminates and the original packet is accepted
636
(but see Section
635
(but see section
637
.Sx BUGS
636
.Sx BUGS
638
below).
637
below).
639
.It Cm unreach Ar code
638
.It Cm unreach Ar code
Lines 798-804 Link Here
798
can be used to escape the dash
797
can be used to escape the dash
799
.Pq Ql -
798
.Pq Ql -
800
character in a service name (from a shell, the backslash must be
799
character in a service name (from a shell, the backslash must be
801
typed twice to avoid that the shell itself uses it as an escape
800
typed twice to avoid the shell itself interpreting it as an escape
802
character).
801
character).
803
.Pp
802
.Pp
804
.Dl "ipfw add count tcp from any ftp\e\e-data-ftp to any"
803
.Dl "ipfw add count tcp from any ftp\e\e-data-ftp to any"
Lines 946-952 Link Here
946
.Ar ver .
945
.Ar ver .
947
.It Cm keep-state
946
.It Cm keep-state
948
Upon a match, the firewall will create a dynamic rule, whose
947
Upon a match, the firewall will create a dynamic rule, whose
949
default behaviour is to matching bidirectional traffic between
948
default behaviour is to match bidirectional traffic between
950
source and destination IP/port using the same protocol.
949
source and destination IP/port using the same protocol.
951
The rule has a limited lifetime (controlled by a set of
950
The rule has a limited lifetime (controlled by a set of
952
.Xr sysctl 8
951
.Xr sysctl 8
Lines 991-1004 Link Here
991
(i.e. one or more comma-separated single values or ranges).
990
(i.e. one or more comma-separated single values or ranges).
992
You can use symbolic names for known values such as
991
You can use symbolic names for known values such as
993
.Em vlan , ipv4, ipv6 .
992
.Em vlan , ipv4, ipv6 .
994
Values can be enter as decimal or hexadecimal (if prefixed by 0x),
993
Values can be entered as decimal or hexadecimal (if prefixed by 0x),
995
and they are always printed as hexadecimal (unless the
994
and they are always printed as hexadecimal (unless the
996
.Cm -N
995
.Cm -N
997
option is used, in which case symbolic resolution will be attempted).
996
option is used, in which case symbolic resolution will be attempted).
998
.It Cm proto Ar protocol
997
.It Cm proto Ar protocol
999
Matches packets with the corresponding IPv4 protocol.
998
Matches packets with the corresponding IPv4 protocol.
1000
.It Cm recv | xmit | via Brq Ar ifX | Ar if Ns Cm * | Ar ipno | Ar any
999
.It Cm recv | xmit | via Brq Ar ifX | Ar if Ns Cm * | Ar ipno | Ar any
1001
Matches packets received, transmitted or be going through,
1000
Matches packets received, transmitted or going through,
1002
respectively, the interface specified by exact name
1001
respectively, the interface specified by exact name
1003
.Ns No ( Ar ifX Ns No ),
1002
.Ns No ( Ar ifX Ns No ),
1004
by device name
1003
by device name
Lines 1137-1143 Link Here
1137
Command execution is atomic on all the sets specified in the command.
1136
Command execution is atomic on all the sets specified in the command.
1138
By default, all sets are enabled.
1137
By default, all sets are enabled.
1139
.Pp
1138
.Pp
1140
When you disable a set, its rules behave as if they were not existing
1139
When you disable a set, its rules behave as if they do not exist
1141
in the firewall configuration, with only one exception:
1140
in the firewall configuration, with only one exception:
1142
.Bl -bullet
1141
.Bl -bullet
1143
.It
1142
.It
Lines 1160-1166 Link Here
1160
.Pp
1159
.Pp
1161
See the
1160
See the
1162
.Sx EXAMPLES
1161
.Sx EXAMPLES
1163
Section on some possible uses of sets of rules.
1162
section on some possible uses of sets of rules.
1164
.Sh STATEFUL FIREWALL
1163
.Sh STATEFUL FIREWALL
1165
Stateful operation is a way for the firewall to dynamically
1164
Stateful operation is a way for the firewall to dynamically
1166
create rules for specific flows when packets that
1165
create rules for specific flows when packets that
Lines 1220-1233 Link Here
1220
of the flow and the setting of some
1219
of the flow and the setting of some
1221
.Cm sysctl
1220
.Cm sysctl
1222
variables.
1221
variables.
1223
See Section
1222
See section
1224
.Sx SYSCTL VARIABLES
1223
.Sx SYSCTL VARIABLES
1225
for more details.
1224
for more details.
1226
For TCP sessions, dynamic rules can be instructed to periodically
1225
For TCP sessions, dynamic rules can be instructed to periodically
1227
send keepalive packets to refresh the state of the rule when it is
1226
send keepalive packets to refresh the state of the rule when it is
1228
about to expire.
1227
about to expire.
1229
.Pp
1228
.Pp
1230
See Section
1229
See section
1231
.Sx EXAMPLES
1230
.Sx EXAMPLES
1232
for more examples on how to use dynamic rules.
1231
for more examples on how to use dynamic rules.
1233
.Sh TRAFFIC SHAPER CONFIGURATION
1232
.Sh TRAFFIC SHAPER CONFIGURATION
Lines 1283-1289 Link Here
1283
.Sm on
1282
.Sm on
1284
.Pp
1283
.Pp
1285
A value of 0 (default) means unlimited bandwidth.
1284
A value of 0 (default) means unlimited bandwidth.
1286
The unit must follow immediately the number, as in
1285
The unit must immediately follow the number, as in
1287
.Pp
1286
.Pp
1288
.Dl "ipfw pipe 1 config bw 300Kbit/s"
1287
.Dl "ipfw pipe 1 config bw 300Kbit/s"
1289
.Pp
1288
.Pp
Lines 1607-1618 Link Here
1607
Default is no.
1606
Default is no.
1608
.El
1607
.El
1609
.Sh IPFW2 ENHANCEMENTS
1608
.Sh IPFW2 ENHANCEMENTS
1610
This Section lists the features that have been introduced in
1609
This section lists the features that have been introduced in
1611
.Nm ipfw2
1610
.Nm ipfw2
1612
and were not present in
1611
which were not present in
1613
.Nm ipfw1 .
1612
.Nm ipfw1 .
1614
We list them in order of the potential impact that they can
1613
We list them in order of the potential impact that they can
1615
have in writing your rulesets.
1614
have on writing rulesets.
1616
You might want to consider using these features in order to
1615
You might want to consider using these features in order to
1617
write your rulesets in a more efficient way.
1616
write your rulesets in a more efficient way.
1618
.Bl -tag -width indent
1617
.Bl -tag -width indent
Lines 1633-1639 Link Here
1633
.Pp
1632
.Pp
1634
The
1633
The
1635
.Cm layer2
1634
.Cm layer2
1636
options might seem redundant, but it is necessary -- packets
1635
option might seem redundant, but it is necessary -- packets
1637
passed to the firewall from layer3 will not have a MAC header,
1636
passed to the firewall from layer3 will not have a MAC header,
1638
so the
1637
so the
1639
.Cm mac-type ip
1638
.Cm mac-type ip
Lines 1697-1703 Link Here
1697
does not implement sets of rules.
1696
does not implement sets of rules.
1698
.It MAC header filtering and Layer-2 firewalling.
1697
.It MAC header filtering and Layer-2 firewalling.
1699
.Nm ipfw1
1698
.Nm ipfw1
1700
does not implement filtering on MAC header fields, nor it is
1699
does not implement filtering on MAC header fields, nor is it
1701
invoked on packets from
1700
invoked on packets from
1702
.Cm ether_demux()
1701
.Cm ether_demux()
1703
and
1702
and
Lines 1727-1733 Link Here
1727
.Sh EXAMPLES
1726
.Sh EXAMPLES
1728
There are far too many possible uses of
1727
There are far too many possible uses of
1729
.Nm
1728
.Nm
1730
so this Section will only give a small set of examples.
1729
so this section will only give a small set of examples.
1731
.Pp
1730
.Pp
1732
.Ss BASIC PACKET FILTERING
1731
.Ss BASIC PACKET FILTERING
1733
This command adds an entry which denies all tcp packets from
1732
This command adds an entry which denies all tcp packets from
Lines 1738-1744 Link Here
1738
.Pp
1737
.Pp
1739
.Dl "ipfw add deny tcp from cracker.evil.org to wolf.tambov.su telnet"
1738
.Dl "ipfw add deny tcp from cracker.evil.org to wolf.tambov.su telnet"
1740
.Pp
1739
.Pp
1741
This one disallows any connection from the entire crackers
1740
This one disallows any connection from the entire cracker's
1742
network to my host:
1741
network to my host:
1743
.Pp
1742
.Pp
1744
.Dl "ipfw add deny ip from 123.45.67.0/24 to my.host.org"
1743
.Dl "ipfw add deny ip from 123.45.67.0/24 to my.host.org"
Lines 1796-1802 Link Here
1796
rule.
1795
rule.
1797
A
1796
A
1798
.Cm check-state
1797
.Cm check-state
1799
rule should be usually placed near the beginning of the
1798
rule should usually be placed near the beginning of the
1800
ruleset to minimize the amount of work scanning the ruleset.
1799
ruleset to minimize the amount of work scanning the ruleset.
1801
Your mileage may vary.
1800
Your mileage may vary.
1802
.Pp
1801
.Pp
Lines 1869-1875 Link Here
1869
.Nm
1868
.Nm
1870
rules are checked both on incoming and outgoing packets.
1869
rules are checked both on incoming and outgoing packets.
1871
.Pp
1870
.Pp
1872
Should we like to simulate a bidirectional link with bandwidth
1871
Should we want to simulate a bidirectional link with bandwidth
1873
limitations, the correct way is the following:
1872
limitations, the correct way is the following:
1874
.Pp
1873
.Pp
1875
.Dl "ipfw add pipe 1 ip from any to any out"
1874
.Dl "ipfw add pipe 1 ip from any to any out"
Lines 1878-1884 Link Here
1878
.Dl "ipfw pipe 2 config bw 64Kbit/s queue 10Kbytes"
1877
.Dl "ipfw pipe 2 config bw 64Kbit/s queue 10Kbytes"
1879
.Pp
1878
.Pp
1880
The above can be very useful, e.g. if you want to see how
1879
The above can be very useful, e.g. if you want to see how
1881
your fancy Web page will look for a residential user which
1880
your fancy Web page will look for a residential user who
1882
is connected only through a slow link.
1881
is connected only through a slow link.
1883
You should not use only one pipe for both directions, unless
1882
You should not use only one pipe for both directions, unless
1884
you want to simulate a half-duplex medium (e.g. AppleTalk,
1883
you want to simulate a half-duplex medium (e.g. AppleTalk,
Lines 1886-1892 Link Here
1886
It is not necessary that both pipes have the same configuration,
1885
It is not necessary that both pipes have the same configuration,
1887
so we can also simulate asymmetric links.
1886
so we can also simulate asymmetric links.
1888
.Pp
1887
.Pp
1889
Should we like to verify network performance with the RED queue
1888
Should we want to verify network performance with the RED queue
1890
management algorithm:
1889
management algorithm:
1891
.Pp
1890
.Pp
1892
.Dl "ipfw add pipe 1 ip from any to any"
1891
.Dl "ipfw add pipe 1 ip from any to any"
Lines 1894-1900 Link Here
1894
.Pp
1893
.Pp
1895
Another typical application of the traffic shaper is to
1894
Another typical application of the traffic shaper is to
1896
introduce some delay in the communication.
1895
introduce some delay in the communication.
1897
This can affect a lot applications which do a lot of Remote
1896
This can signficantly affect applications which do a lot of Remote
1898
Procedure Calls, and where the round-trip-time of the
1897
Procedure Calls, and where the round-trip-time of the
1899
connection often becomes a limiting factor much more than
1898
connection often becomes a limiting factor much more than
1900
bandwidth:
1899
bandwidth:
Lines 1995-2007 Link Here
1995
.Sh BUGS
1994
.Sh BUGS
1996
The syntax has grown over the years and sometimes it might be confusing.
1995
The syntax has grown over the years and sometimes it might be confusing.
1997
Unfortunately, backward compatibility prevents cleaning up mistakes
1996
Unfortunately, backward compatibility prevents cleaning up mistakes
1998
done in the definition of the syntax.
1997
made in the definition of the syntax.
1999
.Pp
1998
.Pp
2000
.Em !!! WARNING !!!
1999
.Em !!! WARNING !!!
2001
.Pp
2000
.Pp
2002
Misconfiguring the firewall can put your computer in an unusable state,
2001
Misconfiguring the firewall can put your computer in an unusable state,
2003
possibly shutting down network services and requiring console access to
2002
possibly shutting down network services and requiring console access to
2004
regain control to it.
2003
regain control of it.
2005
.Pp
2004
.Pp
2006
Incoming packet fragments diverted by
2005
Incoming packet fragments diverted by
2007
.Cm divert
2006
.Cm divert

Return to bug 44541