FreeBSD - Adding VLAN Tagged subinterface using ifconfig
Here's how to add a tagged vlan interface in FreeBSD all versions.
Step 1: create the vlan subinterface:
Code:
# ifconfig vlan122 create
Step 2: assign it a vlan ID and vlan device:
Code:
# ifconfig vlan122 vlan 122 vlandev em0
Step 3: check the vlan subinterface:
Code:
# ifconfig vlan122
vlan122: flags=8842<BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
ether 00:07:e9:a5:9b:fa
media: Ethernet autoselect (1000baseTX <full-duplex>)
status: active
vlan: 122 parent interface: em0
You will notice that interface status is not UP. This has to be changed once it is used.
Step 4: assign ip address:
Code:
# ifconfig vlan122 10.1.122.1/24
# ifconfig vlan122 up
# ifconfig vlan122
vlan122: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
ether 00:07:e9:a5:9b:fa
inet 10.1.122.1 netmask 0xffffff00 broadcast 10.1.122.255
media: Ethernet autoselect (1000baseTX <full-duplex>)
status: active
vlan: 122 parent interface: em0
This subinterface will be equivalent of a tagged logical interface in different vendors (Juniper for example).
To make this vlan tagged interface configuration persistent after reboot, edit
/etc/rc.conf file and add the following line / alter
cloned_interfaces in the networking section:
Code:
cloned_interfaces="... vlan122"
ifconfig_vlan122="inet 10.1.122.1/24 vlan 122 vlandev em0"
_________________
VPSie - SSD VPS servers in AMS-IX, LINX, DE-CIX
https://vpsie.com