Post

Building a Virtual Security Home Lab: Part 4 - pfSense Firewall Configuration

A step-by-step guide for building your very own Cybersecurity Home Lab using VirtualBox

Banner Background by logturnal on Freepik
Hacker Image by catalyststuff on Freepik

In this module, we will finish the pending pfSense setup. After that, we will define firewall rules for the subnets we defined for our home lab.

pfSense General Configuration

Web Portal Setup

On the Kali Linux VM, open the web browser and navigate to https://10.0.0.1.

You will get the following message Warning: Potential Security Risk Ahead. This warning can be ignored. We get this warning because the URL that we are trying to access does not use the secure HTTP (HTTPS). Click on Advanced and then click on Accept the Risk and Continue.

pfsense-26

This will open the pfSense Web UI login page. Login using the default credentials.
Username: admin
Password: pfsense

pfsense-27

Click on Next.

pfsense-28

Click Next again.

pfsense-29

In the General Information section. Provide a Hostname and Domain name. This can be any name you choose. The hostname can be used to identify the pfSense VM on the network. Uncheck the Override DNS option and then click Next.

pfsense-30

Select your Timezone and then click Next.

pfsense-31

Scroll to the bottom of the page and look for the RFC1918 Networks section. Uncheck the Block RFC1918 Private Networks option.

pfsense-32

We disable this option because our WAN interface is not an real WAN interface. It uses an private IP address instead of an public IP address which would be used by a real WAN interface to connect to the Internet.
Our WAN interface uses a private IP address to send data packets to the host system which then sends the data packets to the router present in the network.

Don’t change any value on this page. Click on Next.

pfsense-33

Enter a new password for the admin user. Store the password in a secure place.

pfsense-34

Click on Reload to apply the changes.

pfsense-35

Click on Finish.

pfsense-36

Once the onboarding is complete we will be able to access the pfSense dashboard.

pfsense-37

Interface Renaming

From the navigation bar select Interfaces -> OPT1.

pfsense-38

In the Description field enter CYBER_RANGE. Scroll to the bottom and click on Save.

pfsense-39

At the top of the page, a new popup will appear. Click on Apply Changes.

pfsense-40

From the navigation bar select Interfaces -> OPT2.

pfsense-41

In the Description field enter AD_LAB. Scroll to the bottom of the page and click on Save. A popup will appear at the top of the page click on Apply Changes.

pfsense-42

DNS Resolver Configuration

From the navigation bar select Services -> DNS Resolver.

pfsense-43

Scroll to the bottom of the page, look for the highlighted options and enable them. No need to save just yet. Scroll to the top of the page.

pfsense-44

Click on Advanced Settings.

pfsense-45

Scroll down to the Advanced Resolver Options section and enable the highlighted options. Scroll to the end and click on Save.

pfsense-46

A popup will appear at the top of the page. Click on Apply Changes.

pfsense-47

Advanced Configuration

From the navigation bar select System -> Advanced.

pfsense-48

Go to the Networking tab

pfsense-49

Scroll to the end in the Network Interfaces section and enable the highlighted option. This option should improve the performance of pfSense. Click on Save.

pfsense-50

A popup will appear click on OK to reboot pfSense.

pfsense-51

The following page will be shown while pfSense applies the changes.

pfsense-52

Once the reboot is complete we will be asked to log in again. Use the new password to access the Dashboard.

pfsense-27

Kali Linux Static IP Assignment

From the navigation bar select Status -> DHCP Leases.

pfsense-53

In the Leases section, we should see the Kali Linux VM with its current IP address. Click on the highlighted + icon to assign a static IP to Kali Linux. The static IP will make it easier for us to apply firewall rules to interfaces that should only be able to reach the Kali VM.

pfsense-54

In the IP Address input enter 10.0.0.2. Scroll to the bottom and click on Save.

pfsense-55

A popup will show up at the top of the page. Click on Apply Changes.

pfsense-56

Refresh Kali Linux IP Address

Open a terminal on the VM. Use the following command to see the current IP address.

1
ip a l eth0

We want the VM to release the current IP address and use the static IP that was reserved. This can be achieved using the following command:

1
sudo ip l set eth0 down && sudo ip l set eth0 up

Enter password when prompted. To confirm that the VM is using the static IP run the following command:

1
ip a l eth0

pfsense-57

pfSense Firewall Configuration

From the navigation bar select Firewall -> Rules.

pfsense-58

LAN Rules

Go to the LAN tab. The LAN tab will have some predefined rules.

pfsense-59

Click on the “Add rule to top” button to create a new rule.

pfsense-60

Change the following options:
Action: Block
Address Family: Ipv4+IPv6
Protocol: Any
Source: LAN subnets
Destination: WAN subnets
Description: Block access to services on WAN interface

Scroll to the bottom and click on Save.

pfsense-61

A popup will appear at the top of the page. Click on Apply Changes.

pfsense-62

The final LAN rules should look as follows.

pfsense-63

The order of the rules is important. If the order is not correct. Drag the rules around till it matches the above image.

CYBER_RANGE Rules

Before creating the rules for CYBER_RANGE we need to create a Alias. From the navigation bar select Firewall -> Aliases.

pfsense-64

In the IP tab click on Add to create a new alias.

pfsense-65

Enter the following details:
Name: RFC1918
Description: Private IPv4 Address Space
Type: Network(s)
Network 1: 10.0.0.0/8
Network 2: 172.16.0.0/12
Network 3: 192.168.0.0/16
Network 4: 169.254.0.0/16
Network 5: 127.0.0.0/8

Click on Save to create an alias.

pfsense-66

A popup will show up at the top click on Apply Changes.

pfsense-67

The final result should be as follows:

pfsense-68

From the navigation bar select Firewall -> Rules. Select the CYBER_RANGE tab.

pfsense-69

Use the “Add rule to end” button for all the rules.

pfsense-71

Configure the rule as follows: Address Family: IPv4+IPv6
Protocol: Any
Source: CYBER_RANGE subnets
Destination: CYBER_RANGE address
Description: Allow traffic to all devices on the CYBER_RANGE network

Scroll to the bottom and click on Save.

pfsense-70

A popup will appear at the top to save the changes, no need to click on that just yet. Click on the “Add rule to end” button to create a new rule.

The rule has the following details:
Protocol: Any
Source: CYBER_RANGE subnets
Destination: Address or Alias - 10.0.0.2
Description: Allow traffic to Kali Linux VM

Scroll to the bottom and click on Save.

pfsense-72

Click on the “Add rule to end” button to create a new rule.

Create a rule with the following settings:
Protocol: Any
Source: CYBER_RANGE subnets
Destination: Address or Alias - RFC1918 (Select Invert match)
Description: Allow to any non-private IPv4 Address

Scroll to the bottom and click on Save.

pfsense-73

Click on the “Add rule to end” button to create a new rule.

Create a rule with the following settings:
Action: Block
Address Family: IPv4+IPv6
Protocol: Any
Source: CYBER_RANGE subnets
Description: Block access to everything

Scroll to the bottom and click on Save.

pfsense-74

Click on the Apply Changes button in the popup at the top of the screen.

pfsense-75

The final rules should look as follows:

pfsense-76

AD_LAB Rules

Click on the AD_LAB tab. Use the “Add rule to end” button to create new rules.

pfsense-77

Create a rule with the following settings:
Action: Block
Address Family: IPv4+IPv6
Protocol: Any
Source: AD_LAB subnets
Destination: WAN subnets
Description: Block access to services on WAN interface

Scroll to the bottom and click on Save.

pfsense-78

A popup will appear at the top to save the changes, no need to click on that just yet. Click on the “Add rule to end” button to create a new rule.

The rule has the following details:
Action: Block
Address Family: IPv4+IPv6
Protocol: Any
Source: AD_LAB subnets
Destination: CYBER_RANGE subnets
Description: Block traffic to CYBER_RANGE interface

Scroll to the bottom and click on Save.

pfsense-79

Click on the “Add rule to end” button to create a new rule.

The rule has the following details:
Address Family: IPv4+IPv6
Protocol: Any
Source: AD_LAB subnets
Description: Allow traffic to all other subnets and Internet

Scroll to the bottom and click on Save.

pfsense-80

Click on the Apply Changes button in the popup at the top of the screen.

pfsense-81

The final rules should look as follows:

pfsense-82

pfSense Reboot

Now we need to restart pfSense to persist the firewall rules. From the navigation bar select Diagnostics -> Reboot.

pfsense-118

Click on Submit.

pfsense-119

Once pfSense boots up you will be redirected to the login page.

In the next module, we will add some vulnerable VMs to the CYBER_RANGE interface and then we will test our connectivity to them from the Kali Linux VM.

Part 5 - Cyber Range Setup

This post is licensed under CC BY 4.0 by the author.