In this lab, you will configure a basic firewall.
| Resources | |
|---|---|
| Machines: | serverX and desktopX |
Outcomes:
After completion of this exercise, your serverX machine
should have a running web server, listening on both the cleartext
port 80/TCP and the SSL encapsulated port
443/TCP. The firewall configuration on
serverX should only allow connections to the SSL
encapsulated port.
The firewall should allow access to sshd and vnc from all hosts.
Reset your serverX system.
On your serverX system, make sure that both the
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.
[student@serverX ~]$sudo yum -y install httpd mod_ssl
On your serverX system, create a new file called
/var/www/html/index.html, with the following
contents:
I am alive
[student@serverX ~]$sudo bash -c "echo 'I am alive' > /var/www/html/index.html"
Start and enable the httpd service on your
serverX system.
[student@serverX ~]$sudo systemctl start httpd
[student@serverX ~]$sudo systemctl enable httpd
On your serverX system, make sure that both the
iptables and ip6tables services
are masked, and that the
firewalld service is enabled and running.
[student@serverX ~]$sudo systemctl mask iptables[student@serverX ~]$sudo systemctl mask ip6tables[student@serverX ~]$sudo systemctl status firewalld
On your serverX system, start the
firewall-config application. When prompted
for the student password, enter student.
[student@serverX ~]$firewall-config
or
Select → → from the system menu.
From the Configuration dropdown menu, select Permanent to switch to editing the permanent configuration.
Add the https service to the list of services allowed in
the public zone.
In the Zone list, select public. Since this zone is also the default zone, it is highlighted in bold.
In the Services tab, add a checkmark in front
of the https service.
Important: Also add a
checkmark in front of the vnc-server service.
Failing to do so will lock out your graphical interface when you
activate the firewall. If you do accidentally lock yourself out,
recover by using ssh -X serverX
firewall-config from your desktopX machine.
Activate your firewall configuration by selecting → from the menu.
Verify your work by attempting to view your web server contents from
desktopX.
This command should fail:
[student@desktopX ~]$curl -k http://serverX.example.com
This command should succeed:
[student@desktopX ~]$curl -k https://serverX.example.com
If you use firefox to connect to the web server, it will prompt for verification of the host certificate if it successfully gets past the firewall.