OpenBSD: automate wired/wifi network connection

Despite of missing applications like NetworkManager in OpenBSD, it’s possible to implement some kind of network autodetection, wired and wireless. I launch the following script in the boot process:




WIFI_SCRIPT=”/etc/wifinwid ${IF_WIRELESS}”

STATE_IF_WIRED=`ifconfig $IF_WIRED |grep status|cut -d: -f 2 |sed -E “s/ //g” `


if [ “$STATE_IF_WIRED” = “nocarrier” ]; then

Take note of ‘/etc/wifinwid’ script. This script can be grabbed from:

When OpenBSD is starting this script is executed, launching the wifi script is wired network is down. If my wired nic is up then the wifi script is not launched.

The main problem with this solution is when the wireless network is off. You need mannually activate the wired one. I use another script:



ifconfig iwn0
route delete default
route delete default
dhclient em0

I assign a not real address for the wireless nic and delete the gateway. Maybe using configuration files like hostname.em0 or so is better.


About jjjesss

I'm a guy interested in technology, bsd fan and concerned about the world around.
This entry was posted in BSD, OpenBSD. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s