Configuring VLAN in your freebsd box
Lately , I was given task to create a progam that I had to deal in dot1q protocol (by the way the program is based on sending packet over the wire and have to deal in multi-session support). I was doing socket programming and worst I had to edit the connect() function of kernel to be able to change my source IP address in connect() function. Damn it would take me a alot of time to edit the connect() function but what I did is to find other way to patch the output. And creating vlans in my freebsd is the patch that I took, but actually its not the real solution in my problem, it was just a patch.
Here’s the procedure to have a vlan in your freebsd.
first add this line to your /boot/loader.conf. :
This will enable your vlan support in your freebsd or you can do :
But this will just load temporary vlan support, when you reboot
you have to load it again.
Now in your ifconfig do this:
ifconfig device.vlan_number ip_address/mask
ifconfig sk0.2 create 192.168.2.1/24
This will create vlan in your ifconfig. Of course the connected network must be in the same vlan ID.
Now if you want to remove the vlan id in your freebsd. You can do this:
ifconfig sk0.2 destroy
This will remove your vlan configuration.
And that would be all.