A Linux administrator edits /etc/httpd/conf/httpd.conf on a CentOS-stream 9 server and changes the line
Listen 80
to
Listen 8080
SELinux is in enforcing mode and no other service is using the new port. When the administrator starts the service with systemctl start httpd, Apache fails with the message:
(13)Permission denied: make_sock: could not bind to address 0.0.0.0:8080
Which command will allow the service to start without reducing SELinux security or reverting the Listen directive?
By default, SELinux permits httpd to bind only to ports labeled with the type http_port_t (ports such as 80, 443, 8008, 8443, and a few others). Binding to an unlisted port causes the kernel to deny the operation, generating the "permission denied: make_sock" error and preventing Apache from starting.
The semanage port -a -t http_port_t -p tcp 8080 command permanently adds TCP port 8080 to the list associated with the http_port_t type, so SELinux will allow httpd to bind to it in enforcing mode. No service restart of SELinux is required-after adding the rule, starting or reloading the httpd service succeeds.
The other options do not address the cause of the denial:
firewall-cmd --permanent --add-service=http only opens the firewall and has no effect on SELinux port labeling.
setsebool -P httpd_can_network_connect 1 controls outbound network connections from httpd, not the ability to listen on a TCP port.
restorecon -R -v /var/www/html resets file contexts on the document root, which does not influence port binding.
Therefore, the semanage port command is the required solution.
Ask Bash
Bash is our AI bot, trained to help you pass your exam. AI Generated Content may display inaccurate information, always double-check anything important.
What is SELinux and how does it enforce security?
Open an interactive chat with Bash
What does the `semanage port` command do in SELinux?
Open an interactive chat with Bash
Why do the other incorrect options fail to solve the issue?
Open an interactive chat with Bash
CompTIA Linux+ XK0-006 (V8)
Services and User Management
Your Score:
Report Issue
Bash, the Crucial Exams Chat Bot
AI Bot
Loading...
Loading...
Loading...
IT & Cybersecurity Package Join Premium for Full Access