MAC_IPACL(4)
π
MAC_IPACL(4) β the mac_ipacl manual, bestie edition β¨
okay so welcome to mac_ipacl(4), from the Kernel Interfaces Manual π this is the IP Address access control policy page and honestly? it's giving gatekeeper-but-make-it-kerneL. let's get into it π¦
β¨ NAME β¨
mac_ipacl β the IP Address access control policy, aka the bouncer at the club for your jails' IPs π
πΈ SYNOPSIS πΈ
so to compile the IP address access control policy into your kernel, you literally just drop these lines into your kernel configuration file:
options MAC
options MAC_IPACL
and if you'd rather load the mac_ipacl policy module at boot time instead, add this one in your kernel configuration file:
options MAC
and then in loader.conf(5) you add:
mac_ipacl_load="YES"
no cap, that's the whole vibe check π
π¦ DESCRIPTION π¦
the mac_ipacl policy lets the root of the host use the sysctl(8) interface to limit the VNET(9) jail's ability to set IPv4 and IPv6 addresses π«Ά so basically the host gets to define rules for jails and their interfaces, all about IP addresses, using sysctl(8) MIBs. main character energy, honestly.
its default behavior is to deny all IP addresses for the jail if the mac_ipacl policy is enforced π and then it'll allow/deny IP (or subnets) according to the security.mac.ipacl.rules string you specify with sysctl(8).
π Runtime Configuration π
these sysctl(8) MIBs are the ones that control enforcement and behavior of this MAC Policy. periodt.
security.mac.ipacl.ipv4β enforcesmac_ipaclfor IPv4 addresses. (Default:1). πsecurity.mac.ipacl.ipv6β enforcesmac_ipaclfor IPv6 addresses. (Default:1). πsecurity.mac.ipacl.rulesβ the IP address access control list, and it's specified in this format:
jid,allow,interface,addr_family,IP_addr/prefix[@jid,...]
and here's what each little piece means, iykyk:
jidβ describes the jail id of the jail this rule is written for. π§allowβ1for allow and0for deny. decides the action performed for the rule. slay or nay πinterfaceβ the name of the interface the rule is enforced for. if the interface is left empty then it's a wildcard to enforce the rule for all interfaces β¨addr_familyβ the address family of theIP_addr. the input has to be given as theAF_INETorAF_INET6string only, no improvising πIP_addrβ the IP address (or subnet) to be allowed/denied. the action depends on the prefix length.prefixβ the prefix length of the subnet to be enforced by the policy.-1implies the policy is enforced for the individual IP address. for a non-negative value, it's a range of IP addresses (present in the subnet) which is calculated assubnet = IP_addr & mask. math but make it fashion π
π₯ EXAMPLES π₯
behavior of the mac_ipacl policy module for different inputs of the sysctl variable, coming right up:
- assign
ipv4=1,ipv6=0andrules="1,1,,AF_INET,169.254.123.123/-1"
it allows only 169.254.123.123 IPv4 address for all interfaces (wildcard) of jail 1. it allows all IPv6 addresses since the policy is not enforced for IPv6. iconic.
- assign
ipv4=1,ipv6=1andrules="1,1,epair0b,AF_INET6,fe80::/32@1,0,epair0b,AF_INET6,fe80::abcd/-1"
it denies all IPv4 addresses because the policy is enforced but no rules are specified about it π it allows all IPv6 addresses in subnet fe80::/32 except fe80::abcd for interface epair0b only. very specific, very demure.
- assign
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"
it allows IPv4 in subnet 198.51.100.0/24 for jail 2 and all interfaces π it allows IPv6 addresses in subnet fc00::/7 but denies subnet fc00::1111:2200/120, and allows the individual IP fc00::1111:2299 from the denied subnet for all interfaces in jail 2. the way that rule just carves out an exception? obsessed. π
please refer to mac/ipacl tests-framework for a wide variety of examples on using the ipacl module π«Ά
π LIMITATIONS/PRECAUTIONS π
in the case where multiple rules are applicable to an IP address or a set of IP addresses, the rule that is defined later in the list determines the outcome, disregarding any previous rule for that IP address. so like, last one wins, no take-backs, the earlier rules simply do not get a say π€
β FUTURE WORKS β
rules are given with the sysctl interface which gets very complex to give them all in command line π it has to be simplified with a better way to input those rules. manifesting it fr fr π
π SEE ALSO π
π AUTHORS π
the mac_ipacl policy module was developed as a Google Summer of Code Project in 2019 by Shivank Garg <shivank@FreeBSD.org> under the guidance of Bjoern A. Zeeb <bz@FreeBSD.org>. we stan a GSoC king πβ¨
okay that's the whole page bestie, go forth and rule your jails π§π«
β with love from the Debian edition, dated July 25, 2023, signing off π MAC_IPACL(4) forever π
π¦ where this page comes from
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- nixpkgs unstable: source
- Copyright (c) 2019, 2023 Shivank Garg <shivank@FreeBSD.org>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms