Convert Microsoft to LINUX: Wireless


Wireless has come a long way in the last three years, and it now works great with Linux. If your card does not work out of the box and you are using an Ubuntu distro try doing this first in a terminal window:
sudo apt-get install ndisgtk
Give it your root password and then install all three packages it gives you. These are listed below in detail with their directories, that is the ndiswrapper packages and the ndisgtk package.

If you do not have a connection to the network, you can install the appropriate packages from the ubs "stick", which I labeled stick, i.e. type below at the terminal prompt

fdisk -l
cd /media/stick
ls
find ./ -name ndis*
cd pool/main/n/ndisgtk
dpkg -i ndisgtk_0.8.4-1_i386.deb
cd ../ndiswrapper/
dpkg -i ndiswrapper-common_1.54-2ubuntu1_all.deb
dpkg -i ndiswrapper-utils-1.9_1.54-2ubuntu1_i386.deb

You can then go to:
System | Administration | Windows Wireless Drivers
from the menu bar and browse to the appropriate ".inf" file that comes on the Microsoft Windows CD for your particular wireless card. You can also download this from the manufacturers website. After this you will be able to use the normal network GUI tool to connect to your wireless network. Note all the network drivers will live in a directory of /etc/ndiswrapper/cardname . For example you will have a directory of:
/etc/ndiswrapper/newmw14x/
for the netgear card mentioned in the third example below. It will contain the appropriate .inf and .sys file. If for some reason the GUI interface will not let you load these can you just copy them by hand to this directory.

As one example, here are the two drivers necessary, the lswlnds5.inf and the lswlndsx.sys file for the old linksys Version 4 WPC11V4 card.

As a second example, here are the two drivers necessary, the rt61.inf and the rt61.sys file for the Airlink card.

As a third example, here are the two drivers necessary, the netmw14x.inf and the netmw145.sys file for the netgear wn311t card.

Note, often the drivers will be a .exe file, i.e. SW4321.exe. If you install wine Ubuntu can unpack the executable into the appropriate xxxx.sys and xxxx.inf file. Here is how to install wine:
apt-get install wine
needs to be typed at the terminal prompt. You will then find the file once you save it and expand it with
wine SW4321.exe
in the directory of root@netbook:~/.wine/drive_c#
cd ~/.wine/drive_c to find it when you are logged in as root at the terminal.

Let us consider the example of Linux on a laptop. Some wireless cards are automatically detected and configured upon installation, in which case it is not necessary to do anything. Such a card would show up as either eth0 or wlan0. If it is eth0, the computer does not even know it is wireless and treats it as an ordinary ethernet card. If it shows up as wlan0, it is recognized as a wireless card.

If the card is not automatically detected, it is necessary to first determine what kind of card it is. This is accomplished by going to "Star" (lower left corner) | Administer your system | configure computer | hardware and letting the machine detect the card. When I did this I discovered I had a Motorola Wireless Card, which was detected as an Ethernet Card BCM94306 802.11g NIC. The 802.11g means that it is a wireless card using the "g" protocol.

Next, start a shell (i.e., command line) session by opening a terminal window, and then become the root user by using the su command. The latter is done by typing "su" in the terminal window and then pressing the Enter key, followed by typing the root password and again hitting the Enter key. A # prompt should appear in the terminal window indicating that you are now the root user.

Now type ifconfig. You should see these lines, which means that you have an IP address for wlan0 and thus you are done:
wlan0 Link encap:Ethernet HWaddr 00:69:E5:4F:DC:86
inet addr:192.168.0.5

Otherwise type iwconfig. You should see these lines:
wlan0 IEEE 802.11g ESSID:"ACTIONTEC" Nickname:"linuxlap"
Mode:Managed Frequency:2.412GHz Access Point: 69:0F:C3:91:27:65
Bit Rate=48Mb/s Tx-Power:25 dBm
RTS thr=2347 B Fragment thr=2346 B
Encryption key:off
Power Management:off
Link Quality:100/100

This shows that you have a strong signal 100/100 for link quality, an ID for your connection of "ACTIONTEC" and you are not using encryption. In the real world encryption should be turned on for security, but we are just testing now.

If it is still not working, type
iwlist wlan0 scan
This will give you a little more information. If for some reason it is still not working, then you will have to use the ndiswrapper program. This program will work with any wireless card that has a Microsoft Windows driver. Usually you can open up the CD and find the netcard.inf file (bcmwl5a.inf for Motorola card). It should be in a directory called
/mnt/cdrom/Motorola Utility Installer/Win.
I assume this is where you are still logged in as root in your terminal session. Type
urpmi ndiswrapper (for Mandriva)
apt-get install ndiswrapper-common (for Ubuntu)
For another distro such as Suse or Redhat just make sure you have the appropriate ndiswrapper driver installed.
It will probably answer "already installed," as ndiswrapper is installed by default. Otherwise go ahead ane let it install the ndiswrapper program.
Now type:
cd /mnt/cdrom/Motorola Utility Installer/Win
ndiswrapper -i bcmwl5a.inf
ndiswrapper -m
modprobe wlan0

The first line makes sure we are in the right directory where the appropiate netcard.inf file is on the CD. Note, it is real important that you are on the CD because it installs only one file (bcmwl5a.inf) but it needs to read the other *.sys files on the CD to do its job properly. I discovered this the hard way. The second line tells the ndiswrapper program to install the Microsoft Windows driver. The third line writes information for modprobe . The fourth line adds in all the network configuration information under the /etc directory so that the Linux Kernel can read it. You do not need to know all the details, because it does it for you. Make sure a file called /etc/sysconfig/network-scripts/ifcfg-wlan0 is created. This is the file that on boot creates the device wlan0 which attaches to the ndiswrapper driver. The only thing you may still need to do is click on the Network Connect icon on the right hand side of the toolbar. Select the interface of wlan0 and fill in your ESSID. It defaults to "any," but I always like to put in the actual name (ACTIONTEC) or whatever it is.

Finally, do not forget to put in encryption keys and enable a personal computer firewall. When you are sitting in your favorite Internet cafe there is NO encryption, so anybody can easily spy on you. Go to "Star" | Administer your system | configure your computer | security | firewall. Now uncheck the box that says "Everything (no firewall)." Click on ok. Next choose the appropiate interface for the firewall which is wlan0 . Reboot and you are done!

Final troubleshooting: Type
ndiswrapper -l
You should see >Installed ndis drivers:
bcmwl5a hardware present
If it says not present. Type
modprobe ndiswrapper
At this point the light should go on, on the card. If it does not, type
ifdown wlan0
then wait a few moments and type
ifup wlan0
It should reply with
Determining IP information for wlan0... done.

If you get: Determining IP information for wlan0.. failed.
Then type
iwconfig wlan0 essid any
This will enable polling all available ID ports.
Then type
dhclient
This should hopefully return an IP address for your wlan0 interface.


If you get: configuration for wlan0 not found or
device wlan0 does not exist then type
cd /etc/sysconfig/network-scripts
Download the following file ifcfg-wlan0 and save it. Then type
chmod 775 ./ifcfg-wlan0
This should give the file appropiate permissions and it should run when you boot the machine hopefully showing
interface wlan0 OK
Good luck!!! Wireless does work with a little perseverance.
Here is the contents of ifcfg-wlan0
in the /etc/sysconfig/network-scripts directory.
DEVICE=wlan0
BOOTPROTO=dhcp
ONBOOT=yes
METRIC=10
MII_NOT_SUPPORTED=no
WIRELESS_MODE=Managed
WIRELESS_ESSID=any
NEEDHOSTNAME=yes

Note, this is a starter file, once you use the Network Connect Icon tool and select the appropiate security using WEP key etc. it will write this additional information to the ifcfg-wlan0 file.