Assume we have a switchport with an untagged (native) VLAN 10, plus two tagged VLANs 20 & 30 (see attached switch config). The device connected to that switchport has an internal interface eth0. Use this in /etc/rc.conf
:
# SYNCDHCP makes the boot process wait for address assignment
ifconfig_eth0="SYNCDHCP"
vlans_eth0="20 30"
ifconfig_eth0_20="SYNCDHCP"
ifconfig_eth0_30="inet 192.168.35.15/24"
This creates two VLAN interfaces eth0.20
& eth0.30
. eth0
is untagged for the device, although in the switchport configuration the port is marked as native vlan 10. Note the use of SYNCDHCP
in the base interface definition and the one for VLAN 20. Using DHCP
often results in no attached address. The DHCP request/repsonse cycle takes too long and gets lost.
If you don't want to delay your system startup waiting on DHCP addresses (for example, because you're coding a router or server), change all of the interfaces to static IPs like VLAN 30. Statically defined interfaces come up fast and are ready almost immediately.
That's it. It's that simple.
There's a lot of misinformaton out there. The above configuration started with info from /etc/defaults/rc.conf
and the RC.CONF(5) Man Page. I found that defaults file in a 13 year old post that had the correct information in it. Thank you bboard hero!