Networking on Linux
Sharing an Internet Connection
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)
- Right click on network applet in the top right corner
- Open Edit Connections
- Click on Wireless tab
- Click on Add button
- Enter SSID “adhoc_test”
- Change mode from infrastructure to Ad-hoc
- Click on IPv4 Settings tab
- Change the Method from Automatic (DHCP) to Manual
- Click Add button
- Enter 192.168.1.13 and hit tab
- Enter 255.255.255.0 and hit tab
- Enter 0.0.0.0
- Click the Save button
- Hit the Close button
- Go to the network applet and click Connect to hidden wireless network
- Select the Wireless adapter: 1b75 9170 from the drop down list
- From Connection select Wireless connection 1
- Click Connect button
Repeat steps for each network- adjust IP as needed to be different for each machine.
To test this is working:
- Open a terminal
- type ping 192.168.1.xx where xx is another machine that is in the ad-hoc network
- Wait 30 seconds and hold ctrl key down and while doing so press C key
- 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