Got a new Kindle and no WLAN support on your router?

What’s the motivation? You CAN transfer e-books to the Kindle via USB cable, BUT that leaves a lot to be desired. Browsing the Amazon Kindle store is a very nice feature that I wouldn’t want to miss anymore. There are quite a lot of FREE e-books, mostly older stuff with expired copyrights, that are worth reading. Quite often you can also download free samples of books – a good way to decide if you want to make a purchase or not. The whole process is very streamlined if WiFi is available.

Here’s one way to solve it if you have a linux machine with free USB ports. This is nothing new, but as I’ve just been through all of this, I might as well write it down here. I think the involved tools deserve another mentioning. As there are many (too many?) flavours of linux distributions out there, I won’t give en-detail instruction on every single step. I will only give pointers on what to do.

These are the prerequisites:

You do already have a router (dsl box…) with a running DHCP server on it which you can configure to your needs. Of course you can also run your own DHCP server, but why use 2. That only complicates things.

2ndly you’ll require a USB WLAN stick that supports ‘master’ mode or ‘AP’ mode (like the TP-Link TL-WN722N, Atheros AR9271 chipset, ath9k_htc driver, about 8€, up to 150Mb/s).

3rdly you need a machine with a recent version of some sort of linux that provides: recent version of ‘hostapd’ (does the heavy lifting), the usual network tools (ifconfig, iptables for optional firewall, …) AND last but not least ‘brctl’ (part of ‘bridge-utils’) for creating a bridged network setup!

Caveats:

Using a bridged-setup like this will conflict with using Networkmanager, so you can’t use it.

Steps:

1) Install ‘hostadp’ and ‘bridge-utils’

On debian-ish systems: “aptitude install hostapd bridge-utils”, on openSUSE: “zypper install hostapd bridge-utils”.

2) Configure the DHCP server to hand out an IP to your Kindle.

This will require the MAC address of your Kindle. You can find the latter in one of Kindle’s menus, probably device options or device info. In case of a DSL router, you just add the MAC and a free IP address that is within the range of valid ones and you’re done. If your main PC usually gets e.g. 192.168.1.5, you might use 192.168.1.6 for the Kindle.

3) Create a network bridge ‘br0’ and only add ‘eth0’ to it.

On openSUSE this can be done with YaST (Network Configuration–>Network card–>Add… device-type: bride). ‘br0’ will replace ‘eth0’ as the main network interface of your PC (including DHCP settings, routing, gateway …), you should be able to copy most of the settings over. Make sure to set the IP address of ‘eth0’ to ‘0.0.0.0/32’. If that step was successful your system should have network access as before, but ‘br0’ will be used instead of ‘eth0’. The latter will still be there, but won’t have an IP address assigned to it. The wlan interface should be left alone completely.

Here are the updated config files:

/etc/sysconfig/network/ifcfg-eth0

/etc/sysconfig/network/ifcfg-br0

Running ‘ifconfig’ as root should show something like this:

Running ‘brctl show br0’ should give:

The wlan interface is not part of the bridge, as it is not up and running yet. The access-point daemon will take care of that on its own.

The routing table (run “route -n” as root) should look like this:

This should be identical to what you had before, but with ‘br0’ instead of ‘eth0’ (assuming you had ‘eth0’ before). Again: network access should work as before!

I deliberately won’t talk much about firewall settings here. On openSUSE it works with ‘br0’ for my simple needs. Again you can use YaST to adapt the configuration. Or add ‘br0’ to /etc/sysconfig/SuSEfirewall2 manually. Carefully read the comments in that file. You will probably have to think more about this step if you have a more complicated setup, e.g. bridging enabled for XEN domains and so forth.

4) Configure and start ‘hostapd’

Open hostapd’s configuration files with a text-editor and modify them. Then restart hostapd (e.g. “/etc/init.d/hostapd restart”). These settings worked with my hardware.

/etc/hostapd.conf (main configuration file)

I’ve marked all lines that I had to change. The others were enabled already and may or may not be important.

/etc/hostapd.accept (list of acceptable MAC addresses)

5) Enable the hostapd service automatically

If you need the wireless all the time, this is the best way to go. On openSUSE use YaST to change the runlevel settings. You can also use ‘chkconfig’ on the console (man chkconfig). The integration of ‘systemd’ may or may not be far enough to let you use ‘systemctl’ for that job. This will most likely change in the future.

6) Let a named user (e.g. ‘joe’) enable/disable the access point by hand

If you don’t need the wireless running all the time, you can make it a bit more user-friendly by adding start/stop scripts. Normally these would require root permissions, but thanks to ‘sudo’ this can be remedied.

I put these scripts into /usr/local/bin

wlan-stick_on.sh

wlan-stick_off.sh

Now all is left is to configure sudo to let some user run these scripts with root permission without having to enter a password. This is done with ‘visudo’ as root (of course). You should NOT use a text-editor to edit the file ‘/etc/sudoers’. ‘visudo’ does some sanity checks and warns you if something is not quite right with the config file. You could seriously mess up your system otherwise. This is especially the case for linux distributions that don’t have the root-user enabled per default and use ‘sudo …’ for everything instead. Ubuntu comes to mind… make a backup of the config file(s)!

Run ‘visudo’ as root:

Now the user ‘joe’ can run these scripts and start/stop the wlan access point without having to enter the root password. I like it ;-)

After running ‘wlan-stick_on.sh’ in a console window your Kindle should be able to join the network.

This entry was posted in Computer / Server, Electronics., Software. and tagged , , , , , , , , . Bookmark the permalink.

2 Responses to Got a new Kindle and no WLAN support on your router?

  1. I think you meant to say the TL-WN722N USB dongle? Not the TL-TN722N.

Comments are closed.