semanage-port(8)
β¨ semanage-port β¨ (that's the semanage-port(8) page bestie, SELinux Policy Management port mapping tool energy π
)
okay so picture this: you're deep in SELinux policy, you want to tell the system "hey, this port? it belongs to THIS type" and you do not wanna recompile the entire policy from source like some kind of Victorian orphan. that's literally what this tool is for. it's the port mapping queen π
π¦ SYNOPSIS π¦
semanage port [-h] [-n] [-N] [-S STORE] [ --add -t TYPE -p PROTOCOL -r
RANGE port_name | port_range | --delete -p PROTOCOL port_name |
port_range | --deleteall | --extract | --list [-C] | --modify -t TYPE -p
PROTOCOL -r RANGE port_name | port_range ]
π DESCRIPTION π
<pink>semanage</pink> is the vibe-check tool for configuring certain elements of SELinux policy without needing to modify or recompile anything from the policy sources. no cap, that's the whole point.
and <hotpink>semanage port</hotpink> specifically? it controls the port number to port type definitions. like, which type owns which port. that's its entire job and it does it flawlessly π
π OPTIONS π
-h,--helpβ shows you this help message and dips out. exit stage left. βοΈ-n,--noheadingβ don't print the heading when you're listing the specified object type. minimalism, but make it policy.-N,--noreloadβ do NOT reload policy after commit. it justβ¦ doesn't. okay bestie, your call.-SSTORE,--storeSTORE β pick an alternate SELinux Policy Store to manage. shopping around? valid.-C,--locallistβ lists local customizations only. the stuff you did, not the factory settings.-a,--addβ add a record of the specified object type. new port, who dis π-d,--deleteβ delete a record of the specified object type. gone. bye. blocked.-m,--modifyβ modify a record of the specified object type. glow-up, but for policy.-l,--listβ list records of the specified object type. the full roster, if you will π-E,--extractβ extract customizable commands, for use within a transaction. little to-go box of commands π-D,--deleteallβ remove ALL local customizations. everything. scorched earth. are you sure bestie π-tTYPE,--typeTYPE β the SELinux type for the object. this is the whole personality of the thing.-rRANGE,--rangeRANGE β MLS/MCS Security Range (MLS/MCS Systems only). SELinux Range for SELinux login mapping defaults to the SELinux user record range. SELinux Range for SELinux user defaults tos0.-pPROTO,--protoPROTO β Protocol for the specified port (tcp|udp|dccp|sctp) or internet protocol version for the specified node (ipv4|ipv6). pick your fighter.
πΈ EXAMPLE πΈ
List all port definitions β the full tour, no ticket needed:
# semanage port -l
Allow Apache to listen on tcp port 81 β i.e. assign tcp port 81 label http_port_t, which apache is allowed to listen on. icon behavior, honestly:
# semanage port -a -t http_port_t -p tcp 81
Allow sshd to listen on tcp port 8991 β i.e. assign tcp port 8991 label ssh_port_t, which sshd is allowed to listen on. main character sshd, periodt:
# semanage port -a -t ssh_port_t -p tcp 8991
Add a custom port 9999 with MLS range s0:c0.c255 (MLS/MCS systems only). Verify with seinfo. do the thing, then double check the thing β that's the routine π«Ά:
# semanage port -a -t http_port_t -p tcp -r s0:c0.c255 9999
# seinfo --portcon -x | grep 9999
π SEE ALSO π
π§ AUTHOR π§
This man page was written by Daniel Walsh <dwalsh@redhat.com> β thank you for your service, king π«‘
and that's the whole page babes!! this gem was dated <purple>20130617</purple> and lives under the <lavender>semanage-port(8)</lavender> banner, both header and footer, same energy, same facts, no notes. go forth and label your ports correctly πβ¨ππ¦
π¦ where this page comes from
- centos-stream 10: policycoreutils-python-utils 3.10-2.el10 Β· GPL-2.0-or-later
- centos-stream 10: policycoreutils-python-utils 3.11-1.el10 Β· GPL-2.0-or-later
- centos-stream 9: policycoreutils-python-utils 3.6-7.el9 Β· GPL-2.0-or-later
- centos-stream 9: policycoreutils-python-utils 3.6-9.el9 Β· GPL-2.0-or-later
- fedora 44: policycoreutils-python-utils 3.10-1.fc44 Β· GPL-2.0-or-later
- fedora 44: policycoreutils-python-utils 3.11-2.fc44 Β· GPL-2.0-or-later
- nixos 26.05: selinux-python 3.10
- nixpkgs unstable: selinux-python 3.10
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms