Translation(s): English - Français - Italiano


WiFi Ad-hoc Network

This page describes how to establish a decentralized WiFi network.

A wireless ad-hoc network - also known as Independent Basic Service Set (IBSS) - consists of local wireless devices (nodes) discovering each other and forming a network, each able to forward data for other nodes. An access point is not required for managing this communication.

In the following examples, two wireless LAN clients will be configured as ad-hoc network nodes with static IP addressing. Before continuing, install the wireless-tools package.

Debian Method

  1. On each node, open /etc/network/interfaces in a text editor:

    $ su
    # sensible-editor /etc/network/interfaces
  2. Define stanzas for each node's wireless interface, setting the network SSID and the device's operating mode to ad-hoc:

    Node A

    auto wlan0
    iface wlan0 inet static
        address 192.168.1.1
        netmask 255.255.255.0
        wireless-channel 1
        wireless-essid MYNETWORK
        wireless-mode ad-hoc

    Node B

    auto wlan0
    iface wlan0 inet static
        address 192.168.1.2
        netmask 255.255.255.0
        wireless-channel 1
        wireless-essid MYNETWORK
        wireless-mode ad-hoc
  3. Save the file and exit the editor.
  4. Raise the interface on each node:

    # ifup wlan0
  5. Scan for ad-hoc cells in range (necessary for some drivers to trigger IBSS scanning):

    # iwlist wlan0 scan
    wlan0     Scan completed :
              Cell 01 - Address: 02:0F:B5:4F:74:ED
                        ESSID:"MYNETWORK"
                        Mode:Ad-Hoc
                        Frequency:2.412 GHz (Channel 1)
                        Quality=42/70  Signal level=-53 dBm  Noise level=-95 dBm
                        Encryption key:off
                        Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 11 Mb/s; 6 Mb/s
                                  9 Mb/s; 12 Mb/s; 18 Mb/s; 24 Mb/s; 36 Mb/s
                                  48 Mb/s; 54 Mb/s
                        Extra:bcn_int=100
  6. To test, ping node A from node B:

    you@nodeB$ ping 192.168.1.1
    PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data.
    64 bytes from 192.168.1.1: icmp_seq=1 ttl=64 time=0.073 ms
    64 bytes from 192.168.1.1: icmp_seq=2 ttl=64 time=0.061 ms
    64 bytes from 192.168.1.1: icmp_seq=3 ttl=64 time=0.062 ms
    64 bytes from 192.168.1.1: icmp_seq=4 ttl=64 time=0.063 ms
    
    --- 192.168.1.1 ping statistics ---
    4 packets transmitted, 4 received, 0% packet loss, time 3001ms
    rtt min/avg/max/mdev = 0.061/0.064/0.073/0.010 ms

For general /etc/network/interfaces information, see the interfaces(5) man page.

Manual Method

  1. On each node, bring the wireless interface down, change the device's operating mode and SSID, then raise the interface:

    $ su
    # ifconfig wlan0 down
    # iwconfig wlan0 channel 1 essid MYNETWORK mode ad-hoc
    # ifconfig wlan0 up
  2. Scan for ad-hoc cells in range (necessary for some drivers to trigger IBSS scanning):

    iwlist wlan0 scan
    wlan0     Scan completed :
              Cell 01 - Address: 02:0F:B5:4F:74:ED
                        ESSID:"MYNETWORK"
                        Mode:Ad-Hoc
                        Frequency:2.412 GHz (Channel 1)
                        Quality=42/70  Signal level=-53 dBm  Noise level=-95 dBm
                        Encryption key:off
                        Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 11 Mb/s; 6 Mb/s
                                  9 Mb/s; 12 Mb/s; 18 Mb/s; 24 Mb/s; 36 Mb/s
                                  48 Mb/s; 54 Mb/s
                        Extra:bcn_int=100
  3. On each node, assign an IP address to the wireless interface:

    Node A

    # ifconfig wlan0 192.168.1.1 netmask 255.255.255.0

    Node B

    # ifconfig wlan0 192.168.1.2 netmask 255.255.255.0
  4. To test, ping node A from node B:

    you@nodeB$ ping 192.168.1.1
    PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data.
    64 bytes from 192.168.1.1: icmp_seq=1 ttl=64 time=0.073 ms
    64 bytes from 192.168.1.1: icmp_seq=2 ttl=64 time=0.061 ms
    64 bytes from 192.168.1.1: icmp_seq=3 ttl=64 time=0.062 ms
    64 bytes from 192.168.1.1: icmp_seq=4 ttl=64 time=0.063 ms
    
    --- 192.168.1.1 ping statistics ---
    4 packets transmitted, 4 received, 0% packet loss, time 3001ms
    rtt min/avg/max/mdev = 0.061/0.064/0.073/0.010 ms

Troubleshooting

See Also


CategoryNetwork | CategoryWireless