User Tools

Site Tools


network:freebsdvlan

This is an old revision of the document!


Tagged Vlans on FreeBSD

On the Fly

ifconfig vlan_device.vlan_id create

Using rc.conf

The first thing to do is to list the VLANs that will be on the em0 adapter:

vlans_em0="101 102"

Be be to bring the parent interfaces up before you configure the IPv4 on the vlans

ifconig_em0="up"

This will cause FreeBSD to create new “virtual” network adapters called lan0.101 and lan0.102 – and these seem to function much like any other network card, you can use ifconfig on them. Then, configure the actual addresses for the new virtual adapters:

ifconfig_em0_101="inet 10.1.1.1/24"
ifconfig_em0_102="inet 10.1.2.1/24"

Now reboot your system or run /etc/rc.d/netif restart - you should now see something like this in your ifconfig output:

em0.101: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
        ether 00:1b:b9:8b:ca:33
        inet 10.1.1.1 netmask 0xffffff00 broadcast 10.1.1.255
        inet6 fe80::210:b5ff:fe0d:9c75%lan0.101 prefixlen 64 scopeid 0x5
        nd6 options=3<PERFORMNUD,ACCEPT_RTADV>
        media: Ethernet autoselect (100baseTX <full-duplex,flowcontrol,rxpause,txpause>)
        status: active
        vlan: 101 parent interface: lan0
em0.102: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
        ether 00:1b:b9:8b:ca:33
        inet 10.1.2.1 netmask 0xffffff00 broadcast 10.1.2.255
        inet6 fe80::210:b5ff:fe0d:9c75%lan0.102 prefixlen 64 scopeid 0x6
        nd6 options=3<PERFORMNUD,ACCEPT_RTADV>
        media: Ethernet autoselect (100baseTX <full-duplex,flowcontrol,rxpause,txpause>)
        status: active
        vlan: 102 parent interface: lan0
network/freebsdvlan.1477505408.txt.gz · Last modified: 2016/10/26 13:10 by tschulz