Installing and configuring pfSense
Installing and configuring pfSense
1
Introduction
2
Hardware Requirements
3
Installing pfSense CE
4
pfSense Interface
5
Diagnostics
6
Advanced Settings
7
Updating
8
Internal Routing
9
SSL
10
Additional Features
11
Conclusion
Introduction
HardwareRequirements
The Community Edition can be installed on both bare metal and virtual machines. Hardware
requirements vary with network interface speeds –ranging from a minimum of 500 MHz/512 MiB
for 10 Mbps to a multi-core 2+ GHz/2 GiB for 1 Gbps.
Utilizing additional features and modules requires more CPU cores and more RAM. For commonly
used connections at 100 Mbps, 1 GHz/1 GB is recommended. For higher speeds, a PCIe bus is also
necessary to avoid bottlenecks.
Disk size requirements are minimal but depend on the functionalities used; the minimum size is 8
GB. Moreover, since pfSense is based on FreeBSD, the compatible hardware list is determined by
what FreeBSD supports.
InstallingpfSenseCE
We will show how to install, configure, and operate pfSense using a virtual machine in
the Servercore cloud. For our setup, we will create a lab with two machines: one running pfSense
with both external and internal interfaces, and another serving as a desktop client with an internal
interface.
pfSense is a custom solution deployed on the Servercore cloud platform, presenting several unique
challenges.
As of the year 2021:
In the installation image settings, specify “Linux” instead of “Other” to avoid the “Internal error
Invalid image metadata. Error: Field value other is invalid”).
The distribution only works with network disks and cannot be installed on servers that use local
disks.
It’s also impossible to combine installation via an image in the control panel with selecting two
network interfaces at the same time.
Workarounds include creating a machine with two interfaces and connecting the installation ISO via
OpenStack CLI, or installing with one network interface and later adding a second one. The latter
method is simpler and will be what we use.
Verify the integrity of the downloaded archive and then unpack it:
$ sha256sum=($(sha256sum Download/pfSense-CE-2.5.2-RELEASE-amd64.iso.gz)) &&
[ “$sha256sum” ==
“0266a16aa070cbea073fd4189a5a376d89c2d3e1dacc172c31f7e4e75b1db6bd” ] && echo “Ok” ||
echo “Something wrong”
$ gunzip Download/pfSense-CE-2.5.2-RELEASE-amd64.iso.gz
Next, create and upload the image to the storage repository via the control panel, selecting Linux
OS:
At this stage, set the network as “New Private Network” – it will be internal with the address
192.168.1.0/24. Assign the name int_net and disable DHCP. The gateway setting does not impact
anything in this case, but it cannot be removed.
After entering the necessary parameters, click the “Create” button. The server will be configured
and available within 30 seconds. If you accidentally closed the tab where the machine was being
created – no worries, the server can be accessed in the global “Servers” section. To interact with the
server console, navigate to its card under the “Servers” tab and open the “Console” item.
Read and accept the copyright terms.
Select the installation mode. At this stage, you can also activate the built-in recovery mode.
The system console will not be visible to regular users, so changing the localization is unnecessary –
you can leave it at default.
Depending on the hardware architecture, choose the boot and partitioning method; for VMs, select
BIOS.
By clicking “Yes“, you will be taken to the Shell. Here, you can manually adjust any system settings.
Once the setup is complete, return to the installation program by executing the “exit” command.
Normally, no changes are needed at this stage; simply click “No“.
Network Setup
For our lab, we will need one external and one internal network – add a second interface for this
purpose. Launch the shell by clicking “Shell“.
Then issue the shutdown command:
# poweroff
In real life, this step would not be necessary when installing on your own server.
In the global “Servers” tab, the virtual machine will feature a SHUTOFF status.
Next, we’ll explore a scenario of connecting to an ISP by IP, where we are assigned a network with
a /29 mask (the smallest available on the Servercore cloud platform).
Navigate to the global “Network” -> “Public Subnets” panel and click “Create Subnet“.
In the control panel, you can choose among masks ranging from /29 to /27. If your ISP has provided
a network with a /30 mask, your connection and setup process will be similar.
At this stage, the system will allocate a network (in this example, 94.26.250.176/29) and set a default
gateway (94.26.250.177). This will be necessary for configuring the WAN interface later on. In a real-
world scenario, this would be your ISP’s gateway address.
Add a new network to our server by navigating to “Servers” -> “Ports” -> “Add Port” -> “Select
Network” -> “Add Port“.
The system has assigned an address (94.26.250.178) to our server. It now has two interfaces as a
true internet gateway should – an external one included in the global network and an internal one in
our local network.
The Servercore Cloud Platform does not support VLAN; we do not use it and proceed to configure
interfaces.
With interface vtnet0, our server faces inward towards the network, while vtnet1 faces outward.
Item 2-Set Iface IP -> 1-WAN -> DHCP -> N -> Enter IP-Address -> Enter mask -> Enter gateway.
Next, you will be prompted to modify IPv6 settings. In our scenario, no changes are needed to IPv6
settings.
Confirm by answering “Yes” to “Do you want to revert to HTTP as the webConfigurator protocol?”
and wait 3-4 seconds for the configuration to apply.
Verify that the ISP gateway is accessible (this option is available in step 7).
After selecting “Ping host“, enter either the ISP’s gateway address or, in our lab scenario, that of the
platform.
Test Client
Next, we’ll add a test machine (Ubuntu 18/1 vCPU/2 GB RAM/8 GB Storage) to our lab. This machine
will simulate our user and connect to the Internet via pfSense. We’ll also use this machine to
continue configuring pfSense.
All that’s needed from this machine is a browser. Take a ready-made Ubuntu 18 image and add a
graphical interface to it. To access repositories, temporarily connect the machine directly to an
external network.
Click “Create“, wait 15-20 seconds for the server to initialize, then connect to its console.
If an internal network (int_net) was used during machine creation, either recreate the machine
entirely or replace that network interface with an external one before proceeding with operations
on the machine.
# ip link set eth0 down
# ip addr add 94.26.250.179/29 dev eth0
# ip link set eth0 up
# ip route add default via 94.26.250.177 dev eth0
# ping 94.26.250.177
# ping ya.ru
OS Update
Even though it’s just a test machine, start by updating it:
# apt-get update -y && apt-get upgrade -y
Netplan should not be used in the cloud platform, so we’ll edit the file to enable DHCP on the
machine interface.
/etc/network/interfaces.d/50-cloud-init.cfg
Change it as follows:
Check:
You can view the current IP address with the “ip a[address]” command, and check the settings
received from the DHCP server with the command.
less /var/lib/dhcp/dhclient.<iface>.leases
You can find out the address of the DHCP server like this:
If for some reason DHCP was enabled on the int_net network when the machine was created, DHCP
on this network must be turned off before shutting down or rebooting the machine. Otherwise, the
host 192.168.1.2 or .3 will distribute addresses. After that, configure the cloud-init and network
interface settings as above.
The banner at the top reminds you to change the default password to your own. At step 6, the setup
wizard will prompt you to change your password, so you can ignore the banner for now.
You will see the welcome message of the Setup Wizard.
In the future (for example, after resetting to factory settings: Diagnostics -> Factory Defaults), you
can restart the wizard from the System -> Setup Wizard menu.
pfSenseInterface
Upon connecting to the router, the first thing displayed is the dashboard, which may appear as
follows:
Theme change
Many prefer “dark” themes available in pfSense under System -> General Setup in
the webConfigurator section:
The article will alternate between using the default dark and light themes.
Localization
The System -> General Setup section’s Localization section allows you to switch the web interface’s
language via the Language parameter.
Diagnostics
Initial diagnostics typically start with analyzing system and component logs, followed by assessing
historical system load over a specific period, such as the last day or hour.
System Logs
Accessible via the Status -> System Logs tab. There are numerous logs, but they are organized by
category. Logs under Status/System Logs/System/General and Status/System Logs/Firewall will be
of primary interest.
Load Charts
Assessing system load is conveniently done graphically in the Status/Monitoring section.
Further diagnostics involve careful analysis of counter values on the “Statuses” tab and using
diagnostic tools on the “Diagnostics” tab.
Password Reset
If you lose your pfSense password, it can be reset to default via console option 3 (Reset
webConfigurator password).
AdvancedSettings
Firewall Rules
Default settings prevent connections to pfSense from external networks and allow client access
outward using NAT translation (specifically dynamic NAT or NAPT as per RFC 2663, also known as
NAT overload or PAT).
For instance, create an allow rule for connecting to pfSense from home on the WAN interface, then
limit user connections to only browsing on the LAN interface.
pfSense features a handy mechanism for defining variables through aliases; let’s create one for our
home office and tcp ports 80/443 and enable packet logging. Under Firewall’s Aliases menu on the
default IP tab, click the +Add button:
The tooltip provides a convenient method for creating an alias for a range of ports.
To configure this setting, navigate to Firewall/Rules/.
Now when creating or editing rules, we can utilize aliases. This is particularly useful when a setting is
reused across multiple rules and occasionally changes.
In such cases, only one alias needs adjusting.
In the earlier example, we selected previously defined aliases for both source address and
destination ports.
After making adjustments, remember to click Apply Changes. Now you can test the connection.
Similarly, create a rule for surfing on the LAN interface:
Next on this interface create rules for DNS (udp:53) and optionally for easier diagnostics ICMP (just
echo request, echo reply is enough).
Now disable default rules by clicking on the green checkmark (1), Save (2 if rule order has changed),
and Apply Changes(3):
Check access to websites and then to non-standard ports using portquiz.net:
Ping is working, domain names are resolved, HTTP over TCP/80 is open, but the connection fails on
the non-standard port TCP/8080.
This is also documented in the log:
Thus, we have accomplished the task of providing access to web resources and blocking unwanted
resources on other ports.
Port Forwarding
A frequent task involves publishing a service hosted on a local network, such as a mail or web server.
Test Web Server
While this topic isn’t related to pfSense, our lab currently lacks any resources for publication, so let’s
create one.
In the /var/www/html directory, create a file named demo.php with the following contents:
<?php
phpinfo();
?>
With the test server now set up, all that remains is to ensure the web server is operational:
Verification
Check our settings by accessing the WAN address of pfSense at port 8080.
The internal web server has responded at the public address. Adding the title of the demo page, we
see that it has also been successfully published.
Updating
pfSense is a multifunctional and user-friendly tool. Updates are easily performed either in
the System Information section on the dashboard or through the System -> Update menu.
Our system was installed from the latest distribution and is already up to date; no updates are
necessary. Updates are typically released every six months.
If you’re ready to experiment, you can update to the experimental branch.
Here’s what updating from the previous version looks like (2.4.5):
After configuring the settings, remember to click the “Apply changes” button.
Dynamic routing scenarios require installing an additional package like frr (Free Range Routing),
which supports numerous protocols including GP, OSPF, RIP, IS-IS, PIM, LDP, BFD, Babel, PBR,
OpenFabric and VRRP.
After the package is installed, protocol configuration sections such as FRR-OSPF are added to the
Services menu:
Before setting up dynamic routing in Global Settings, activate FRR and set up the mandatory master
password:
SSL
The management interface can be swtiched between HTTP and HTTPS via the Advanced section of
the System menu.
Activate the rule (1), assign an easy-to-understand name (2), and set the bandwidth (3). Separate
rules are established for download and upload limits (4).
The shaper is directly activated within the firewall rules (Firewall → Rules). We want to restrict
outbound traffic from our internal clients, so let’s modify/add rules for the LAN interface accordingly.
Limits names are taken from the perspective of the interface side: In – incoming traffic, Out –
outgoing traffic. To restrict outbound client traffic, use the In rule.
Open the Rules section under the Firewall menu, navigate to the LAN tab and, in the Extra
Options section of the required (newly created or existing) rule, enable advanced settings display
(Display Advanced button):
Note: The example shown above uses an existing rule that permits internal clients to connect via
HTTPS.
In the second-from-last section of Advanced Settings (1, In/Out pipe), specify the rules for traffic
incoming to the interface (2) and outgoing from it (3).
After saving and applying settings, pfSense notifies of the need to reload filtering rules in the
background and suggests checking the status on the Status/Filter Reload page.
Following rule updates, let’s take another speed test.
AdditionalFeatures
pfSense’s functionality is expanded by numerous packages available through its package manager;
here are just a few:
apcupsd – a daemon for interfacing with APC UPSes (now Schneider);
arpwatch – monitors MAC/IP address activity;
cron – a scheduling tool;
filer – a file manager;
squid/lightsquid/squidGuard – proxy, report generator, and filter.
lldpd – supports discovery via Link Layer Discovery Protocol and also supports proprietary protocols
such as CDP, EDP, FDP, NDP.
mailreport – sends reports via email.
net-snmp – SNMP graphical interface.
nmap – the classic tool for network scanning.
snort/suricata/zeek – solutions for IDS/IPS systems.
It’s important to understand that using these features requires better hardware. Heavy VPN use may
necessitate one or more additional CPU cores, while IDS/IPS systems will also need an extra 1-2 GB
of RAM.
Let’s demonstrate enhanced functionality using the popular nmap scanner. In the System menu,
navigate to Package Manager, select the Available Packages tab, click Install next to the NMap
package, wait, and access the built-in scanner:
NMap is now available in the Diagnostics menu; launch it:
Our lab’s internal segment contains only one host, which was successfully detected and scanned:
Conclusion
This article presents an overview of pfSense, a solution for implementing a high-performance,
reliable, and functional software router. We learned how to install, configure, throttle speed, and
enhance functionality by installing extension packages.