MAC_PORTACL(4)
π MAC_PORTACL(4) β the kernel interfaces manual, but make it make sense
okay bestie, buckle up, because this is mac_portacl β the network port access control policy β and she is literally the bouncer at the club door of your ports. this is a mac manpage (kernel interfaces manual, iykyk) and we're gonna get through it together π
β¨ NAME β¨
mac_portacl β network port access control policy π¦
πΈ SYNOPSIS πΈ
so to compile the port access control policy into your kernel, you put these lines in your kernel configuration file:
options MAC
options MAC_PORTACL
alternately β if you'd rather load the port access control policy module at boot time β you put just this line in your kernel configuration file:
options MAC
and then in loader.conf(5) you go:
mac_portacl_load="YES"
easy. slay. periodt π
π DESCRIPTION π
so what does the mac_portacl policy actually do? it lets administrators administratively limit binding to local UDP and TCP ports via the sysctl(8) interface. that's the whole vibe. no cap β¨
but listen, there are prerequisites, because of course there are:
- in order to enable the
mac_portaclpolicy, MAC policy must be enforced on sockets (seemac(4)), and - the port(s) protected by
mac_portaclmust not be included in the range specified by thenet.inet.ip.portrange.reservedlowandnet.inet.ip.portrange.reservedhighsysctl(8)MIBs.
and here's the important lil nuance: the mac_portacl policy only affects ports explicitly bound by a user process (either for a listen/outgoing TCP socket, or a send/receive UDP socket). this policy will not limit ports bound implicitly for outgoing connections where the process has not explicitly selected a port β those are automatically selected by the IP stack. so like, don't come for her when the stack picks a port for you, that's not her department π
when mac_portacl is enabled, it will control binding access to ports up to the port number set in the security.mac.portacl.port_high sysctl(8) variable. by default, all attempts to bind to mac_portacl controlled ports will fail if not explicitly allowed by the port access control list β though binding by the superuser will be allowed, if the sysctl(8) variable security.mac.portacl.suser_exempt is set to a non-zero value. the superuser really said "rules for thee, not for me" and honestly? iconic π
π§ Runtime Configuration π§
the following sysctl(8) MIBs are available for fine-tuning the enforcement of this MAC policy. all sysctl(8) variables, except security.mac.portacl.rules, can also be set as loader(8) tunables in loader.conf(5). (yes, only that one has to sit out. she's special.)
security.mac.portacl.enabledβ Enforce themac_portaclpolicy. (Default: 1).security.mac.portacl.port_highβ The highest port numbermac_portaclwill enforce rules for. (Default: 1023).security.mac.portacl.rulesβ The port access control list is specified in the following format:
idtype:id:protocol:port[,idtype:id:protocol:port,...]
and here's what each lil piece means:
idtypeβ Describes the type of subject match to be performed. Eitheruidfor user ID matching, orgidfor group ID matching.idβ The user or group ID (depending onidtype) allowed to bind to the specified port. NOTE: User and group names are not valid; only the actual ID numbers may be used. π yeah, numbers only, names do NOT work, don't @ me.protocolβ Describes which protocol this entry applies to. Eithertcporudpare supported.portβ Describes which port this entry applies to. NOTE: MAC security policies may not override other security system policies by allowing accesses that they may deny, such asnet.inet.ip.portrange.reservedlow/net.inet.ip.portrange.reservedhigh. If the specified port falls within the range specified, themac_portaclentry will not function (i.e., even the specified user/group may not be able to bind to the specified port). so like, she's not gonna fight the other security systems for you. that's not her job. π«Ά
security.mac.portacl.suser_exemptβ Allow superuser (i.e., root) to bind to allmac_portaclprotected ports, even if the port access control list does not explicitly allow this. (Default: 1).security.mac.portacl.autoport_exemptβ Allow applications to use automatic binding to port 0. Applications use port 0 as a request for automatic port allocation when binding an IP address to a socket. This tunable will exempt port 0 allocation from rule checking. (Default: 1).
fr fr though β those defaults?1,1023,1,1. write them down, bestie. π
π SEE ALSO π
mac(3), ip(4), mac_biba(4), mac_bsdextended(4), mac_ddb(4), mac_ifoff(4), mac_mls(4), mac_none(4), mac_partition(4), mac_seeotheruids(4), mac_test(4), mac(9)
(the whole mac cinematic universe, go read 'em π)
β HISTORY β
MAC first appeared in FreeBSD 5.0 and mac_portacl first appeared in FreeBSD 5.1. two icons, one era π
π AUTHORS π
This software was contributed to the FreeBSD Project by NAI Labs, the Security Research Division of Network Associates Inc. under DARPA/SPAWAR contract N66001-01-C-8035 (βCBOSSβ), as part of the DARPA CHATS research program.
and that's the whole page, bestie, you ate it up ππ this was Debian's build, dated December 9, 2004 β shoutout to the version/date corner of the footer, we see you π¦β¨
π¦ where this page comes from
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- nixpkgs unstable: source
- Copyright (c) 2003 Networks Associates Technology, Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms