how to use vlans on freebsd interfaces

this example assumes:

  • physical device em0

  • vlan 1

  • cisco switch running ios

manual configuration:

configure the physical interface:
ifconfig em0 up
create the vlan interface:
ifconfig vlan0 vlan 1 vlandev em0
assign the vlan interface its ip address:
ifconfig vlan0 inet netmask
ifconfig_vlan0="inet netmask vlan 1 vlandev em0"
configure the switch:
interface Gi/1/1
switchport trunk encapsulation dot1q
switchport trunk allowed vlan 1
switchport mode trunk