How do I configure a firewall for my Preseem element?

This article covers how to setup the firewall on the Preseem element to block access to services such as SSH.

The Preseem software itself exposes no listening ports to the Internet however system services such as SSH or the Cockpit web UI are available to remote addresses by default. Preseem strongly recommends limiting access to these services to a set of safe addresses to reduce the risk in the event that one of these services have a remote vulnerability. This also greatly reduces the risk of password guessing attacks which are rampant against SSH servers.

Since Preseem runs on top of Fedora, the standard Fedora firewall management tools can be used to configure a local firewall. The firewall is managed by firewalld.

Start and Enable Firewalld

In order to control firewall rules, firewalld must be running and should be enabled such that it starts on the next reboot.

systemctl enable firewalld

systemctl start firewalld

Recommended Exceptions

Should Preseem support need to help perform an upgrade or investigate problems, it is greatly helpful to have SSH access to the Preseem element. To make this easy, all Preseem support activities are sourced from the following IP addresses:

35.199.29.237

35.197.73.77

Configure the Firewall Rules

Firewalld operates with the concepts of zones and services. In this example we will add a new zone called "trusted" and add the SSH and Cockpit services to that zone. We also allow the Preseem support addresses and one internal subnet (192.168.0.0/24).

firewall-cmd --zone="trusted" --add-source 35.199.29.237/32

firewall-cmd --zone="trusted" --add-source 35.197.73.77/32

firewall-cmd --zone="trusted" --add-source 192.168.0.0/24

firewall-cmd --zone="trusted" --add-service ssh

firewall-cmd --zone="trusted" --add-service cockpit

Test and Save

After making the above changes, test that your management IP addresses can use the SSH and cockpit services. Also, check from a non-whitelisted IP to ensure that access is blocked. Once you are comfortable that everything is working, the configuration can be saved with the following command:

firewall-cmd --runtime-to-permanent

Note: If the command above is not executed, the firewall configuration will not be restored on reboot.