OpenBSD | Networking (1|base)

di | Ottobre 17, 2026

Per connettere una macchina OpenBSD ad una rete, è necessario come prima cosa individuare il dispositivo (o i dispositivi) di rete presenti, che il kernel, oltre a riconoscerli, è capace di supportare. Per far questo, utilizzo il comando ifconfig. Questo è ciò che mi appare col mio magnifico Lenovo ThinkPad i5.

Ad occhio, le interfacce di rete rilevate da OpenBSD sulla mia macchina sono iwm0 ed em0.

Bello vero? : – )

arcadia$ ifconfig 

lo0: flags=2008049<UP,LOOPBACK,RUNNING,MULTICAST,LRO> mtu 32768
	index 4 priority 0 llprio 3
	groups: lo
	inet6 ::1 prefixlen 128
	inet6 fe80::1%lo0 prefixlen 64 scopeid 0x4
	inet 127.0.0.1 netmask 0xff000000

iwm0: flags=808843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST,AUTOCONF4> mtu 1500
	lladdr b0:35:9f:9d:a4:40
	index 1 priority 4 llprio 3
	groups: wlan egress
	media: IEEE802.11 autoselect (HT-MCS6 mode 11n)
	status: active
	ieee80211: join gnu chan 1 bssid e2:0b:42:3d:b1:d9 56% wpakey wpaprotos wpa2 wpaakms psk wpaciphers ccmp wpagroupcipher ccmp
	inet 10.84.119.5 netmask 0xffffff00 broadcast 10.84.119.255

em0: flags=8802<BROADCAST,SIMPLEX,MULTICAST> mtu 1500
	lladdr 54:e1:ad:98:1a:60
	index 2 priority 0 llprio 3
	media: Ethernet autoselect (none)
	status: no carrier

enc0: flags=0<>
	index 3 priority 0 llprio 3
	groups: enc
	status: active

pflog0: flags=141<UP,RUNNING,PROMISC> mtu 33136
	index 5 priority 0 llprio 3
	groups: pflog

iwm0 sta per “Primo dispositivo gestito dal driver iwm”. Se ne avesse rilevato due, di questi dispositivi, mi sarei ritrovato un iwm0 ed un iwm1. Per avere maggiori dettagli su driver iwm e relativi dispositivi supportati da questo, si può consultare la magnifica man page.

arcadia$ man iwm

IWM(4)                       Device Drivers Manual                      IWM(4)

NAME
     iwm - Intel 7000/8000/9000 IEEE 802.11a/ac/b/g/n wireless network device

SYNOPSIS
     iwm* at pci?

DESCRIPTION
     The iwm driver provides support for Intel Wireless 7260, 7265, 3160,
     3165, 3168, 8260, 8265, and 9260 PCIe Mini Card and M.2 network adapters,
     and for Intel Wireless 9560 Integrated Connectivity (CNVi) network
     adapters with companion RF M.2 modules.

     These are the modes the iwm driver can operate in:

     BSS mode       Also known as infrastructure mode, this is used when
                    associating with an access point, through which all
                    traffic passes.  This mode is the default.

     monitor mode   In this mode the driver is able to receive packets without
                    associating with an access point.  This disables the
                    internal receive filter and enables the card to capture
                    packets from networks which it wouldn't normally have
                    access to, or to scan for access points.

     The iwm driver can be configured to use Wired Equivalent Privacy (WEP) or
     Wi-Fi Protected Access (WPA1 and WPA2).  WPA2 is currently the most
     secure encryption standard for wireless networks supported by OpenBSD.
     It is strongly recommended that neither WEP nor WPA1 are used as the sole
     mechanism to secure wireless communication, due to serious weaknesses.
     WPA1 is disabled by default and may be enabled using the option
     "wpaprotos wpa1,wpa2".  For standard WPA networks which use pre-shared
     keys (PSK), keys are configured using the "wpakey" option.  WPA-
     Enterprise networks require use of the wpa_supplicant package.  The iwm
     driver offloads both encryption and decryption of unicast data frames to
     the hardware for the CCMP cipher.

     In BSS mode the driver supports background scanning; see ifconfig(8).

     The iwm driver can be configured at runtime with ifconfig(8) or on boot
     with hostname.if(5).

FILES
     The driver needs one of the following firmware files, which are loaded
     when an interface is brought up:

           /etc/firmware/iwm-3160-17
           /etc/firmware/iwm-3168-29
           /etc/firmware/iwm-7260-17
           /etc/firmware/iwm-7265-17
           /etc/firmware/iwm-7265D-29
           /etc/firmware/iwm-8000C-36
           /etc/firmware/iwm-8265-36
           /etc/firmware/iwm-9000-46
           /etc/firmware/iwm-9260-46

     These firmware files are not free because Intel refuses to grant
     distribution rights without contractual obligations.  As a result, even
     though OpenBSD includes the driver, the firmware files cannot be included
     and users have to download these files on their own.

     A prepackaged version of the firmware can be installed using
     fw_update(8).

EXAMPLES
     The following example scans for available networks:

           # ifconfig iwm0 scan

     The following hostname.if(5) example configures iwm0 to join network
     "mynwid", using WPA key "mywpakey", obtaining an IP address using DHCP:

           join mynwid wpakey mywpakey
           inet autoconf

DIAGNOSTICS
     iwm0: device timeout  A frame dispatched to the hardware for transmission
     did not complete in time.  The driver will reset the hardware.  This
     should not happen.

     iwm0: fatal firmware error  For some reason, the firmware crashed.  The
     driver will reset the hardware.  This should not happen.

     iwm0: radio is disabled by hardware switch  The radio transmitter is off
     and thus no packet can go out.  The driver will reset the hardware.  Make
     sure the laptop radio switch is on.

     iwm0: could not read firmware ... (error N)  For some reason, the driver
     was unable to read the firmware image from the filesystem.  The file
     might be missing or corrupted.

     iwm0: firmware too short: N bytes  The firmware image is corrupted and
     can't be loaded into the adapter.

     iwm0: could not load firmware  An attempt to load the firmware into the
     adapter failed.  The driver will reset the hardware.

SEE ALSO
     arp(4), ifmedia(4), intro(4), netintro(4), pci(4), hostname.if(5),
     ifconfig(8)

HISTORY
     The iwm device driver first appeared in OpenBSD 5.7.

OpenBSD 7.8                     March 27, 2025                          IWM(4)

Nell’installazione base di OpenBSD le manpage son tutte presenti. Non è necessaria nessuna connessione ad internet e nessun LLM per utilizzare questo sistema operativo.

Dopodichè leggo i messaggi del kernel con dmesg, per conoscere dettagli specifici sul reale dispositivo hardware rilevato su PCI

arcadia$ dmesg | grep iwm
iwm0 at pci2 dev 0 function 0 "Intel AC 8260" rev 0x3a, msi
iwm0: hw rev 0x200, fw ver 36.ca7b901d.0, address 0b:53:f9:9d:a4:40

Scansionare l’etere alla ricerca di un punto di accesso.

Adesso che conosco vita, morte e miracoli del mio dispositivo e relativo driver che lo supporta, posso passare alla ricerca dei punti di accesso presenti nell’ambiente circostante, che mi permetteranno di entrare in una rete lan, e per farlo non devo installare nulla, mi basta sempre e solo il comando ifconfig. Nel sistemi GNU/Linux è necessario installare un pacchetto extra, ed il comando iwconfig per ottenere tale funzionalità. Questo è uno dei tanti motivi per cui GNU/Linux è uno unix-like ed OpenBSD uno UNIX.

arcadia$ ifconfig iwm0 scan

iwm0: flags=808843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST,AUTOCONF4> mtu 1500
	lladdr b0:35:9f:9d:a4:40
	index 1 priority 4 llprio 3
	groups: wlan egress
	media: IEEE802.11 autoselect (HT-MCS7 mode 11n)
	status: active
	ieee80211: join gnu chan 1 bssid 0b:53:f9:9d:a4:40 80% wpakey wpaprotos wpa2 wpaakms psk wpaciphers ccmp wpagroupcipher ccmp

		nwid gnu chan 1 bssid 0b:53:f9:9d:a4:40 80% HT-MCS7 privacy,short_preamble,short_slottime,radio_measurement,wpa2 

		nwid TIM-23275439 chan 11 bssid 35:5d:33:9d:e5:c1 25% HT-MCS31 privacy, short_preamble, short_slottime, radio_measurement, wpa2
 
	inet 10.84.119.5 netmask 0xffffff00 broadcast 10.84.119.255
 

Cosa ci dice esattamente, il precedente comando? Che nelle vicinanze ci sono 2 punti di accesso presumibilmente a delle reti locali : gnu e TIM-23275439. Il primo è il mio cellulare android (hotspot), mentre il secondo è un router di casa. Segue il canale, il MAC Adress e la potenza di segnale. Chiaramente ricevo un segnale piu’ potente dal cellulare che non è lontano da qui (80%), mentre il router emette un segnale debole perchè è a 2 piani sotto.

Entrambi i punti di accesso permettono l’autenticazione tramite protocollo wpa2.

Accesso ad una rete.

Per accedere ad una delle due reti è necessario fornire una passpharse, normalmente è così : – )

arcadia$ ifconfig iwm0 \
nwid gnu \
wpakey <YOUR_PASSPHARSE> \
up 

arcadia$

Assegnazione parametri di rete.

Per configurare i parametri di rete: IP, Broadcast ed eventuali DNS Server e Gateway di default, è necessario eseguire il comando /etc/netstart come utente root o altro utente autorizzato da esso.

arcadia$ doas sh /etc/netstart

arcadia$ traceroute openbsd.org

 1  10.84.119.225 (10.84.119.225)  3.735 ms  2.208 ms  1.978 ms
 2  172.20.130.126 (172.20.130.126)  221.786 ms  193.151 ms 172.20.130.125 (172.20.130.125)  153.573 ms
 3  172.20.128.4 (172.20.128.4)  113.213 ms 172.20.128.0 (172.20.128.0)  73.162 ms  33.307 ms
 4  172.19.201.161 (172.19.201.161)  22.023 ms  35.958 ms  35.935 ms
 5  172.18.19.2 (172.18.19.2)  35.713 ms  31.279 ms  24.337 ms
 6  172.17.48.18 (172.17.48.18)  163.351 ms 172.17.48.10 (172.17.48.10)  151.411 ms  241.451 ms
 7  172.19.177.36 (172.19.177.36)  88.045 ms  47.822 ms  37.382 ms
 8  172.19.177.4 (172.19.177.4)  37.86 ms 172.19.177.6 (172.19.177.6)  58.058 ms 172.19.177.8 (172.19.177.8)  49.797 ms
 9  195.22.205.116 (195.22.205.116)  50.193 ms 195.22.192.144 (195.22.192.144)  33.58 ms  47.511 ms
10  195.22.192.139 (195.22.192.139)  47.973 ms  25.851 ms  39.479 ms
11  ae9.cr6-mil2.ip4.gtt.net (212.221.95.185)  59.715 ms  54.053 ms  48.279 ms
12  ae3.cr2-cal1.ip4.gtt.net (89.149.182.97)  209.074 ms  210.978 ms  216.581 ms
13  yyc-border.openbsd.org (204.209.252.3)  200.885 ms  202.503 ms  211.443 ms
14  bb-pf.openbsd.org (199.185.230.2)  199.973 ms  199.557 ms  199.895 ms
15  199.185.178.80 (199.185.178.80)  193.702 ms  194.343 ms  193.327 ms

Memorizzare la configurazione.

Se in rete vi connettete sempre dallo stesso punto di accesso, potete salvare i parametri di connessione di un’interfaccia di rete (nel mio caso iwm0) nel file /etc/hostname.<interfaccia>, in maniera tale che ai prossimi boot o reboot della macchina, questa si connetta alla rete in maniera automatica.

arcadia# cat /etc/hostname.iwm0
join 'gnu' wpakey '<PASSWORD>'
inet autoconf

# :::... EOF 

Questo è solo un assaggio, di una serie di appunti su OpenBSD ed il Networking.