Networking on Linux

Sharing an Internet Connection

(See Internet Sharing (Archlinux)

IBSS/ad-hoc

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. All devices talk directly to each other, with no inherent relaying.

  A
 / \
B---C

A can talk to B, B can talk to A and C, C can talk to B, but A and C can not talk directly (without setting up routes):

A---B---C

Command Line ()

To create an ad-hoc network, you first create an ad-hoc interface (in this example named ah0):

iw phy <phyname> interface add <devname> type ibss

Next, you join/create the ibss: iw dev <devname> ibss join <SSID> <freq in MHz> [fixed-freq] [<fixed bssid>] [key d:0:abcde]

Example:

iw phy phy0 interface add ah0 type ibss
ifconfig ah0 up
iw dev ah0 ibss join AdHocNetworkName 2412

Repeat these steps on all devices you want to network together.


To leave an ibss you do: iw dev <devname> ibss leave

Example:

dev ah0 ibss leave

How to Setup an Ad-hoc Network

(From https://www.thinkpenguin.com/gnu-linux/how-setup-ad-hoc-network)

(Tested on Ubuntu 12.04 & Ubuntu 12.10)

  1. Right click on network applet in the top right corner
  2. Open Edit Connections
  3. Click on Wireless tab
  4. Click on Add button
  5. Enter SSID “adhoc_test”
  6. Change mode from infrastructure to Ad-hoc
  7. Click on IPv4 Settings tab
  8. Change the Method from Automatic (DHCP) to Manual
  9. Click Add button
  10. Enter 192.168.1.13 and hit tab
  11. Enter 255.255.255.0 and hit tab
  12. Enter 0.0.0.0
  13. Click the Save button
  14. Hit the Close button
  15. Go to the network applet and click Connect to hidden wireless network
  16. Select the Wireless adapter: 1b75 9170 from the drop down list
  17. From Connection select Wireless connection 1
  18. Click Connect button

Repeat steps for each network- adjust IP as needed to be different for each machine.


To test this is working:

  1. Open a terminal
  2. type ping 192.168.1.xx where xx is another machine that is in the ad-hoc network
  3. Wait 30 seconds and hold ctrl key down and while doing so press C key
  4. You may see dropped packets- it should be less than 100% packet loss in any event, anything less than 100% packet loss indicates a successful connection has been mad to the other machine(s) in the ad-hoc network