PFSense - VLAN (Virtual LAN) - Set up a VLAN
Create the VLAN
Navigate to Interfaces → Assignments.
Select VLANs.
Click the Add button.
Parent Interface:
em1. Typically this is the
LAN port.
VLAN Tag: 20. Use any unique number from 2 to 4096. Here 20 is used as an example.
VLAN Priority: 0. Keep the default.
Description: VLAN 20. Any description will do.
Click Save.
Setup an Interface for the VLAN
Navigate to Interfaces Assignments.
Against Available network ports, click the drop down arrow and Choose VLAN 20 on em1.
Click the interface link for OPT1.
In General Configuration:
Enable: Checked.
Description: VLAN20. Give the VLAN a nicer name.
IPv4 Configuration Type: Static IPv4.
IPv6 Configuration Type: None.
In Static IPv4 Configuration:
IPv4 Address: 192.168.20.1.
Click the drop-down for the Subnet Mask and select 24.
Click Save.
Click Apply Changes at the top.
NOTE: The VLAN interface is now created.
DHCP Server for VLAN 20
Navigate to Services → DHCP Server.
In General Options:
NOTE: The Range is limited to those 100 addresses.
Change this as needed.
Firewall Rules
To allow the VLAN to get out to the Internet a firewall rule is needed.
Additional restrictions can be set against client of the VLAN with additional firewall rules.
Allowing VLAN 20 Clients Internet Access
Navigate to Firewall –> Rules:
Click on an Add button.
Action: Pass.
Interface: VLAN20. Or whatever name you gave the VLAN.
Protocol: Any
Source:
Description: Allow OPT1VLAN20 to any
Click Save.
Click Apply Changes at the top.
NOTE: At this point, clients on VLAN 20 that are issued IP addresses on the 192.168.20.0 subnet should be able to get out to the Internet.
NOTE: When you create a firewall rule, it may not seem as if it goes into effect immediately.
The reason:
Denying VLAN 20 Clients to the pfSense Web GUI
Add an Alias for the pfSense GUI
Navigate to Firewall –> Aliases.
Firewall Rules
Navigate to Firewall –> Rules.
Select Floating:
Click on a green Add button.
Action: Block.
Quick: Checked.
Interface: Select the VLAN(s) to be denied access.
Direction: in.
Address family: IPv4.
Protocol: TCP\UDP.
Source:
Destination:
Destination Port Range:
Description:
VLAN 20 – no access to pfSense GUI
Click Save.
Click Apply Changes at the top.
NOTE: Navigate to System–>Advanced to see whether the actual pfSense GUI is set to run on either HTTP or HTTPS.
To ensure that access is denied against both HTTP and HTTPS, setup a similar firewall rule for both.
Block Access to LAN when on VLAN 20
Navigate to Firewall → Rules
Click on VLAN20:
Click the Add button (up arrow), so this needs to be the first rule in the list.
Action: Block.
Interface: VLAN20.
Protocol: Any.
Source:
-
Description:
VLAN 20 – cannot access LAN.
Click Save.
Click Apply Changes at the top.
IMPORTANT NOTE: Trying to restrict a client on a VLAN from accessing a device on the LAN will not work if used with an unmanaged switch.
This limitation does not necessarily apply to Wireless Access Points that have VLAN capabilities (such as Ubiquiti Wireless Access Points); as they have managed switches built into them.