xref: /freebsd/share/man/man4/mac_ipacl.4 (revision fa9896e082a1046ff4fbc75fcba4d18d1f2efc19)
1*215bab79SShivank Garg.\" Copyright (c) 2019, 2023 Shivank Garg <shivank@FreeBSD.org>
2*215bab79SShivank Garg.\"
3*215bab79SShivank Garg.\" This code was developed as a Google Summer of Code 2019 project
4*215bab79SShivank Garg.\" under the guidance of Bjoern A. Zeeb.
5*215bab79SShivank Garg.\"
6*215bab79SShivank Garg.\" Redistribution and use in source and binary forms, with or without
7*215bab79SShivank Garg.\" modification, are permitted provided that the following conditions
8*215bab79SShivank Garg.\" are met:
9*215bab79SShivank Garg.\" 1. Redistributions of source code must retain the above copyright
10*215bab79SShivank Garg.\"    notice, this list of conditions and the following disclaimer.
11*215bab79SShivank Garg.\" 2. Redistributions in binary form must reproduce the above copyright
12*215bab79SShivank Garg.\"    notice, this list of conditions and the following disclaimer in the
13*215bab79SShivank Garg.\"    documentation and/or other materials provided with the distribution.
14*215bab79SShivank Garg.\"
15*215bab79SShivank Garg.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
16*215bab79SShivank Garg.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17*215bab79SShivank Garg.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18*215bab79SShivank Garg.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
19*215bab79SShivank Garg.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20*215bab79SShivank Garg.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21*215bab79SShivank Garg.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22*215bab79SShivank Garg.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23*215bab79SShivank Garg.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24*215bab79SShivank Garg.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25*215bab79SShivank Garg.\" SUCH DAMAGE.
26*215bab79SShivank Garg.\"
27*215bab79SShivank Garg.Dd July 25, 2023
28*215bab79SShivank Garg.Dt MAC_IPACL 4
29*215bab79SShivank Garg.Os
30*215bab79SShivank Garg.Sh NAME
31*215bab79SShivank Garg.Nm mac_ipacl
32*215bab79SShivank Garg.Nd "IP Address access control policy"
33*215bab79SShivank Garg.Sh SYNOPSIS
34*215bab79SShivank GargAdd the following lines in your kernel configuration file to compile the
35*215bab79SShivank GargIP address access control policy into your kernel:
36*215bab79SShivank Garg.Bd -ragged -offset indent
37*215bab79SShivank Garg.Cd "options MAC"
38*215bab79SShivank Garg.Cd "options MAC_IPACL"
39*215bab79SShivank Garg.Ed
40*215bab79SShivank Garg.Pp
41*215bab79SShivank GargTo load the mac_ipacl policy module at boot time, add the
42*215bab79SShivank Gargfollowing line in your kernel configuration file:
43*215bab79SShivank Garg.Bd -ragged -offset indent
44*215bab79SShivank Garg.Cd "options MAC"
45*215bab79SShivank Garg.Ed
46*215bab79SShivank Garg.Pp
47*215bab79SShivank Gargand in
48*215bab79SShivank Garg.Xr loader.conf 5 add:
49*215bab79SShivank Garg.Pp
50*215bab79SShivank Garg.Dl "mac_ipacl_load=""YES"""
51*215bab79SShivank Garg.Sh DESCRIPTION
52*215bab79SShivank GargThe
53*215bab79SShivank Garg.Nm
54*215bab79SShivank Gargpolicy allows the root of the host to use the
55*215bab79SShivank Garg.Xr sysctl 8
56*215bab79SShivank Garginterface to limit the
57*215bab79SShivank Garg.Xr VNET 9
58*215bab79SShivank Gargjail's ability to set IPv4 and IPv6 addresses.
59*215bab79SShivank GargSo, the host can
60*215bab79SShivank Gargdefine rules for jails and their interfaces about IP addresses
61*215bab79SShivank Gargwith
62*215bab79SShivank Garg.Xr sysctl 8
63*215bab79SShivank GargMIBs.
64*215bab79SShivank Garg.Pp
65*215bab79SShivank GargIts default behavior is to deny all IP addresses for the jail if
66*215bab79SShivank Garg.Nm
67*215bab79SShivank Gargpolicy is enforced and allow/deny IP (or subnets) according to the
68*215bab79SShivank Garg.Va security.mac.ipacl.rules
69*215bab79SShivank Gargstring specified with
70*215bab79SShivank Garg.Xr sysctl 8
71*215bab79SShivank Garg.Ss Runtime Configuration
72*215bab79SShivank GargThe following
73*215bab79SShivank Garg.Xr sysctl 8
74*215bab79SShivank GargMIBs are used to control enforcement and behavior of this MAC Policy.
75*215bab79SShivank Garg.Bl -tag -width indent
76*215bab79SShivank Garg.It Va security.mac.ipacl.ipv4
77*215bab79SShivank GargEnforce
78*215bab79SShivank Garg.Nm
79*215bab79SShivank Gargfor IPv4 addresses.
80*215bab79SShivank Garg(Default: 1).
81*215bab79SShivank Garg.It Va security.mac.ipacl.ipv6
82*215bab79SShivank GargEnforce
83*215bab79SShivank Garg.Nm
84*215bab79SShivank Gargfor IPv6 addresses.
85*215bab79SShivank Garg(Default: 1).
86*215bab79SShivank Garg.It Va security.mac.ipacl.rules
87*215bab79SShivank GargThe IP address access control list is specified in the following format:
88*215bab79SShivank Garg.Pp
89*215bab79SShivank Garg.Sm off
90*215bab79SShivank Garg.D1 jid , allow , interface , addr_family , IP_addr / prefix Op @ jid , ...
91*215bab79SShivank Garg.Sm on
92*215bab79SShivank Garg.Bl -tag -width "interface"
93*215bab79SShivank Garg.It jid
94*215bab79SShivank GargDescribe the jail id of the jail for which the rule is written.
95*215bab79SShivank Garg.It allow
96*215bab79SShivank Garg1 for allow and 0 for deny.
97*215bab79SShivank GargDecides action performed for the rule.
98*215bab79SShivank Garg.It interface
99*215bab79SShivank GargName of the interface the rule is enforced for.
100*215bab79SShivank GargIf the interface is left empty then it is a wildcard to enforce the
101*215bab79SShivank Gargrule for all interfaces.
102*215bab79SShivank Garg.It addr_family
103*215bab79SShivank GargAddress family of the IP_addr.
104*215bab79SShivank GargThe input to be given as AF_INET or AF_INET6
105*215bab79SShivank Gargstring only.
106*215bab79SShivank Garg.It IP_addr
107*215bab79SShivank GargIP address (or subnet) to be allowed/denied.
108*215bab79SShivank GargAction depends on the prefix length.
109*215bab79SShivank Garg.It prefix
110*215bab79SShivank GargPrefix length of the subnet to be enforced by the policy.
111*215bab79SShivank Garg-1 implies the policy is enforced for the individual IP address.
112*215bab79SShivank GargFor a non-negative value, a range of IP addresses (present in subnet)
113*215bab79SShivank Gargwhich is calculated as subnet = IP_addr & mask.
114*215bab79SShivank Garg.El
115*215bab79SShivank Garg.El
116*215bab79SShivank Garg.Sh EXAMPLES
117*215bab79SShivank GargBehavior of the
118*215bab79SShivank Garg.Nm
119*215bab79SShivank Gargpolicy module for different inputs of sysctl variable:
120*215bab79SShivank Garg.Bl -tag -width "1."
121*215bab79SShivank Garg.It 1.
122*215bab79SShivank GargAssign ipv4=1, ipv6=0 and rules="1,1,,AF_INET,169.254.123.123/-1"
123*215bab79SShivank Garg.Pp
124*215bab79SShivank GargIt allow only 169.254.123.123 IPv4 address for all interfaces (wildcard) of jail 1.
125*215bab79SShivank GargIt allows all IPv6 addresses since the policy is not enforced for IPv6.
126*215bab79SShivank Garg.It 2.
127*215bab79SShivank GargAssign ipv4=1, ipv6=1 and rules="1,1,epair0b,AF_INET6,fe80::/32@1,0,epair0b,AF_INET6,fe80::abcd/-1"
128*215bab79SShivank Garg.Pp
129*215bab79SShivank GargIt denies all IPv4 addresses as the policy is enforced but no rules are specified
130*215bab79SShivank Gargabout it.
131*215bab79SShivank GargIt allows all IPv6 addresses in subnet fe80::/32 except
132*215bab79SShivank Gargfe80::abcd for interface epair0b only.
133*215bab79SShivank Garg.It 3.
134*215bab79SShivank GargAssign ipv4=1, ipv6=1, rules="2,1,,AF_INET6,fc00::/7@2,0,,AF_INET6,fc00::1111:2200/120@2,1,,AF_INET6,fc00::1111:2299/-1@1,1,,AF_INET,198.51.100.0/24"
135*215bab79SShivank Garg.Pp
136*215bab79SShivank GargIt allows IPv4 in subnet 198.51.100.0/24 for jail 2 and
137*215bab79SShivank Gargall interfaces.
138*215bab79SShivank GargIt allows IPv6 addresses in subnet fc00::/7 but
139*215bab79SShivank Gargdenies subnet fc00::1111:2200/120, and allows individual IP
140*215bab79SShivank Gargfc00::1111:2299 from the denied subnet for all interfaces in jail 2.
141*215bab79SShivank Garg.El
142*215bab79SShivank GargPlease refer to mac/ipacl tests-framework for wide variety of examples on using
143*215bab79SShivank Gargthe ipacl module.
144*215bab79SShivank Garg.Sh LIMITATIONS/PRECAUTIONS
145*215bab79SShivank GargIn the case where multiple rules are applicable to an IP address or
146*215bab79SShivank Garga set of IP addresses, the rule that is defined later in the list
147*215bab79SShivank Gargdetermines the outcome, disregarding any previous rule for that IP
148*215bab79SShivank Gargaddress.
149*215bab79SShivank Garg.Sh FUTURE WORKS
150*215bab79SShivank GargRules are given with sysctl interface which gets very complex to give them
151*215bab79SShivank Gargall in command line.
152*215bab79SShivank GargIt has to be simplified with a better way to input those rules.
153*215bab79SShivank Garg.Sh SEE ALSO
154*215bab79SShivank Garg.Xr mac 4 ,
155*215bab79SShivank Garg.Xr mac 9
156*215bab79SShivank Garg.Sh AUTHORS
157*215bab79SShivank GargThe
158*215bab79SShivank Garg.Nm
159*215bab79SShivank Gargpolicy module was developed as a Google Summer of Code Project in 2019
160*215bab79SShivank Gargby
161*215bab79SShivank Garg.An -nosplit
162*215bab79SShivank Garg.An "Shivank Garg" Aq Mt shivank@FreeBSD.org
163*215bab79SShivank Gargunder the guidance of
164*215bab79SShivank Garg.An "Bjoern A. Zeeb" Aq Mt bz@FreeBSD.org .
165