This document describes a convenient network configuration for notebooks with OpenBSD. I use the trunk(4) interface to switch between wired and wireless network connections. A wired connection is preferred over wifi, because its more reliable. The ifstated(8) it used to trigger link-state changes on the wired interface, so dhcpleased(8) is notified to renew the dhcp lease.
This setup works best where WIFI and wire are on the same network. The fixed MAC address on the trunk(4) interface guaranties the same IP address on WIFI and wire. Thus, you can switch between them without losing network sessions.
trunkproto failover trunkport em0 trunkport iwm0 lladdr xx:xx:xx:xx:xx:xx inet6 autoconf inet autoconf up
up
join 'Home Wi-Fi' wpa wpakey 'xxxxxxxx' join 'Free Wi-Fi' ... up
if em0.link.up || em0.link.down run "dhcpleasectl trunk0 > /dev/null"
# rcctl enable ifstated # rcctl start ifstated # sh /etc/netstart