Wednesday, January 6, 2010

Setting up an ad-hoc wireless network between 2 Ubuntu machines

You can create an ad-hoc wireless network between 2 linux hosts as shown below. Let us assume that we have two machine A and B both running ubuntu. We will assign 192.168.1.1 to A and 192.168.1.2 to B. I am also assuming that the drivers for the wireless card ( wlan0 here) are loaded already.
Run the following commands:
On machine A.

 ifconfig wlan0 down

iwconfig wlan0 channel 4

iwconfig wlan0 mode ad-hoc

iwconfig wlan0 essid 'fermilevel'

iwconfig wlan0 key 1234567890

ifconfig wlan0 192.168.1.1
On machine B

 ifconfig wlan0 down

iwconfig wlan0 channel 4

iwconfig wlan0 mode ad-hoc

iwconfig wlan0 essid 'fermilevel'

iwconfig wlan0 key 1234567890

ifconfig wlan0 192.168.1.2
Please note that essid and key must be same on both machines. You can change the given values.

4 comments:

dasilah said...

how to share the internet using this setting?

Anonymous said...

Thank you so much ubuntuguru !!!

I tried so many solutions that absolutly did not work. Only your solution WORKED.

MANY MANY THANKS FOR YOUR HELP !!!!

littlebean

Anonymous said...

Hi. I tried working with this. it worked on one system but when i tried it on another system it gave me an error for the mode ad-hoc command:
#iwconfig wlan0 mode ad-hoc

Output:
Error for wireless request "Set Mode" (8B06) :
SET failed on device wlan0 ; Operation not supported

Kindly help me out. I dont understand where im going wrong.

IFA said...

using ubuntu is not so easy for window user but post like this are really helpful

WiFi