pfSense Configuration¶
Overview
pfSense is an open-source firewall and router platform based on FreeBSD. It provides enterprise-grade features including stateful packet filtering, NAT, VPN, traffic shaping, and comprehensive network management capabilities. This makes it ideal for creating isolated, secure lab environments for penetration testing.
Official website: https://www.pfsense.org/
Virtual Environment Only - Not for Production Use
This configuration guide is specifically for virtual lab environments only. Running pfSense virtualized for production or normal daily use is strongly discouraged due to:
- Instability: Virtual routing can be unstable and may cause network interruptions
- Boot Order Dependency: pfSense VM must be started before all client VMs, or they will lose network connectivity
- Performance Issues: Virtual networking adds latency and overhead
- Limited Hardware Access: Cannot utilize dedicated network hardware or NICs efficiently
For production environments, always install pfSense on bare metal (dedicated physical hardware).
🔌🛠️ Initial Setup - Port Assignment and IP Configuration¶
Console Configuration¶
After the initial boot, pfSense will present a console menu.
-
Assign Interfaces (Option 1)
-
Assign
WANinterface to your external/host network adapter (bridge or NAT) -
Assign
LANinterface to your internal lab network adapter (LAN Segment) -
Set Interface IP Addresses (Option 2)
WAN Interface:
- Configure via DHCP or set static IP in your host network range (e.g.,
192.168.10.10/24) - Gateway: Your host network gateway
LAN Interface:
- Static IP:
10.0.0.1 - Subnet mask:
24(255.255.255.0) - Enable DHCP server for LAN:
Yes -
DHCP range:
10.0.0.150to10.0.0.200 -
Access the web interface at
http://10.0.0.1from any VM on the LAN network
⚙️🔧 Web Interface Configuration¶
Basic Settings¶
- System > General Setup
- Hostname:
pfsense - Domain:
lab.local - DNS Servers: Add your preferred DNS (e.g.,
8.8.8.8,1.1.1.1)
- Hostname:
DNS Configuration¶
Navigate to Services > DNS Resolver
- Enable DNS Resolver
-
Configure the following settings:
- Network Interfaces:
LAN - DHCP Registration: Enable (allows DHCP clients to register in DNS)
- Static DHCP: Enable (registers static DHCP mappings)
- Network Interfaces:
🧱 Firewall Rules¶
Navigate to Firewall > Rules > LAN
Create rules to control lab traffic. Rule order matters - rules are processed from top to bottom.
Critical Security Rules
Never allow vulnerable systems (Metasploitable, OWASP applications, Windows XP/7) to access the internet! These systems are intentionally vulnerable and should remain completely isolated from external networks.
⚠️ Recommended Rule Configuration:
| Rule | Action | Protocol | Source | Destination | Description |
|---|---|---|---|---|---|
| Allow Kali to Internet | Pass | Any | Single host: 10.0.0.100 |
Any | Allow Kali Linux for tool updates |
| Block LAN to WAN | Block | Any | LAN net | WAN net | Block vulnerable systems from Internet |
| Allow LAN to LAN | Pass | Any | LAN net | LAN net | Allow internal lab communication |
Rule Order is Critical
Place the Kali Linux allow rule FIRST, then the block rule, then the LAN-to-LAN rule. The first matching rule wins, so specific exceptions must come before general blocks.
RFC1918 Networks Configuration¶
Navigate to Interfaces > WAN
If you need connectivity between the host machine and lab VMs:
- Uncheck "Block private networks and loopback addresses"
- Uncheck "Block bogon networks"
This allows RFC1918 private addresses (10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16) to traverse the WAN interface, enabling communication between your host and the lab environment.
Security Warning
Only disable RFC1918 blocking if your WAN interface is connected to a trusted network (like your host-only adapter). Never disable this on internet-facing interfaces.
🤝 Local DNS Configuration for Web Applications¶
For hosting multiple web applications on a single IP using domain names, configure DNS Host Overrides and set up a reverse proxy.
Step 1: DNS Host Overrides in pfSense¶
Navigate to Services > DNS Resolver > Host Overrides
Add the following entries for your vulnerable web applications:
| Host | Domain | IP Address | Description |
|---|---|---|---|
| webgoat | dojo.lan | 10.0.0.50 | WebGoat Application |
| django | dojo.lan | 10.0.0.50 | Django Application |
| casino | dojo.lan | 10.0.0.50 | Casino Application |
| shop | dojo.lan | 10.0.0.50 | Juice Shop |
| cheese | dojo.lan | 10.0.0.50 | Cheese Shop |
Save and Apply Changes after adding all entries.
Step 2: Reverse Proxy Configuration on Web Server¶
On the server hosting your applications (10.0.0.50), configure Apache as a reverse proxy to route requests based on the domain name.
Enable Required Apache Modules¶
Create Virtual Host Configurations¶
For each application, create a virtual host configuration file in /etc/apache2/sites-available/.
Example: casino.dojo.lan.conf
<VirtualHost *:80>
ServerName casino.dojo.lan
ProxyPreserveHost On
ProxyPass / http://127.0.0.1:3000/
ProxyPassReverse / http://127.0.0.1:3000/
ErrorLog ${APACHE_LOG_DIR}/casino_error.log
CustomLog ${APACHE_LOG_DIR}/casino_access.log combined
</VirtualHost>
Configuration for Other Applications:
| Domain | Port | Config File |
|---|---|---|
| webgoat.dojo.lan | 8081 | webgoat.dojo.lan.conf |
| django.dojo.lan | 8091 | django.dojo.lan.conf |
| shop.dojo.lan | 3008 | shop.dojo.lan.conf |
| cheese.dojo.lan | 8008 | cheese.dojo.lan.conf |
Enable Virtual Hosts¶
sudo a2ensite casino.dojo.lan.conf
sudo a2ensite webgoat.dojo.lan.conf
sudo a2ensite django.dojo.lan.conf
sudo a2ensite shop.dojo.lan.conf
sudo a2ensite cheese.dojo.lan.conf
sudo systemctl reload apache2
Step 3: Testing Configuration¶
Test DNS Resolution:
Test Web Access:
Open a browser and navigate to http://casino.dojo.lan/. You should see the application running on port 3000, not the default Apache page.
If issues occur, examine the logs:
🐛 Common Issues¶
- Seeing default Apache page: Ensure the virtual host is enabled and
ServerNamematches exactly - DNS not resolving: Verify Host Overrides are saved and DNS Resolver is running
- Connection refused: Check that the backend application is running on the specified port
Configuration Summary¶
Your pfSense lab setup should now include:
- ✅ WAN and LAN interfaces properly assigned
- ✅ Static IP addressing for LAN network
- ✅ DHCP server for automatic client configuration
- ✅ DNS Resolver for internal name resolution
- ✅ Firewall rules controlling lab traffic
- ✅ Local DNS entries for web applications
- ✅ RFC1918 settings configured for host connectivity
This configuration provides a secure, isolated environment for penetration testing while maintaining necessary connectivity and services.