Cannot get VLAN setup to work

OS= 2x FreeBSD-12, 1x FreeBSD-11
I have three bare metal hosts connected on a single non-managed switch. I am testing vlan configurations using one of the FreeBSD-12 hosts as a duel homed router and the other two hosts as single homed device nodes.

The network configuration for the host acting as a gateway is:
Code:
# cat /etc/rc.conf
### Networks  ### FreeBSD-12
hostname="gway04"

gateway_enable="YES"          # Set to YES if this host will be a gateway
defaultrouter="A.B.C.1"       # FIB of last resort

### Physical interfaces:
# LAN == em0
# WAN == em1

### Interface IP addresses and IP aliases
ifconfig_em0="inet 192.168.149.4/25"
ifconfig_em0_alias1="inet 192.168.149.1"

ifconfig_em1="inet A.B.C.4/25"

### Cloned interfaces for Jails and VLANs
cloned_interfaces="vlan150 vlan151"

### VLANs
ifconfig_vlan150="inet 192.168.150.4/24 vlan 150 vlandev em0"
ifconfig_vlan150_alias1="inet 192.168.150.1"

ifconfig_vlan151="inet 192.168.151.4/24 vlan 151 vlandev em0"
ifconfig_vlan151_alias1="inet 192.168.151.1"

PF is running on the gway04 with nat enabled and pass all as the default rule.


One of the nodes is configured with:
Code:
# cat /etc/rc.conf
### Networks ### FreeBSD-11
hostname="vhost04"

gateway_enable="NO"          # Set to YES if this host will be a gateway
defaultrouter="192.168.149.1"

ifconfig_em0="inet 192.168.149.44/25"    # Requires NAT enabled on gateway
ifconfig_em0_alias150="inet 192.168.150.44/24"

The other with:
Code:
# cat /etc/rc.conf
### Networks ### FreeBSD-12
hostname="vhost05"

gateway_enable="NO"          # Set to YES if this host will be a gateway
defaultrouter="192.168.151.1"

ifconfig_em0="inet 192.168.151.5/24"    # Requires NAT enabled on gateway

There is evidently some error in this configuration but I cannot see what it is. When I attempt to ping 192.168.151.1 from vhost05 there is no route to host. Likewise, when I ping from gway04 to 192.168.151.5 there is no route to host. What am I doing wrong?
 
Does your switch support VLANs? And is the port on the switch configured as a trunk (tagged)?

Note that your gateway host is mixing native VLAN (no VLAN id; i.e. untagged) and VLAN tagged on the same interface. That's possible but requires a specific configuration on the switch.

Edit:
I have three bare metal hosts connected on a single non-managed switch.
That's never going to work. You need a managed switch with VLAN support.
 
That's never going to work. You need a managed switch with VLAN support.

Depends. There are some unmanaged switches that are "vlan-aware". Meaning, they will pass vlan tags through untouched, basically treating every port as a hybrid port with every vlan tag enabled. They won't add or remove tags, though, so every port has every vlan tag enabled. They're a pain to debug vlan issues with, though. HP ProCurve 1400 series do this, for example.

That being said, if you want to play with vlans, then you need to make sure everything in the network between the hosts supports proper vlan tagging (aka managed switches, access points with vlan support, routers with vlan support, etc).
 
Back
Top