Marcio Cunha

Home Network Infrastructure Management with VLANs, OPNsense and Inter-VLAN Routing

Learn how to isolate IoT devices, guests, and servers in a home network using VLANs, OPNsense, and firewall rules to ensure maximum security.

Marcio Cunha•4 min
Also available in:EspañolPortuguês
Summary
  • Network segmentation through VLANs prevents compromised IoT devices from reaching sensitive data on the main network
  • OPNsense acts as the central router and edge firewall, enforcing granular rules for inter-VLAN traffic
  • Managed switches are essential to propagate VLAN tags across physical cables using trunk ports
  • Inter-VLAN routing requires careful subnet planning and restrictive rules to prevent performance bottlenecks
  • Monitoring network traffic with integrated tools helps identify suspicious connections before they cause failures

Why segment your home network with VLANs?

Traditional home networks usually bundle everything together: work computers, smartphones, smart lightbulbs, voice assistants, and security cameras share the exact same digital space. In practice, this means if a single smart bulb suffers a cyber attack, the attacker gains direct access to your personal computer and backup files. VLAN separation (Virtual Local Area Networks, which divide a physical infrastructure into multiple isolated logical networks) solves this problem by creating invisible barriers between devices.

Isolating devices is not just about corporate paranoia, but a necessity in the age of the Internet of Things (IoT). Cheap connected devices rarely receive frequent security updates, making them easy targets for breaches. When we create separate networks, we limit the scope of a potential compromise, ensuring an infected appliance cannot snoop around the rest of your residential infrastructure.

The role of OPNsense in routing and security

To allow different VLANs to talk to each other when necessary, or to access the internet in a controlled manner, we need a device capable of understanding these network tags and enforcing strict rules. OPNsense is an open-source firewall and routing operating system based on FreeBSD, widely known for its robustness and friendly interface. In practice, it works as the traffic cop of your home, deciding who can pass from one street (VLAN) to another.

Besides acting as a router between VLANs, OPNsense houses the edge firewall where we build security policies. For instance, we can allow the home automation network to send commands to devices, but completely prohibit those same devices from accessing the internet or the main computer network. This 'zero trust' approach ensures every data packet is validated before reaching its destination.

Configuring managed switches and trunk ports

VLANs exist only on a logical plane until physical equipment knows how to handle them. To connect OPNsense to Wi-Fi access points and switches scattered around the house, we use ports known as trunks (virtual conduits carrying packets from multiple VLANs simultaneously using special labels called 802.1Q tags). In practice, the network cable leaving the firewall carries multiple networks at once, and each switch knows exactly which port to direct each packet to.

On the other end, we have access ports, which deliver a clean, untagged signal to common devices like a Smart TV or a gaming console. Setting up managed switches requires attention to detail, as an error in tag assignment can completely isolate a device or drop communication with the router itself, requiring a physical hardware reset.

Subnet planning and IP addressing

Before creating any rules in OPNsense, it is essential to design your home's IP addressing map. Using standardized private addresses, such as the RFC 1918 ranges, simplifies organization. For example, the main network can use the 192.168.10.0/24 range, while the guest network uses 192.168.20.0/24 and IoT devices sit on 192.168.30.0/24. In practice, this visual separation in numbers helps quickly pinpoint the origin of a problem when reviewing system logs.

Each VLAN requires its own default gateway, which will be the corresponding IP address of the virtual interface configured in OPNsense. It is also important to size subnets properly; while a /24 range offers over 250 addresses—usually plenty for residential settings—keeping control over the DHCP server scope prevents unknown devices from gaining easy access.

Step-by-step implementation of Inter-VLAN routing

To bring the architecture to life, follow a logical sequence of configuration in the hardware and management software.

  1. Access the web interface of your managed switch and create the desired VLANs, assigning unique identification numbers (IDs) to each.
  2. Configure the port connecting to OPNsense as a trunk port, allowing all created VLANs to pass through, and set the final device ports as access ports.
  3. In the OPNsense dashboard, navigate to the interfaces section, assign the new physical VLANs, and enable each of them by setting their respective gateway IP addresses.
  4. Create firewall rules in the tab corresponding to each VLAN, explicitly defining what is permitted (such as DNS and WAN access) and blocking unwanted cross-traffic.
  5. Connect a test device to a physical port mapped to the new VLAN and validate that it obtains an IP via DHCP and reaches only permitted destinations.

Final Considerations and Infrastructure Maintenance

Maintaining a segmented home network requires discipline and ongoing monitoring of event logs. As new smart devices and computers join the environment, fine-tuning firewall rules becomes natural to balance convenience and security. The time invested in initial configuration pays off handsomely by shielding your privacy against modern digital threats.

The constant evolution of connectivity standards reinforces the importance of relying on a robust router like OPNsense. By mastering inter-VLAN routing, you transform a simple residential internet connection into an enterprise-grade infrastructure, maintaining total control over the data flow entering and leaving your home.