Wireless Configuration/Set-up

A wireless networking card is required to use a wireless network, FreeBSD will also need to be configured to the correct wireless network support. The correct module will need to be modified, depending on the type of networking card. The most commonly used wireless devices are those that use parts made by Atheros. These devices are supported by ath(4) and require the following line to be added to /boot/loader.conf:


If unsure about the device, you can identify many common wireless adaptors through the use of the  sysctl(8) net.wlan.devices variable:

% sysctl net.wlan.devices

To load support for a different type of wireless device, specify the module for that device. This example is for devices based on the Intersil Prism parts (wi(4)) driver:


Note: A list of available wireless drivers and supported adapters can be found in the FreeBSD Hardware Notes, available on the Release Information page of the FreeBSD website.

In addition, the modules that implement cryptographic support for the security protocols to use must be loaded. These are intended to be dynamically loaded on demand by the wlan(4) module. To load these modules at boot time, add the following lines to /boot/loader.conf:


Information about the wireless device should appear in the boot messages, like this:

ath0: <Atheros 5212> mem 0x88000000-0x8800ffff irq 11 at device 0.0 on cardbus1
ath0: [ITHREAD]
ath0: AR2413 mac 7.9 RF2413 phy 4.5

Connecting to a Network:

Open Networks

Directly connecting to an unsecure network, while not recommended, is extremely common. It’s also a very simple process on FreeBSD. In this example I’ll beconnecting to the John F Kennedy International Airport’s free WiFi.

Start by finding the name of the network:

ifconfig wlan0 up scan

This will look for available networks and return a list, In this case, we want to connect to the JFK free wifi so we’ll use:

ifconfig wlan0 ssid _Free JFK WiFi

Hopefully you will see that it’s joined, and running ifconfig ath0 will show that it’s associated. You can then get an address with:

dhclient wlan0


Most home/private networks will rely on these security protocols. Connecting a computer to an existing WPA/WPA2/Personal wireless network is a very common situation.

  • Obtain the SSID (Service Set Identifier) and PSK (Pre-Shared Key) from the network administrator, these may also be listed on the router.
  • Add an entry for this network to /etc/wpa_supplicant.conf. If the file does not exist, create it. Replace myssid and mypsk with the SSID and PSK provided by the network administrator.
  • Note: If the wireless network is hidden, add an additional line to indicate that the network is not publicly visible.
  • Add entries to /etc/rc.conf to configure the network on startup. Make sure to use the correct wireless adapter as identified earlier (this example will use the Atheros ath0 wireless adapter).
ifconfig_wlan0="WPA SYNCDHCP"
  • Restart the computer, or restart the network service to connect to the network:
# service netif restart

FreeBSD as an Access Point:

FreeBSD can act as an Access Point (AP) in order to act as a gateway or to eliminate the need to purchase AP hardware. Before an Access Point can be set up, the kernel mu

Before configuring a FreeBSD machine as an AP, the kernel must be configured with the appropriate networking support for the wireless card as well as the security protocols being used. This mode is only supported by native FreeBSD wireless drivers.

After setting up wireless networking, you can check if the device supports host-based access point mode:

# ifconfig wlan0 create wlandev ath0
# ifconfig wlan0 list caps

This output displays the card’s capabilities. The HOSTAP word confirms that this wireless card can act as an AP.

The wireless device can only be put into hostap mode during the creation of the network pseudo-device, so a previously created device must be destroyed first:

# ifconfig wlan0 destroy

then regenerated with the correct option before setting the other parameters:

# ifconfig wlan0 create wlandev ath0 wlanmode hostap
# ifconfig wlan0 inet netmask ssid freebsdap mode 11g channel 1

Use ifconfig(8) again to see the status of the wlan0 interface:

# ifconfig wlan0
  wlan0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
	  ether 00:11:95:c3:0d:ac
	  inet netmask 0xffffff00 broadcast
	  media: IEEE 802.11 Wireless Ethernet autoselect mode 11g <hostap>
	  status: running
	  ssid freebsdap channel 1 (2412 Mhz 11g) bssid 00:11:95:c3:0d:ac
	  country US ecm authmode OPEN privacy OFF txpower 21.5 scanvalid 60
	  protmode CTS wme burst dtimperiod 1 -dfs

The hostap parameter indicates the interface is running in the host-based access point mode.

The interface configuration can be done automatically at boot time by adding the following lines to /etc/rc.conf:

create_args_wlan0="wlanmode hostap"
ifconfig_wlan0="inet netmask ssid freebsdap mode 11g channel 1"

Once the AP is configured, initiate a scan from another wireless machine to find the AP.

USB Tethering

Many cellphones can share data connection over USB, FreeBSD provides support through a variety of protocols:

Before attaching a device, load the appropriate driver into the kernel:

# kldload if_urndis                     # driver generally used by Android™ device
# kldload if_ipheth                     # driver used by Apple® devices
# kldload if_cdce                       # driver often used in older devices

Once the device is attached ue0 will be available for use like a normal network device. Be sure that the “USB tethering” option is enabled on the mobile device.

To make this change permanent and load the driver as a module at boot time, place the appropriate line of the following in /boot/loader.conf:



Loading Bluetooth Support

Before attaching a Bluetooth device, determine which Bluetooth driver it uses. A broad variety of Bluetooth USB dongles are supported by ng_ubt(4). Broadcom BCM2033 based Bluetooth devices are supported by the ubtbcmfw(4) and ng_ubt(4) drivers. The 3Com Bluetooth PC Card 3CRWB60-A is supported by the ng_bt3c(4) driver. Serial and UART based Bluetooth devices are supported by sio(4)ng_h4(4), and hcseriald(8). For example, if the device uses the ng_ubt(4) driver:

# kldload ng_ubt

If the Bluetooth device will be attached to the system during system startup, the system can be configured to load the module at boot time by adding the driver to /boot/loader.conf:


Once the driver is loaded, plug in the USB dongle. If the driver load was successful, output similar to the following should appear on the console and in /var/log/messages:

ubt0: vendor 0x0a12 product 0x0001, rev 1.10/5.25, addr 2
ubt0: Interface 0 endpoints: interrupt=0x81, bulk-in=0x82, bulk-out=0x2
ubt0: Interface 1 (alt.config 5) endpoints: isoc-in=0x83, isoc-out=0x3,
      wMaxPacketSize=49, nframes=6, buffer size=294

To start and stop Bluetooth, use the driver’s startup script.

# service bluetooth start ubt0

Finding Other Bluetooth Devices

FreeBSD uses hccontrol(8) to find and identify Bluetooth devices within RF proximity. The following example shows

One of the most common tasks is discovery of Bluetooth devices within RF proximity. This operation is called inquiry. Inquiry and other HCI related operations are done using hccontrol(8). To display a list of devices that are in range use:e example below shows how to find out which Bluetooth devices are in range. The list of devices should be displayed in a few seconds. Note that a remote device will only answer the inquiry if it is set to discoverable mode.

% hccontrol -n ubt0hci inquiry
Inquiry result, num_responses=1
Inquiry result #0
       BD_ADDR: 00:80:37:29:19:a4
       Page Scan Rep. Mode: 0x1
       Page Scan Period Mode: 00
       Page Scan Mode: 00
       Class: 52:02:04
       Clock offset: 0x78ef
Inquiry complete. Status: No error [00]

Note: only devices that are set to discoverable mode will be listed.

The BD_ADDR is the unique address of a Bluetooth device, similar to the MAC address of a network card. This address is needed for further communication with a device. To to obtain the human readable name that was assigned to the remote device:

% hccontrol -n ubt0hci remote_name_request 00:80:37:29:19:a4
BD_ADDR: 00:80:37:29:19:a4
Name: Pav's T39

The Bluetooth system provides a point-to-point connection between two Bluetooth units, or a point-to-multipoint connection which is shared among several Bluetooth devices. The following example shows how to create a connection to a remote device:

% hccontrol -n ubt0hci create_connection BT_ADDR

create_connection accepts BT_ADDR as well as host aliases in /etc/bluetooth/hosts.

The following example shows how to obtain the list of active baseband connections for the local device:

% hccontrol -n ubt0hci read_connection_list
Remote BD_ADDR    Handle Type Mode Role Encrypt Pending Queue State
00:80:37:29:19:a4     41  ACL    0 MAST    NONE       0     0 OPEN

Bluetooth Device Pairing

While a Bluetooth device can choose to require authentication, communication is normally not authenticated, so any Bluetooth device can talk to any other device. If the device requires authentication, the PIN code must be entered on both devices, the devices will then generate a link key. After that, the link key can be stored either in the devices or in a persistent storage. This procedure is called pairing.

The hcsecd(8) daemon is responsible for handling Bluetooth authentication requests. The default configuration file is /etc/bluetooth/hcsecd.conf. An example section for a cellular phone with the PIN code set to 1234 is shown below:

device {
        bdaddr  00:80:37:29:19:a4;
        name    "iPhone";
        key     nokey;
        pin     "1234";

The only limitation on PIN codes is length. Some devices, such as Bluetooth headsets, may have a fixed PIN code built in. The -d switch forces hcsecd(8) to stay in the foreground, so it is easy to see what is happening. Set the remote device to receive pairing and initiate the Bluetooth connection to the remote device. The remote device should indicate that pairing was accepted and request the PIN code. Enter the same PIN code listed in hcsecd.conf. Now the computer and the remote device are paired.

The following line can be added to /etc/rc.conf to configure hcsecd(8) to start automatically on system start: