11.\"
2- .Dd December 29, 2025
2+ .Dd March 1, 2026
33.Dt IPFW 8
44.Os
55.Sh NAME
@@ -1428,8 +1428,7 @@ The second format
14281428with multiple addresses) is provided for convenience only and
14291429its use is discouraged.
14301430.It Ar addr : Oo Cm not Oc Bro
1431- .Cm any | me | me6 |
1432- .Cm table Ns Pq Ar name Ns Op , Ns Ar value
1431+ .Cm any | me | me6 | Ar table-ref
14331432.Ar | addr-list | addr-set
14341433.Brc
14351434.Bl -tag -width indent
@@ -1441,26 +1440,32 @@ Matches any IP address configured on an interface in the system.
14411440Matches any IPv6 address configured on an interface in the system.
14421441The address list is evaluated at the time the packet is
14431442analysed.
1444- .It Cm table Ns Pq Ar name Ns Op , Ns Ar value
1443+ .El
1444+ .It Ar table-ref :
1445+ A table lookup can be specified in one of the following ways:
1446+ .Bl -tag -width indent
1447+ .It table Ns Pq Ar name Ns
14451448Matches any IPv4 or IPv6 address for which an entry exists in the lookup table
14461449.Ar number .
1447- If an optional 32-bit unsigned
1450+ .It table Ns Pq Ar name , Ns Ar value
1451+ Matches any IPv4 or IPv6 address for which an entry exists in the lookup table
1452+ .Ar number
1453+ and 32-bit unsigned
14481454.Ar value
1449- is also specified, an entry will match only if it has this value.
1450- If
1455+ specified matchess entry value.
1456+ .It table Ns Pq Ar name , Ns Ar value-type Ns = Ns Ar value
1457+ Matches any IPv4 or IPv6 address for which an entry exists in the lookup table
1458+ .Ar number
1459+ and 32-bit unsigned
14511460.Ar value
1452- is specified in form
1453- .Ar valtype=value ,
1454- then specified value type field will be checked.
1455- It can be
1456- .Ar skipto, pipe, fib, nat, dscp, tag, divert, netgraph, limit, nh4
1457- and
1458- .Ar mark.
1459-
1461+ specified matches corresponding
1462+ .Ar value-type
1463+ field for the record found.
1464+ .El
1465+ .Pp
14601466See the
14611467.Sx LOOKUP TABLES
14621468section below for more information on lookup tables.
1463- .El
14641469.It Ar addr-list : ip-addr Ns Op , Ns Ar addr-list
14651470.It Ar ip-addr :
14661471A host or subnet address specified in one of the following ways:
@@ -1681,9 +1686,9 @@ and IPsec encapsulating security payload headers
16811686.It Cm fib Ar fibnum
16821687Matches a packet that has been tagged to use
16831688the given FIB (routing table) number.
1684- .It Cm flow Ar table Ns Pq Ar name Ns Op , Ns Ar value
1685- Search for the flow entry in lookup table
1686- .Ar name .
1689+ .It Cm flow Ar table-ref
1690+ Search for the flow entry in lookup table specified by
1691+ .Ar table-ref .
16871692If not found, the match fails.
16881693Otherwise, the match succeeds and
16891694.Cm tablearg
@@ -1699,16 +1704,16 @@ Matches IPv6 packets containing any of the flow labels given in
16991704.Ar labels .
17001705.Ar labels
17011706is a comma separated list of numeric flow labels.
1702- .It Cm dst-mac Ar table Ns Pq Ar name Ns Op , Ns Ar value
1703- Search for the destination MAC address entry in lookup table
1704- .Ar name .
1707+ .It Cm dst-mac Ar table-ref
1708+ Search for the destination MAC address entry in lookup table specified by
1709+ .Ar table-ref .
17051710If not found, the match fails.
17061711Otherwise, the match succeeds and
17071712.Cm tablearg
17081713is set to the value extracted from the table.
1709- .It Cm src-mac Ar table Ns Pq Ar name Ns Op , Ns Ar value
1710- Search for the source MAC address entry in lookup table
1711- .Ar name .
1714+ .It Cm src-mac Ar table-ref
1715+ Search for the source MAC address entry in lookup table specified by
1716+ .Ar table-ref .
17121717If not found, the match fails.
17131718Otherwise, the match succeeds and
17141719.Cm tablearg
@@ -1926,8 +1931,10 @@ set of parameters as specified in the rule.
19261931One or more
19271932of source and destination addresses and ports can be
19281933specified.
1929- .It Cm lookup Bro Cm dst-ip | dst-port | dst-mac | src-ip | src-port | src-mac | uid |
1930- .Cm jail | dscp | mark | rulenum Brc Ar name
1934+ .It Cm lookup Bro Cm dst-ip | dst-ip4 | dst-ip6 | dst-port | dst-mac | src-ip |
1935+ .Cm src-ip4 | src-ip6 | src-port | src-mac | uid | jail | dscp | mark |
1936+ .Cm rulenum
1937+ .Brc Ns Oo : Ns Ar bitmask Oc Ar name
19311938Search an entry in lookup table
19321939.Ar name
19331940that matches the field specified as argument.
@@ -1936,8 +1943,56 @@ Otherwise, the match succeeds and
19361943.Cm tablearg
19371944is set to the value extracted from the table.
19381945.Pp
1946+ If an optional
1947+ .Ar bitmask
1948+ is specified, value of the field is altered by bitwize AND with
1949+ .Ar bitmask
1950+ and resulting value is being searched instead of the original one.
1951+ The
1952+ .Ar bitmask
1953+ is accepted in the following formats:
1954+ .Bl -enum -width indent
1955+ .It
1956+ In a dotted-quad form, e.g. 127.88.34.0.
1957+ This form can be used for IPv4 lookups as well as for all numeric lookup
1958+ types.
1959+ .It
1960+ As a 32-bit number, e.g. 0xf00baa1 or 255.
1961+ This form can be used for IPv4 lookups as well as for all numeric lookup
1962+ types.
1963+ .It
1964+ As an IPv6 address when specified alongwith
1965+ .Cm dst-ip6
1966+ or
1967+ .Cm src-ip6
1968+ field.
1969+ If used, the rule will match IPv6 packets only.
1970+ Example: src-ip6:afff:ff00:ffff:ffff:0:0:0:0f0f.
1971+ .It
1972+ As a Ethernet mac address when specified alongwith
1973+ .Cm dst-mac
1974+ or
1975+ .Cm src-mac
1976+ field. E.g. 00:11:22:33:44:55.
1977+ .El
1978+ .Pp
1979+ The
1980+ .Ar bitmask
1981+ can not be specified for
1982+ .Cm dst-ip
1983+ or
1984+ .Cm src-ip
1985+ as these field specifiers lookup both IPv4 and IPv6 addresses.
1986+ .Pp
19391987This option can be useful to quickly dispatch traffic based on
19401988certain packet fields.
1989+ The
1990+ .Ar bitmask
1991+ allows to implement wildcard lookups by inserting into table masked prefix and
1992+ appying
1993+ .Ar bitmask
1994+ upon each lookup.
1995+ .Pp
19411996See the
19421997.Sx LOOKUP TABLES
19431998section below for more information on lookup tables.
@@ -2000,7 +2055,7 @@ However, this option doesn't imply an implicit
20002055.Cm check-state
20012056in contrast to
20022057.Cm keep-state .
2003- .It Cm recv | xmit | via Brq Ar ifX | Ar ifmask | Ar table Ns Po Ar name Ns Oo , Ns Ar value Oc Pc | Ar ipno | Ar any
2058+ .It Cm recv | xmit | via Brq Ar ifX | Ar ifmask | Ar table-ref | Ar ipno | Ar any
20042059Matches packets received, transmitted or going through,
20052060respectively, the interface specified by exact name
20062061.Po Ar ifX Pc ,
@@ -2018,8 +2073,8 @@ See also the
20182073.Sx EXAMPLES
20192074section.
20202075.Pp
2021- Table
2022- .Ar name
2076+ A lookup table specified by
2077+ .Ar table-ref
20232078may be used to match interface by its kernel ifindex.
20242079See the
20252080.Sx LOOKUP TABLES
@@ -4350,7 +4405,8 @@ Capture messages from
43504405.Xr route 4
43514406socket, that were logged using rules with
43524407.Cm log Cm logdst Ar rtsock
4353- opcode. Optional
4408+ opcode.
4409+ Optional
43544410.Ar filter-comment
43554411can be specified to show only those messages, that were logged
43564412by rules with specific rule comment.
@@ -4705,10 +4761,41 @@ In the following example per-interface firewall is created:
47054761The following example illustrate usage of flow tables:
47064762.Pp
47074763.Dl " ipfw table fl create type flow:src-ip,proto,dst-ip,dst-port"
4708- .Dl " ipfw table fl add 2a02:6b8 :77::88,tcp,2a02:6b8 :77::99,80 11"
4764+ .Dl " ipfw table fl add 2001:db8 :77::88,tcp,2001:db8 :77::99,80 11"
47094765.Dl " ipfw table fl add 10.0.0.1,udp,10.0.0.2,53 12"
47104766.Dl " .."
47114767.Dl " ipfw add 100 allow ip from any to any flow 'table(fl,11)' recv ix0"
4768+ .Pp
4769+ The following example illustrate masked table lookups to aid uniform client
4770+ distribution among multiple NAT instances:
4771+ .Bd -literal -offset indent
4772+ # Configure NAT instances
4773+ ipfw nat 10 config ip 192.0.2.0
4774+ ipfw nat 11 config ip 192.0.2.1
4775+ ipfw nat 12 config ip 192.0.2.2
4776+ ipfw nat 13 config ip 192.0.2.3
4777+
4778+ ipfw table mynats create type addr valtype nat
4779+ # Map external NAT address to NAT instance
4780+ ipfw table mynats add 192.0.2.0 10
4781+ ipfw table mynats add 192.0.2.1 11
4782+ ipfw table mynats add 192.0.2.2 12
4783+ ipfw table mynats add 192.0.2.3 13
4784+
4785+ # Map last 2 bits of client's IP address to NAT instance
4786+ ipfw table mynats add 0.0.0.0 10
4787+ ipfw table mynats add 0.0.0.1 11
4788+ ipfw table mynats add 0.0.0.2 12
4789+ ipfw table mynats add 0.0.0.3 13
4790+
4791+ # In -> Out NAT, zero out all bits in a client's IP exept
4792+ # 2 least significant prior to table lookup
4793+ ipfw add nat tablearg ip from 10.0.0.0/24 to any
4794+ lookup src-ip4:0.0.0.3 mynats
4795+ # Out -> In NAT
4796+ ipfw add nat tablearg ip from any to 192.0.2.0/30
4797+ lookup dst-ip mynats
4798+ .Ed
47124799.Ss SETS OF RULES
47134800To add a set of rules atomically, e.g.\& set 18:
47144801.Pp
0 commit comments