Some days ago, I was looking for a quick way to connect two computers with a wireless link but without an access point. This job can be done in two ways:
– setting your wifi device to master mode (making, in fact, your computer like a real access point)
– setting your wifi device to ad-hoc mode (it’s a less scalable and low performance solution – allow wireless devices to communicate with each other in a peer-to-peer fashion)
Using the “master mode” solution will be perfect, but not all wireless drivers support this mode (actually I’m using my D-Link DWL G122 usb dongle and I have no master mode support with my current drivers; well, it’s possible getting the master mode using the next generation drivers, but it’s needed also the kernel >= 2.6.22-rc1 and it’s not my case).
To check if you have the master mode support is easy: of course, you need to have your wifi device already working, then use the iwconfig command to set the master mode: iwconfig wlan0 mode master (replace wlan0 with your wifi device). If you get no errors, probably you are lucky and you have a master mode capable device.
My goal is to bring up a temporary wireless link between the two PC, so using the ad-hoc mode will be fine (…and with my hardware and the short time available, it’s my only solution 🙂 ). Anyway, other bad news are coming: my current open source drivers are not working well in ad-hoc mode: the link is unstable and if I increase the distance between the two PC (more than one meter!!!) the link collapse. Damn!
Also with the Ralink drivers, no way to get a better result. Great! 🙁
My last idea: I will try the ndiswrapper way. Maybe, using the windows drivers, can make my day.
My DWL G122 is revision C1, so to find the correct windows driver I must to go to the D-Link UK web site. After unzipping the downloaded archive I must install the driver into ndiswrapper subsystem.[source: js] [root@linuxbox ~]# ndiswrapper -i Dr71WU.inf
[root@linuxbox ~]# ndiswrapper -l
dr71wu : driver installed
device (07D1:3C03) present (alternate driver: rt73)
This is a temporary solution, so I will keep the open source driver installed. I will not remove any reference to rt73 into /etc/modprobe.conf. I will unload the rt73 module by hand before loading ndiswrapper. In this way, I will not compromise the functionality of this Linux box and, with a reboot, I can restore the previous configuration status.[source: js] /sbin/rmmod rt73
/sbin/ifconfig wmaster0 up
/sbin/ifconfig wmaster0 192.168.111.1 netmask 255.255.255.0
/sbin/iwconfig wmaster0 mode ad-hoc
/sbin/iwconfig wmaster0 key 6572747975
/sbin/iwconfig wmaster0 channel auto
/sbin/iwconfig wmaster0 essid ADHOC
Notes: wmaster0 is my wifi interface, this name can vary, so you must use yours. I have set up a private network with the address 192.168.111.0/24, again, you must use yours (also for the WEP key and the essid, the same rule). I have set up a WEP link: I know it’s not very secure, but it’s easy to implement and remember, this is a temporary link.
The other side of my link was my Mac laptop with the Airport wifi interface. I can found the new wireless network under the Computer-to-Computer Networks section. When prompted for the security key to join, I have entered the WEP key with the $ symbol on beginning ($6572747975 – this is an Mac-only requirement, as I know).
Finally I set up my laptop wireless device with the IP address 192.168.111.2 so I can ping the Linux box from my laptop.
The evolution of this setup, can be sharing the internet connection from the Linux box to the laptop…
– when you are working with devices under Linux, usually, you must be root to do this kind of jobs. Feel free to use a root shell, the su – way or the sudo way. 🙂