1.\"- 2.\" SPDX-License-Identifier: BSD-2-Clause 3.\" 4.\" Copyright (c) 2024 Alexander Ziaee <concussious@runbox.com> 5.\" 6.Dd April 17, 2024 7.Dt "NETWORKING" 7 8.Os 9.Sh NAME 10.Nm networking , 11.Nm wifi 12.Nd quickstart guide to connecting to a network 13.Sh DESCRIPTION 14In the following examples, it is assumed that we are connecting to Ethernet 15with the first interface found by the 16.Xr em 4 17driver, and Wi-Fi with the first interface found by the 18.Xr iwn 4 19driver, though your hardware will vary. 20.Sh EXAMPLES 21.Bl -tag -width 0n 22.It Sy Connecting to an Ethernet network with DHCP: 23.Bd -literal -offset 2n 24.Ic # dhclient em0 25.Ed 26.It Sy Connecting to a cellular network with USB tethering: 27.Pp 28Load the USB tethering driver, 29.Xr urndis 4 : 30.Bd -literal -offset 2n 31.Ic # kldload urndis 32.Ed 33.Pp 34Ask for a DHCP lease on the USB tethering interface: 35.Bd -literal -offset 2n 36.Ic # dhclient ue0 37.Ed 38.It Sy Connecting to a Wi-Fi network: 39.Pp 40Identify your Wi-Fi hardware: 41.Bd -literal -offset 2n 42.Ic % sysctl net.wlan.devices 43.Ed 44.Pp 45Configure your Wi-Fi hardware as wlan0 interface: 46.Ed 47.Bd -literal -offset 2n 48.Ic # sysrc wlans_iwn0="wlan0" 49.Ed 50.Pp 51Set that interface to negotiate a DHCP lease with 52.Xr wpa_supplicant 8 : 53.Bd -literal -offset 2n 54.Ic # sysrc ifconfig_wlan0="WPA SYNCDHCP" 55.Ed 56.Pp 57Enter the details of the Wi-Fi network: 58.Bd -literal -offset 2n 59.Ic # wpa_passphrase \(dqmyssid\(dq \(dqmypassphrase\(dq >> wpa_supplicant.conf 60.Ed 61.Pp 62Restart the network interface daemon: 63.Bd -literal -offset 2n 64.Ic # service netif restart 65.Ed 66.Pp 67.It Sy Scanning for Wi-Fi networks: 68.Bd -literal -offset 2n 69.Ic % ifconfig wlan0 scan 70.Ed 71.It Sy Airplane mode: 72.Bd -literal -offset 2n 73.Ic # service netif stop 74.Ed 75.El 76.Sh SEE ALSO 77.Xr bsdconfig 8 , 78.Xr dhclient 8 , 79.Xr ifconfig 8 , 80.Xr wpa_passphrase 8 81.Pp 82The Advanced Networking chapter of the 83.Fx 84Handbook. 85.Sh CAVEATS 86Shell Special Characters in the 87.Ar SSID 88or 89.Ar passphrase 90will need to be escaped for 91.Xr wpa_passphrase 8 , 92commonly using 93.Ql \e , 94see the manual page for your shell for more details. 95.Pp 96Currently 97.Ql Ic service netif restart 98does not restart routing. 99A common workaround is to issue 100.Ql Ic service netif restart && service routing restart 101instead. 102