Configuring The Firewall: Guided Exercise: Managing Server Firewalls
Configuring The Firewall: Guided Exercise: Managing Server Firewalls
Click the Networking option in the left navigation menu to display the Firewall section in the
main networking page. Click the Firewall link to access the allowed services list.
To add a service, click the Add Services... button in the upper right corner of the Firewall
Allowed Services page.
The example commands below set the default zone to dmz, assign all traffic coming from the
192.168.0.0/24 network to the internal zone, and open the network ports for the mysql
service on the internal zone.
1. On the servera system, ensure that both httpd and mod_ssl packages are installed.
These packages provide the Apache web server you will protect with a firewall, and
the necessary extensions for the web server to serve content over SSL.
4. From workstation, attempt to access your web server on servera using both the
cleartext port 80/TCP and the SSL encapsulated port 443/TCP. Both attempts should fail.
This command should fail:
On servera, make sure that the nftables service is masked and the firewalld service is
enabled and running.
Determine whether the status of the nftables service is masked.
[student@servera ~]$ sudo systemctl status nftables
[sudo] password for student: student
● nftables.service - Netfilter Tables
Loaded: loaded (/usr/lib/systemd/system/nftables.service; disabled;
vendor preset: disabled)
Active: inactive (dead)
Docs: man:nft(8)
The results show that nftables is disabled and inactive but not masked. Run the
following command to mask the service.
Verify that the status of the firewalld service is enabled and running.
From workstation, open Firefox and log in to the Web Console running on servera to add
the httpd service to the public network zone.
Open Firefox and browse to https://servera.lab.example.com:9090 to
access the Web Console. Accept the self-signed certificate used by servera
by adding an exception.
Select the check box next to Reuse my password for privileged tasks to
ensure administrative privileges.
Log in as student user with student as the password.
Click Networking in the left navigation bar.
Click the Firewall link in main Networking page.
Click the Add Services... button located in the upper right side of the Firewall
page.
In the Add Services user interface, scroll down or use Filter Services to
locate and select the check box next to the Secure WWW (HTTPS) service.
Click the Add Services button located at the lower right side of the Add
Services user interface.
Return to a terminal on workstation and verify your work by attempting to view the
web server contents of servera.
This command should fail:
To get an overview of all the current port label assignments, run the semanage port -l
command. The -l option lists all current assignments in this form:
To add a port to an existing port label (type), use the following syntax. The -a adds a new
port label, the -t denotes the type, the -p denotes the protocol.
To view local changes to the default policy, administrators can add the -C option to the
semanage command.
gopher_port_t tcp 71
Removing Port Labels
The syntax for removing a custom port label is the same as the syntax for adding a port label,
but instead of using the -a option (for Add), use the -d option (for Delete).
For example, to remove the binding of port 71/TCP to gopher_port_t:
http_port_t tcp 71
[root@server ~]# semanage port -l | grep http
http_cache_port_t tcp 8080, 8118, 8123, 10001-10010
http_cache_port_t udp 3130
http_port_t tcp 71, 80, 81, 443, 488, 8008, 8009, 8443,
9000
pegasus_http_port_t tcp 5988
pegasus_https_port_t tcp 5989
Attempt to fix the web content problem by restarting the httpd service.
1. Use the systemctl command to restart the httpd.service. This command is
expected to fail.
2. [root@servera ~]# systemctl restart httpd.service
3. Job for httpd.service failed because the control process exited with error
code.
4. See "systemctl status httpd.service" and "journalctl -xe" for details.
5. Use the systemctl status -l command to reveal the status of the httpd service. Note
the permission denied error.
6. [root@servera ~]# systemctl status -l httpd.service
7. ● httpd.service - The Apache HTTP Server
8. Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor
preset: disabled)
9. Active: failed (Result: exit-code) since Mon 2019-04-08 14:23:29 CEST;
3min 33s ago
10. Docs: man:httpd.service(8)
11. Process: 28078 ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND
(code=exited, status=1/FAILURE)
12. Main PID: 28078 (code=exited, status=1/FAILURE)
13. Status: "Reading configuration..."
14.
15. Apr 08 14:23:29 servera.lab.example.com systemd[1]: Starting The Apache
HTTP Server...
16. Apr 08 14:23:29 servera.lab.example.com httpd[28078]: (13)Permission
denied: AH00072: make_sock: could not bind to address [::]:82
17. Apr 08 14:23:29 servera.lab.example.com httpd[28078]: (13)Permission
denied: AH00072: make_sock: could not bind to address 0.0.0.0:82
18. Apr 08 14:23:29 servera.lab.example.com httpd[28078]: no listening sockets
available, shutting down
19. Apr 08 14:23:29 servera.lab.example.com httpd[28078]: AH00015: Unable to
open logs
20. Apr 08 14:23:29 servera.lab.example.com systemd[1]: httpd.service: Main
process exited, code=exited, status=1/FAILURE
21. Apr 08 14:23:29 servera.lab.example.com systemd[1]: httpd.service: Failed
with result 'exit-code'.
Configure SELinux to allow httpd to bind to port 82/TCP, then restart the httpd.service
service.
Use the semanage command to find an appropriate port type for port 82/TCP.
http_port_t contains the default HTTP ports, 80/TCP and 443/TCP. This is the
correct port type for the web server.
Use the semanage command to assign port 82/TCP the http_port_t type.
Use the systemctl command to restart the httpd.service service. This command
should succeed.
Check if you can now access the web server running on port 82/TCP. Use the curl command
to access the web service from servera.
success
success
Use the curl command to access the web service from workstation.
Enable and start the httpd service. The httpd service fails to start.
Use the sealert command to check whether SELinux is blocking the httpd service from
binding to port 1001/TCP.
Use the semanage command to bind port 1001/TCP to the http_port_t type.
5. Log in to serverb to determine whether the correct ports are assigned to the firewall.
From workstation, log in to serverb as the student user.
If the previous step did not return public as the default zone, correct it with the
following command:
6. Add port 1001/TCP to the permanent configuration for the public network zone. Confirm
your configuration.
Add port 1001/TCP to the public network zone.