Showing posts with label networking. Show all posts
Showing posts with label networking. Show all posts

Sunday, 25 May 2008

Getting a Huawei HSDPA modem working with Ubuntu

Here in the UK, mobile broadband has started to become more prominent in the last few months, with mobile phone providers offering HSDPA modems at rates comparable to landlines. I daresay the same is probably happening elsewhere in the world, so no doubt many users of Ubuntu and Ubuntu-derived distros are thinking about getting one. I actually tried Vodafone's Mobile Broadband myself but was disappointed with the speed I could get (the mobile networks aren't great in rural Norfolk) so I wound up taking it back. However, I'm assured that in other parts of the country it's fast enough to compete with a DSL line.
So, one question many people will want to know is "Will it work with Ubuntu?". It depends on the device. The Huawei E220 is currently being offered by Vodafone, 3 and T-Mobile in the UK, and apparently support for it was added in the 2.6.20 Linux kernel. Therefore it should work out of the box with any Ubuntu version from Feisty Fawn onwards (I think it should also work with the default OS on the Asus Eee as if I remember right that uses the 2.6.21 kernel). Also, this is a USB device so is easy to get working. Overall, this is probably the safest choice.
The one I opted for was the Huawei E620 PCMCIA card. This was somewhat more troublesome. Fortunately, Vodafone have developed the Vodafone Mobile Connect card driver for Linux for this device which will apparently also work for other carriers as long as they are using a compatible device. It's available from this link. Unfortunately, the comments seem to imply that the beta version doesn't yet work well with Hardy, but I can personally vouch for the stable version working well in Gutsy. I'd therefore expect that once the beta reaches a stable version it will work OK, and it may be that one of the older versions works fine in Hardy.
However, this does have a LOT of dependencies, so to get it working with Ubuntu, you'll need an alternative way to access the Internet. If you install the package as normal and use apt-get -f install to resolve the dependencies, it should be nearly ready to go.
If you then start the application from the menu, you'll be prompted to enter the APN, user name and password. For Vodafone in the UK, this forum post gives you the details you need. For those of you outside the UK or connecting via other providers, you'll need to do a bit of Googling to get the correct settings. I also recommend using Open DNS instead of your provider's own DNS servers for better performance.
If you have trouble with the E220, the Vodafone Mobile Connect card driver might also be helpful in respect of that device.
Overall, the Huawei HSDPA modems are surprisingly easy to get working in Linux with just a few Google searches - I was able to get it working fine within a short period of time. So if you're running Ubuntu or a derivative on your laptop and are considering getting mobile broadband, but were concerned about whether it would work OK, then go ahead - these devices are quite Linux-friendly.

Sunday, 2 March 2008

DNS problems

I personally have had problems in the past with domain name server issues when running Linux. Essentially, a domain name server takes the URL (web address) of the site you're looking for, and translates it into a numerical IP (Internet Protocol) address, which is used to actually get to the website. Your computer has to query the domain name server (normally provided by your Internet Service Provider) to discover the IP address of the URL you've given. Without that, it's stumped.

Normally this works fine in Linux. But, a small number of routers (including my own, a D-Link wireless router), don't seem to play well with Linux. The router has its own IP address and when you request data (ie enter a URL or click on a link) the request will reach the router's IP address and will then be forwarded to the ISP's domain name server. For some reason, that doesn't seem to work with these routers, and they fail to forward the request on to the domain name server.

This can be very frustrating, as it means that many applications will not be able to access the Internet. I found that Firefox and apt-get could not access the Internet, but Konqueror could, so I could browse but I couldn't install anything new. This doesn't always happen - it happened with Ubuntu Edgy and also happens with Ubuntu Gutsy, but wasn't present in Ubuntu Feisty, and it very nearly stopped me from using Kubuntu Gutsy at all.

Fortunately, there's a great service which can help with this. Open DNS is a third-party domain name server you can use instead, and also works better and faster than most ISP's DNS service.

You can configure your router to use Open DNS if you want - just follow this link to get full instructions. Or to just configure your Ubuntu machine, here's full instructions:

First, enter the following in a terminal:
sudo network-admin

Please note, this works on Ubuntu and Xubuntu only. Kubuntu users will need to open KnetworkManager (which normally starts up at outset, and is in the system tray on the bottom right by default - look for a picture of a cable if you're connected via Ethernet, a signal strength meter if you're using Wi-Fi, or an unplugged socket if you're not connected to the Internet), and then click on Manual Configuration to open the configuration screen.

Whichever program you're using, you'll see a tab marked "DNS". Click on that, remove the existing domain name servers, and replace them with the following:

  1. 208.67.222.222 as your preferred DNS (or just first in line)
  2. 208.67.220.220 as your alternate DNS (or just second)

That will set Open DNS as your domain name server, so you can now exit the program. To make sure it sticks though, we're going to have to edit a text file. Enter the following in a terminal:
sudo cp /etc/resolv.conf /etc/resolv.conf.auto

This copies a text file into a new name. Now enter the following:
sudo nano /etc/dhcp3/dhclient.conf

That opens the text file /etc/dhcp3/dhclient.conf. Add the following line to the end of the document:
prepend domain-name-servers 208.67.222.222,208.67.220.220;

Then save and exit the document. You will now also have to switch off IPv6, which is easy:
sudo nano /etc/modprobe.d/aliases

Now look for a line that reads as follows:
alias net-pf-10 ipv6

and edit it to this:
alias net-pf-10 off

Now all you need to do is restart your connection. Enter the following:
sudo ifdown eth0

substituting the name of your connection for eth0. Then:
sudo ifup eth0

That should restart your connection. If not, and you still can't get online, try rebooting.

This method is what I used to get online. Apparently it's not an issue with Linux, but with the router's firmware, and some people have reported success in overcoming this issue simply by updating their router's firmware. In addition, I've found that some Ubuntu-based distros, such as Linux Mint, have already taken care of this issue before release. However, you may wish to use your laptop running Ubuntu in a public place such as a cafe where there is free wi-fi, and under those circumstances you can't expect to be able to update the router, so you may need to do this anyway.

It also goes to show that with wireless routers, you get what you pay for - if you're thinking of getting one, don't just opt for the cheapest. I was confronted with the choice between a Belkin and a D-Link, and I opted to save £10 by going for the D-Link. Two weeks later I read an article in a magazine that had a round-up of wireless routers, and they had both of them in there, and it said the D-Link was terrible and to get the Belkin instead as it had a stronger signal and was a lot more reliable. I'm willing to bet it would probably work better with Linux too!

Sunday, 3 February 2008

Using ndiswrapper to get your wireless connection working

Although it may not always seem like it, Linux is actually the best operating system in the world for out-of-the-box functionality for peripherals. The Linux kernel runs on a staggering panoply of hardware, such as:
  • Wristwatches
  • Consumer electronics (the TiVO is the best example of this)
  • Wireless routers (including the BT Home Hub)
  • Servers (Google use it on their servers, as do many other companies)
  • Supercomputers
I even heard recently that a computerised car that won a competition to drive through a mockup of a city without human intervention was running Ubuntu! So when you take that into account, you realise that Linux is very portable. More things "just work" with Linux than any other operating system you care to name.

This is because Linux has drivers for many pieces of hardware built into the kernel. Because manufacturers do not generally provide Linux drivers when you buy hardware, nor do they make them available to download, the developers who create the Linux kernel are responsible for adding these drivers. This means that for a lot of hardware, it's not necessary to install any drivers before using it like you would have to do in Windows. You can just plug it in and see if it works, and if it does, great!


However, it doesn't always work. New hardware will often have no driver support, or poor support. While anything from a year old is usually a fairly safe bet, there's still no guarantee that it will work. Hopefully in future more manufacturers will be willing to provide drivers for Linux, but at present it's still less well-supported than Windows in terms of drivers from manufacturers.


I'd say that wireless Internet connections are one of the things that are worst affected by this. Support for wireless has been poor in the past (although it is steadily improving). Not every device is supported, and of those that are, they often have less functionality or are less reliable than their Windows equivalents. For instance, back when I was using Kubuntu Feisty, there was a driver for my wireless card, but it didn't support WPA encryption, only WEP.


Fortunately, there is a solution. Ndiswrapper is a program that enables you to use the Windows driver for your device within Linux. It's not perfect as it doesn't support all wireless devices and setting it up does take a bit of effort, but it's sometimes the only option to get wireless support working.


First of all you need to get the Windows drivers. I find the best way to do this is to go to the manufacturer's website and look up your wireless card. I use a Belkin F5D7010uk PCMCIA card and so I looked this up on Belkin's UK website. Most manufacturers will have a link where you can download a copy of the driver (fortunately Belkin are pretty good at this and that's one reason why I'd recommend their products if you're planning to use them with Linux), so just search around for it.


It's also a good idea to try searching under the name of the chipset. You can find this using the connection applet for your desktop (Network Manager in Gnome, KNetwork Manager in KDE). Look for the device name (in mine it's RT2561/RT61). This shouldn't be too hard to find, and if the device manufacturer doesn't offer drivers, the chipset manufacturer may do. You'll also want this information later.


If you can't find it, you might be able to get the driver from your installation CD, or if you still have a Windows install on your computer, you might be able to copy the files you need from your Windows installation. If none of these work, try Googling it (when running Linux, Google is your best friend in the whole world!).



Hopefully you should now have a .zip file for your drivers. I'm assuming that you've saved this to your home directory. I recommend that you set up a new folder (call it Driver for ease of reference), and move the .zip file into it. Now, you'll need to extract the files you need, and this is best done from the command line. Open Terminal or Konsole and enter the following:

cd /home/matthew/Driver
Obviously you need to substitute the name of your home directory (this is your user name when you installed). This changes the working folder (or directory to use the correct terminology) to the Driver folder we just set up. Now enter the following:
unzip f5d7010v6drivers.exe
Again, you need to substitute the name of the file you downloaded. This will work with .zip files, as well as most .exe files. If not, you may have to extract them in Windows, using a tool like Universal Extractor to get the files you need.


What you are after is the .sys and .inf files relevant to your wireless device. Sometimes, there may be .bin files as well - if so, you will need these as well, but they don't appear often. You can ignore any other files that appear.



Now, if there's more than one .inf file, you will need to search through them to see which one relates to your device. Look for the PCI ID of the device by going to System>Administration>Device Manager in Ubuntu, or KInfoCenter in Kubuntu. It may be under PCI, or Network Interfaces. In Ubuntu, look for a line that reads net.physical_device. This should show the PCI number. It should be in the format pci_701e1799. I found that in Kubuntu, I could only find the first part (701e) when I looked under PCI in KInfoCenter, but this should be enough. Open the command line and use the cd command to change back into the folder with the drivers:

cd /home/matthew/Driver
Now we'll use the grep command to search the .inf file. Enter the following:
grep "701E" rt61.inf
Substitute the name of your .inf file for rt61.inf and whatever you can get of the PCI ID in the quotes. Don't forget, the command line is case sensitive so if this doesn't work try using lower case instead of upper case. Alternatively, if you have very little to go on, try replacing "701E" with the name of the manufacturer. You should get a list of the lines in the file that include the term "701E". All you need to do is establish which file has the PCI ID of your device, and keep that one. You can get rid of any others.


Now we have the files we need, we can get on with getting them working. First of all, you will need to install ndiswrapper. This isn't generally installed by default, but it may be on the CD you installed from. But the easiest way to get it is to use an Ethernet connection. Just open the command line and enter the following:

apt-cache search ndiswrapper
We're searching for the most recent version of ndiswrapper. In Gutsy, here's the response I got:
matthew@matthew-laptop:~/Driver$ apt-cache search ndiswrapper
linux-ubuntu-modules-2.6.22-14-386 - Ubuntu supplied Linux modules for version 2.6.22 on i386
linux-ubuntu-modules-2.6.22-14-generic - Ubuntu supplied Linux modules for version 2.6.22 on x86/x86_64
linux-ubuntu-modules-2.6.22-14-server - Ubuntu supplied Linux modules for version 2.6.22 on x86/x86_64
ndiswrapper-common - Common scripts required to use the utilities for ndiswrapper
ndiswrapper-utils-1.9 - Userspace utilities for the ndiswrapper linux kernel module
linux-ubuntu-modules-2.6.22-14-rt - Ubuntu supplied Linux modules for version 2.6.22 on x86/x86_64
linux-ubuntu-modules-2.6.22-14-ume - Ubuntu supplied Linux modules for version 2.6.22 on Embedded/Mobile
linux-ubuntu-modules-2.6.22-14-xen - Ubuntu supplied Linux modules for version 2.6.22 on x86
ndisgtk - graphical frontend for ndiswrapper (installation of Windows WiFi drivers)
Here, what we need is ndiswrapper-utils-1.9, which is the most recent version currently available in Ubuntu. So now enter the following:
sudo apt-get install ndiswrapper-utils-1.9
You'll be told that ndiswrapper-common also needs to be installed. As usual, apt-get will download the files and install them.


What happens next depends on why you are using ndiswrapper. If there is no driver for your wireless device at all, you can skip this step. If the existing driver doesn't work well, you'll need to blacklist it first. Enter the following:

sudo nano /etc/modprobe.d/blacklist
Now, at the bottom, type the following on a new line:
blacklist modulename
In my case this is rt61 as my adapter uses the Ralink RT61 chipset. Now save the file (Ctrl-X to save and exit nano), then reboot your system. If all has gone to plan, when it restarts the wireless network device will no longer be visible in Network Manager.


Here's where the people who have no driver at all can rejoin us. You may want to set up a folder specifically for the wireless drivers, rather than have them in your home directory. Enter the following:
cd /dev
sudo mkdir wireless
cd /dev/wireless
This moves you to the /dev folder (where drivers are kept, so is a logical choice for this), creates a new folder called wireless, then changes into it.


Now we change into the directory where the files are kept and copy them to the new folder:
cd /home/matthew/Driver
sudo cp rt61.inf rt61.sys RT619x.sys /dev/wireless
This copies the folders into /dev/wireless. Don't forget, replace what I've put with the names of the .sys and .inf files for your device (plus any .bin files).


Now the time has come to configure ndiswrapper. Change to the directory where you put the files:
cd /dev/wireless
Now enter the following:
sudo ndiswrapper -i rt61.inf
Again, substitute the name of your .inf file (in my case I didn't know which one of the two to try, so I tried the rt.61 and it worked fine).

Now enter the following:

sudo ndiswrapper -m
sudo nano /etc/modules
This opens the modules configuration file. Add a new line at the bottom, and enter the following:
ndiswrapper
Press enter after adding the line, then save and exit. Now reboot your computer. You should now find that the Windows driver is installed and working!


If you have difficulties getting this working, try the Ubuntu Forums. They are very helpful, as wireless problems seem to be fairly common. But if you can't get it working and want to try a different driver, you'll need to remove the one you've installed.

Open the command line and enter the following:
sudo ndiswrapper -l
Look for the first component of the line that is returned (that will be the name of the driver you need to remove). In my case that would be rt61, so now enter the following:
sudo ndiswrapper -e rt61
If you reboot, the ndiswrapper driver will have been removed so you can try another one.


Don't be scared by the length of this post! I found this to be one of the most daunting tasks in using Ubuntu early on, but as of Gutsy there is a driver for my PCMCIA wireless card that supports both WEP and WPA. The chances are that anything over a year old will be supported OK. And once you have done this once it gets easier. The hardest part is finding your chipset and getting the drivers. Believe me, if you can handle this, you're well on the way to being a proficient Linux user!


As an aside, there's also a graphical front-end for ndiswrapper called ndisgtk. I've never tried it, but if you prefer a graphical interface, you may want to try this to configure ndiswrapper rather than using the command line.