Complete Guide to Setting Up a Raspberry Pi as a Firewall: How to Configure IPFire on Your LAN

Complete Guide to Setting Up a Raspberry Pi as a Firewall: How to Configure IPFire on Your LAN

April 8, 2024

Illustrated cover of a Raspberry Pi firewall setup guide featuring IPFire and network security graphics

If you’re looking to configure IPFire on Raspberry Pi, this guide offers a simple and effective way to strengthen your network security.In an increasingly connected world, safeguarding your home/small office network from external threats is paramount.One effective solution is to deploy a firewall, a barrier that monitors and controls incoming and outgoing network traffic. This is precisely what our **complete guide to setting up a Raspberry Pi as a firewall** covers in detail.

With the ubiquity of Raspberry Pi and the robustness of IPFire, many users are choosing to configure IPFire on Raspberry Pi to build a small yet powerful home firewall.This guide will help to through the process of setting up a Raspberry Pi as a firewall using the IPFire distribution, offering a practical solution for improving Raspberry Pi network security.Whether you're looking to protect your personal devices, secure IoT gadgets, or simply enhance your network's defense, this project offers a cost-effective and customizable solution for a Raspberry Pi firewall setup.

Network diagram showing Raspberry Pi running IPFire to filter and allow SSH and HTTP traffic as a firewall gateway

IPFire

IPFire.org logo featuring the flaming penguin mascot representing the open-source firewall project

IPFire is an open-source Linux distribution designed to provide a robust firewall solution for small to medium-sized networks, making it ideal for a Raspberry Pi firewall setup at home or in a small office.It offers a wide range of features including firewall, VPN, proxy, Intrusion Detection System (IDS), Quality of Service (QoS), and more. IPFire is known for its security-focused design and regular updates to address emerging threats.

Here are some key features of IPFire:

Firewall: IPFire includes a powerful firewall that allows you to define rules to control incoming and outgoing traffic based on various criteria such as source/destination IP address, port, protocol, and interface.

Virtual Private Network (VPN): IPFire supports VPN connections, allowing you to securely connect remote devices or offices to your network. It supports various VPN protocols including OpenVPN and IPsec.

Proxy Server: IPFire includes a proxy server that can cache web content, filter content based on URL or content type, and provide additional security by inspecting and filtering web traffic.

Intrusion Detection System (IDS): IPFire includes an IDS called Snort, which monitors network traffic for suspicious activity —an essential feature for those concerned about Raspberry Pi network security.

Quality of Service (QoS): IPFire allows you to prioritize network traffic to ensure that critical applications or services receive adequate bandwidth and performance.

Updates and Security: IPFire receives regular updates to address security vulnerabilities and includes features like packet filtering, Stateful Packet Inspection (SPI), and network address translation (NAT) to enhance network security.

Installation

1.Download IPFire:

For a smooth IPFire Raspberry Pi installation, begin by downloading the correct ARM image suitable for your Raspberry Pi model.Download IPFire: Download the ARM image suitable for Raspberry Pi directly from the **IPFire download page**.

Download the ARM image suitable for Raspberry Pi:
https://downloads.ipfire.org/releases/ipfire-2.x/2.29-core183/ipfire-2.29-core183-aarch64.img.xz

2.Prepare the MicroSD card:

Use software like Raspberry Pi Imager to flash the IPFire image onto the MicroSD card.

Raspberry Pi Imager interface showing device, OS, and storage selection options for system image installation

3.Configure IPFire:

Connect the Raspberry Pi to your network router using the Ethernet cable and power on the Raspberry Pi.

4.Initial Setup:

Once booted, the Raspberry Pi will start the IPFire setup process.Follow the on-screen instructions to configure IPFire. Set passwords, network configuration, and other preferences.

Initial screen of the IPFire installation wizard showing the start installation prompt in a text-based interface

Configuration

Diagram showing Raspberry Pi network interfaces with IPFire, connecting the Green LAN to local devices and the Red WAN to the internet

1. Green Network (LAN):

When performing an IPFire Raspberry Pi installation, the network setup is similar to other platforms but may have some specific considerations due to the Raspberry Pi's hardware and interfaces.Here's a guide to the standard IPFire installation network setup on a Raspberry Pi:

IPFire installation screen for selecting network configuration types including Green, Red, Blue, and Orange interfaces

This network segment represents your trusted internal network where your local devices reside.
Connect the Raspberry Pi's Ethernet port (eth0) to your local network switch or router using an Ethernet cable.
During the IPFire installation process, assign the Ethernet interface (eth0) to the Green network segment.
Configure the Green network with an appropriate IP address range (e.g., 192.168.x.x or 10.x.x.x) and subnet mask that matches your existing LAN setup.

IPFire configuration screen for assigning IP address and subnet mask to the Green network interface

You can also configure the Green network to provide DHCP services to your local devices if desired.

2. Red Network (WAN - Internet):

This network segment represents the untrusted external network that connects to the internet.
Connect the Raspberry Pi's USB Ethernet (eth1) to your internet modem or router using another Ethernet cable.
During the IPFire installation process, assign the Ethernet interface (eth1) to the Red network segment.
By default, IPFire will attempt to obtain an IP address for the Red network interface dynamically via DHCP from your ISP. If you have a static IP address from your ISP, you can configure it during the installation process.

IPFire setup screen for configuring the Red interface with static IP, DHCP, or PPP dial-up connection options

3. Optional Networks (Blue, Orange, etc.):

If you have additional network segments (e.g., guest network, IoT network), you can configure them as optional networks during the IPFire installation process.
Connect additional Ethernet adapters (if available) to the Raspberry Pi's USB ports and assign them to the desired network segments (e.g., Blue, Orange) during installation.
The last thing to configure is the DHCP (Dynamic Host Configuration Protocol) Server for the Green Interface.

IPFire DHCP server configuration screen showing IP address range, DNS settings, and lease time options

An effective IPFire DHCP setup begins during the installation process. The configuration of DHCP with the program setup is possible during installation only.However, you can change all these settings after installation with IPFire's Web UI . Which occurs after you type in browser https://ipfire.localdomain:444 or https://ipfire:444 or https://192.168.1.1:444

IPFire web interface main page displaying network zones, IP addresses, connection status, and system uptime

You will be prompted to log in to the IPFire web interface. Use the credentials you set up during the initial configuration to continue with the steps in this IPFire configuration guide.

Configuring Services:

Once logged in, navigate to the "Services" tab in the web interface. Here you'll find various services that you can configure according to your needs.

DHCP Server:

Under the "Services" tab, click on "DHCP Server" to configure DHCP settings.

You can set up the DHCP server to automatically assign IP addresses to devices on your network.

IPFire web interface showing DHCP server configuration for the Green interface, including IP range, DNS, and lease settings

Configure the DHCP lease range, DNS settings, and other options as needed.

Firewall

Navigate to the "Firewall" tab to configure firewall rules specifically tailored for Raspberry Pi firewall rules management.

IPFire firewall rule configuration interface showing source address and network selection options for VPN and standard networks

You can create rules to allow or block traffic based on various criteria such as source/destination IP addresses, ports, and protocols.

Configure port forwarding, NAT rules, and other firewall settings as required.

Proxy Server:

IPFire URL filter settings interface showing block category options for ads, spyware, violence, and other web content

If you want to use the proxy server feature of IPFire, navigate to the "Proxy" tab.Configure proxy settings such as cache size, access control lists, and logging options.You can also enable content filtering and set up URL filtering rules.

VPN (Virtual Private Network)

A proper IPFire VPN configuration allows secure connections between remote devices and your local network. IPFire supports various VPN protocols including OpenVPN and IPsec. For a comparison with the default iptables/ufw firewall offered on Raspberry Pi OS, check out our guide on ⟶ **how to configure the firewall in Raspberry Pi**.

Navigate to the "VPN" tab to begin your IPFire VPN configuration, where you can set up clients, tunnels, and manage certificates.

You can set up VPN clients and servers, configure VPN tunnels, and manage certificates and keys.

IPFire OpenVPN global settings interface showing server status, network configuration, and cryptographic options

After configuring the desired services, make sure to save your changes and apply them.Some changes may require a restart of specific services or the entire system.

Monitoring and Troubleshooting

After configuring services, monitor their performance and troubleshoot any issues that may arise.

IPFire daily traffic graph for ppp0 interface showing incoming and outgoing network activity over time

IPFire provides logs and monitoring tools to help you keep track of network activity and service status.

Graphical traffic statistics for IPFire ppp0 interface including total, hourly, and daily charts of received and transmitted data
How to Update Raspberry Pi OS Back to News How to Configure the Firewall in Raspberry Pi