Ad-hoc networking

An IBSS (Independent Basic Service Set) network, often called an ad-hoc network, is a way to have a group of devices talk to each other wirelessly, without a central controller. It is an example of a peer-to-peer network, in which all devices talk directly to each other, with no inherent relaying.

For example, ad-hoc networking may be used to share an internet connection.

Requirements

  • A nl80211 compatible wireless device (e.g. ath9k) on all devices which will connect to the network

Since IBSS network is a peer-to-peer network, the steps necessary to set up the wifi link layer should be the same on all devices.

Tip: It is possible to create complex network topologies, see Linux Wireless documentation for advanced examples.

Manual method

Warning: This method creates unencrypted ad-hoc network. See #wpa_supplicant for method using WPA encryption.

See Wireless network configuration#iw for a better explanation of the following commands. Make sure that iw is installed.

Set the operation mode to ibss:

# iw interface set type ibss

Bring the interface up (an additional step like rfkill unblock wifi might be needed):

# ip link set interface up

Now you can create an ad-hoc network. Replace your_ssid with the name of the network and frequency with the frequency in MHz, depending on which channel you want to use. See the Wikipedia page List of WLAN channels for a table showing frequencies of individual channels.

# iw interface ibss join your_ssid frequency

wpa_supplicant

Ensure that wpa_supplicant is installed, and create a configuration file for it (see wpa_supplicant for details).

Run wpa_supplicant on all devices connected to the network with the following command:

# wpa_supplicant -B -i interface -c /etc/wpa_supplicant-adhoc.conf -D nl80211,wext

Network configuration

The final step is to assign an IP address to all devices in the network. There are multiple ways to do this:

If you want to share an internet connection to the ad-hoc network, see Internet sharing.

Tips and tricks

Using NetworkManager

If you use NetworkManager, you can use nm-applet for ad-hoc network configuration instead of the manual method described above. See NetworkManager#Sharing internet connection over Wi-Fi for details.

Custom systemd service (with wpa_supplicant and static IP)

You can use the following templates to enable wireless ad-hoc networking:

See also

This article is issued from Archlinux. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.