‘Server not found’ by browser at launch

I haven’t had any significant Linux problems or new requirements in the last few months, hence no new posts here. My last real problem was back in June 2013 when I rolled my Gentoo installation to latest using Portage and found that, whenever I launched Firefox, it displayed the ‘Server not found’ page and I had to click ‘Try Again’, and then Firefox displayed the expected Web site. From then onwards, Firefox would work as expected until I exited the application. Thunderbird was also unable to access e-mail servers on the first attempt after it was launched. The same thing happened in Sabayon Linux when I rolled to latest using Entropy a couple of days later. Anyway, here is how I fixed the problem in both distributions.

First I used Wireshark to see what was going on, and it transpired that Gentoo (and Sabayon) was sending an IPv4 request followed quickly by an IPv6 request, but the reply to the IPv6 request was being received first and was a ‘server not found’ message since my ISP does not support IPv6 and my router apparently does not handle IPv6 requests correctly. Gentoo (and Sabayon) then used an IPv4 address when I clicked ‘Try Again’ in the browser window, and thereafter Firefox always dispayed the expected Web sites.

I should point out that IPv6 is enabled in the kernels I use and I’ve never before had to disable IPv6 in Firefox (or system-wide) on the affected laptops. So why the change in functionality, I wonder?

With Wireshark capturing packets, when I launched Firefox I was seeing a server failure message indicating “AAAA” (IPv6) instead of “A” (IPv4). To stop this happening I could have chosen any one of the three following solutions:

1. I could have used about:config in Firefox (and Config Editor in Thunderbird) to change the value of network.dns.disableIPv6 to true instead of false.

2. I could have disabled IPv6 system-wide by editing /etc/modprobe.d/aliases.conf and uncommenting the line “alias net-pf-10 off“.

3. I could have forced the getaddrinfo() function in glibc to make the IPv4 and IPv6 requests sequentially rather than in parallel.

Just for the fun of it I chose the third option on a couple of my laptops, and, as they use NetworkManager, this is how I did it:

fitzcarraldo@aspire5536 ~ $ su
Password:
aspire5536 fitzcarraldo # cat /etc/resolv.conf
# Generated by resolvconf
domain home
nameserver 192.168.1.254
aspire5536 fitzcarraldo # cd /etc/NetworkManager/dispatcher.d/
aspire5536 dispatcher.d # touch 06-dhclientoptions
aspire5536 dispatcher.d # nano 06-dhclientoptions
aspire5536 dispatcher.d # cat 06-dhclientoptions
#!/bin/bash
echo "options single-request" >> /etc/resolv.conf
aspire5536 dispatcher.d # chmod +x /etc/NetworkManager/dispatcher.d/06-dhclientoptions
aspire5536 dispatcher.d # # Now I disconnect then reconnect to the network
aspire5536 dispatcher.d # cat /etc/resolv.conf
# Generated by resolvconf
domain home
nameserver 192.168.1.254
options single-request
aspire5536 dispatcher.d #

As you can see above, I added a two-line Bash script 06-dhclientoptions in the directory /etc/NetworkManager/dispatcher.d/ that appends the line “options single-request” (without the quotes) to the contents of the file /etc/resolv.conf. The addition of the line “options single-request” in resolve.conf causes the getaddrinfo() function in glibc to make the IPv4 and IPv6 requests sequentially rather than in parallel. With this change, Firefox and Thunderbird no longer have a problem accessing the Internet the first time they are launched.

From “man 5 resolv.conf” under “options”:

single-request (since glibc 2.10)
sets RES_SNGLKUP in _res.options. By default, glibc performs IPv4 and IPv6 lookups in parallel since version 2.9. Some appliance DNS servers cannot handle these queries properly and make the requests time out. This option disables the behavior and makes glibc perform the IPv6 and IPv4 requests sequentially (at the cost of some slowdown of the resolving process).

single-request-reopen (since glibc 2.9)
The resolver uses the same socket for the A and AAAA requests. Some hardware mistakenly sends back only one reply. When that happens the client system will sit and wait for the second reply. Turning this option on changes this behavior so that if two requests from the same port are not handled correctly it will close the socket and open a new one before sending the second request.

I had to use NetworkManagerDispatcher to add the line “options single-request” to /etc/resolv.conf because NetworkManager overwrites /etc/resolv.conf if you edit it manually.

UPDATE (February 4, 2014): As I have recently seen the line “options single-request” occurring more than once in the file /etc/resolv.conf I now recommend /etc/NetworkManager/dispatcher.d/06-dhclientoptions consists of the following:

#!/bin/bash
if grep -q "options single-request" /etc/resolv.conf; then
    exit
else
    echo "options single-request" >> /etc/resolv.conf
fi

Setting the wireless regulatory domain in Linux on your laptop

I travel internationally and want to make sure that my laptop uses the legal wireless networking frequencies in the country I am visiting. In Linux, CRDA (Central Regulatory Domain Agent) is the udev helper used to communicate between userspace and the kernel, and it enables you to view and alter the wireless regulatory domain your kernel uses. For more information see the Regulatory page on the Linux Wireless Wiki site.

CFG80211 is the Linux wireless LAN (802.11) configuration API. The kernel on my main laptop has the following configuration settings relating to CFG80211:

# cat /usr/src/linux/.config | grep CFG80211
CONFIG_CFG80211=m
# CONFIG_CFG80211_DEVELOPER_WARNINGS is not set
# CONFIG_CFG80211_REG_DEBUG is not set
CONFIG_CFG80211_DEFAULT_PS=y
# CONFIG_CFG80211_DEBUGFS is not set
# CONFIG_CFG80211_INTERNAL_REGDB is not set
CONFIG_CFG80211_WEXT=y

and the cfg80211 module is loaded:

# lsmod | grep cfg80211
cfg80211 145747 3 iwlwifi,mac80211,iwldvm

I have the package crda installed, and I have the following udev rule file /etc/udev/rules.d/regulatory.rules to allow the kernel to communicate with userspace:

KERNEL=="regulatory*", ACTION=="change", SUBSYSTEM=="platform", RUN+="/sbin/crda"

So, how do you check which wireless regulatory domain your kernel is currently using, and switch to another domain if necessary? These tasks are performed using the iw command. You’ll need to install the package iw if it is not already installed.

To see the regulatory domain your laptop is using now, enter the following command as root user:

iw reg get

When I use the above command on my laptop after start-up, I normally see the following:

# iw reg get
country 00:
(2402 - 2472 @ 40), (3, 20)
(2457 - 2482 @ 20), (3, 20), PASSIVE-SCAN, NO-IBSS
(2474 - 2494 @ 20), (3, 20), NO-OFDM, PASSIVE-SCAN, NO-IBSS
(5170 - 5250 @ 40), (3, 20), PASSIVE-SCAN, NO-IBSS
(5735 - 5835 @ 40), (3, 20), PASSIVE-SCAN, NO-IBSS

The country code 00 is not the code of the country I am in at present. To tell the kernel which wireless regulatory domain you wish to use, enter the following command as root user:

iw reg set ISO_3166-1_alpha-2

where ISO_3166-1_alpha-2 is the 2-character code for the country you are in. You can find the list of ISO 3166-1 alpha-2 codes on the Wikipedia page ISO 3166-1 alpha-2.

For example, if I were in the UK then I would enter the following command:

# iw reg set GB

and the regulatory domain would then be reported like this:

# iw reg get
country GB:
(2402 - 2482 @ 40), (N/A, 20)
(5170 - 5250 @ 40), (N/A, 20)
(5250 - 5330 @ 40), (N/A, 20), DFS
(5490 - 5710 @ 40), (N/A, 27), DFS

It is not a big deal to use the command line, but I wanted to make it even easier. I’m using KDE on my main laptop, so I created a Desktop Configuration File /home/fitzcarraldo/Desktop/Set_wireless_regulatory_domain containing the following:

[Desktop Entry]
Comment[en_GB]=
Comment=
Exec=/home/fitzcarraldo/iw_reg.sh
GenericName[en_GB]=Set wireless regulatory domain
GenericName=Set wireless regulatory domain
Icon=/home/fitzcarraldo/national-flags-icon.png
MimeType=
Name[en_GB]=Set_wireless_regulatory_domain
Name=Set_wireless_regulatory_domain
Path=
StartupNotify=true
Terminal=true
TerminalOptions=\s--noclose
Type=Application
X-DBUS-ServiceName=
X-DBUS-StartupType=none
X-KDE-SubstituteUID=false
X-KDE-Username=

and gave it the following file permissions:

# chmod 744 /home/fitzcarraldo/Desktop/Set_wireless_regulatory_domain
# ls -la /home/fitzcarraldo/Desktop/Set_wireless_regulatory_domain
-rwxr--r-- 1 fitzcarraldo users 496 Jan 15 21:53 /home/fitzcarraldo/Desktop/Set_wireless_regulatory_domain

I used a search engine to find a nice PNG icon consisting of several overlapping national flags, and saved it with the file name name national-flags-icon.png in my home directory.

I created a Bash shell script /home/fitzcarraldo/iw_reg.sh containing the following:

#!/bin/bash
echo "First you need to enter the password of your user account..."
sudo echo ""
echo "The ISO 3166-1 alpha-2 codes are listed on Web page https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2"
echo ""
echo "The current wireless regulatory domain is set as: "
echo ""
sudo iw reg get
echo ""
echo -n "Enter the ISO 3166-1 alpha-2 code (upper case) for the country you are in now, and press ENTER: "
read REGULATORYDOMAIN
sudo iw reg set $REGULATORYDOMAIN
echo ""
echo "The current wireless regulatory domain is now set as: "
echo ""
sudo iw reg get
echo ""
echo "All done. You can close this window."

and gave it the following file permissions:

# chmod 744 /home/fitzcarraldo/iw_reg.sh
# ls -la /home/fitzcarraldo/iw_reg.sh
-rwxr--r-- 1 fitzcarraldo users 632 Jan 15 21:33 /home/fitzcarraldo/iw_reg.sh

Now, if I double-click on the icon for Set_wireless_regulatory_domain on my desktop, a Konsole window pops up with a prompt for me to enter my user account password. When I enter my password the window displays the current wireless regulatory domain the kernel is using and prompts me to enter the 2-character code for the regulatory domain I wish to use instead. When I enter the country code the window displays the new regulatory domain, as shown in the sample below.


First you need to enter the password of your user account...
Password:

The ISO 3166-1 alpha-2 codes are listed on Web page https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2

The current wireless regulatory domain is set as:

country SA:
(2402 - 2482 @ 40), (N/A, 20)
(5170 - 5250 @ 20), (3, 23)
(5250 - 5330 @ 20), (3, 23), DFS
(5735 - 5835 @ 20), (3, 30)

Enter the ISO 3166-1 alpha-2 code (upper case) for the country you are in now, and press ENTER: GB

The current wireless regulatory domain is now set as:

country GB:
(2402 - 2482 @ 40), (N/A, 20)
(5170 - 5250 @ 40), (N/A, 20)
(5250 - 5330 @ 40), (N/A, 20), DFS
(5490 - 5710 @ 40), (N/A, 27), DFS

All done. You can close this window.

The task of viewing and changing the regulatory domain after start-up is now very easy for me. The only thing that would be easier than this would be if Linux could detect automatically which country I’m in and set the regulatory domain automatically.

AirDroid, a handy Android app for managing your phone from Linux

AirDroid

In a previous article I explained how I installed and used the Windows application MyPhoneExplorer in WINE to manage the phone book (contacts list) in my HTC Desire mobile phone. Well, today I found out about AirDroid, a clever and useful Android application that can do the same thing, as well as the other tasks that MyPhoneExplorer can do, such as transfer files between my laptop and my phone, typing SMS on the laptop to send from the phone, and so on.

Last week I bought a Samsung Galaxy Note II and I needed to transfer a lot of large PDF files from my laptop to the new phone. Now, with my HTC Desire I could simply connect the phone to my laptop with a USB cable, mount the phone in KDE as a storage device, and drag the files across from one Dolphin file manager window to another. But the Samsung phone uses MTP for file transfers and, when the phone is connected to my laptop with a USB cable I can browse the phone’s file directories in Dolphin, but I cannot copy files from the laptop to the phone. Applications that use MTP for file transfer do exist for Windows and OS X (in fact Samsung provides Kies for this purpose), but my laptop runs Linux. I had not got around to installing the latest version (1.8.4) of MyPhoneExplorer to check if it works with the HTC Desire, let alone with a Samsung phone. So I searched the Web to see if there was a Linux application that uses MTP for general file transfer (i.e. not one of the dedicated music players in Linux that do support MTP for transferring music files only).

And that is how I learned about AirDroid, which allows you to “wirelessly manage your Android from your favourite browser.” The AirDroid Web site and the Android Play Store page for AirDroid explain the features of the application and both have a video showing it in operation.

From the AirDroid Web site:

What is AirDroid?

AirDroid is a fast, free app that lets you wirelessly manage & control your Android devices (phone & tablet) from a web browser. It’s designed with the vision to bridge the gap between your Android device and web browser, on desktop computers or tablet devices, on Windows, Mac/iOS, or Linux.

What can I do with AirDroid?

You can use AirDroid to send/receive SMS (text messages, if supported by the device), install/uninstall apps, transfer files between Android device and computer/tablet, and manage contacts, photos, music, videos, and ringtones, etc., all in a web browser. Install AirDroid on your Android device and open your favorite web browser to experience it yourself.

I immediately used Play Store on my phone to install AirDroid. I launched AirDroid, launched Firefox on my laptop and opened http://web.airdroid.com/, and was able to connect the laptop and phone quickly and easily. I block-selected the eighty files in the Dolphin window that I wanted to copy to the phone and dragged them to the phone’s Download directory window in the Firefox window. One by one the files were copied to the phone, with a little progress bar against each one. However, for some reason a few of the files were not copied so I dragged those across individually after the copying of the others had completed.

AirDroid in Firefox on my laptop

AirDroid in Firefox on my laptop

The above snapshot of my laptop’s screen shows the AirDroid desktop inside the maximised Firefox window. The window with the yellow folder icons inside it is actually an AirDroid window which I opened by clicking on the blue folder named ‘Files’ on the left side of the AirDroid desktop. These windows can be dragged around the AirDroid desktop in the browser window, and can even be resized.

A connection problem, and a solution

When I tried to connect the phone and laptop again later, an error message was displayed in the browser window on the laptop:

Failed to connect. Make sure your device is connected to a same WiFi network.

I was sure that the two devices were on the same WiFi network but, no matter what I tried, I could not get the laptop and phone to connect again. I looked through the AirDroid forums and found a thread indicating that this is a common problem.

Some users who posted in that thread were able to connect after they disabled the firewall on the PC, and others were able to connect by deleting the cookies in the browser. However, I think the fundamental cause of the problem is IPTables in Android Jelly Bean (see this comment). Anyway, taking all these factors into consideration, here is the way I got around the problem when it occurred:

On the laptop

1. Make sure the firewall is disabled.

As I use UFW on my laptop, all I need to do is:

# ufw disable

2. Launch Firefox and delete all cookies.

3. Open http://web.airdroid.com/

On the phone

1. Power down the phone, then power it up again.

2. Disable ‘Mobile data’ so that the phone cannot connect to the Internet via the mobile network, only via WiFi.

3. Enable WiFi.

4. Launch AirDroid.

From then on use AirDroid as usual, i.e. click on ‘Start’ and then either click on the camera icon and point the camera at the QR Code on the AirDroid page in the brower window or type the 6-character passcode displayed on the phone in the passcode box in the browser window and click ‘Login’.

That’s it!

AirDroid is a novel and useful application that now enables me to manage my Android phone from within Linux without needing to use WINE. Nice! :-)

(My thanks to Gentoo Forums user Q-collective in the thread [Workaround] Syncing Galaxy S3: What mediaplayer is capable? for mentioning AirDroid, otherwise I would never have known about it.)

EDIT November 5, 2012: I have used AirDroid on my home network and a public network, both using DHCP, not static IP addresses. I think AirDroid does not work if you use static IP addressing, so if you still run into trouble after following all the steps listed above, also check if you have a static IP address specified in the phone and router, and set them to use dynamic IP addressing instead.

EDIT November 26, 2012: Apparently some people — even those using static IP addresses — can get AirDroid working in their home network simply by rebooting their home router, so that’s something else you could try.

How to install the linux-firmware package in Gentoo

The microcode image (a.k.a. firmware) file for a driver can be installed from the distribution’s package manager. For example, in Gentoo the microcode package for the Intel Wireless WiFi 5100AGN, 5300AGN and 5350AGN controllers is named sys-firmware/iwl5000-ucode. However, microcode files are also available in a single package named sys-kernel/linux-firmware and can be installed using that package instead. However, to me at least, it was not obvious how to do this and the elog output when you merge the linux-firmware package is not particularly helpful:

* If you are only interested in particular firmware files, edit the saved
* configfile and remove those that you do not want.
>>> sys-kernel/linux-firmware-20120816 merged.

In other words, I used to enter the following command to install the microcode for the Intel 5300AGN WiFi controller:

emerge sys-firmware/iwl5000-ucode

and that command installed only the microcode files needed for that WiFi controller, but the following command also installed many other microcode files for hardware that my laptop does not have:

emerge sys-kernel/linux-firmware

You can see below what the above command installs in /lib/firmware/ (/lib64/firmware/ if you have a 64-bit installation) in the case of the package linux-firmware-20120816.

# ls /lib/firmware/
3com bnx2 emi26 iwlwifi-4965-2.ucode LICENCE.broadcom_bcm43xx matrox qlogic s2250_loader.fw usbdux
acenic bnx2x emi62 iwlwifi-5000-1.ucode LICENCE.chelsio_firmware mrvl r128 sb16 usbduxfast_firmware.bin
ACX100_USB.bin bnx2x-e1-4.8.53.0.fw ene-ub6250 iwlwifi-5000-2.ucode LICENCE.ene_firmware mts_cdma.fw radeon slicoss usbdux_firmware.bin
adaptec bnx2x-e1-5.2.13.0.fw ess iwlwifi-5000-5.ucode LICENCE.i2400m mts_edge.fw RADIO0d.BIN STLC2500_R4_00_03.ptc usbduxsigma_firmware.bin
advansys bnx2x-e1-5.2.7.0.fw f2255usb.bin iwlwifi-5150-2.ucode LICENCE.iwlwifi_firmware mts_gsm.fw RADIO11.BIN STLC2500_R4_00_06.ssf v4l-cx231xx-avcore-01.fw
af9005.fw bnx2x-e1h-4.8.53.0.fw GPL-3 iwlwifi-6000-4.ucode LICENCE.Marvell mts_mt9234mu.fw RADIO15.BIN STLC2500_R4_02_02_WLAN.ssf v4l-cx23418-apu.fw
agere_ap_fw.bin bnx2x-e1h-5.2.13.0.fw htc_7010.fw iwlwifi-6000g2a-5.ucode LICENCE.mwl8335 mts_mt9234zba.fw README STLC2500_R4_02_04.ptc v4l-cx23418-cpu.fw
agere_sta_fw.bin bnx2x-e1h-5.2.7.0.fw htc_9271.fw iwlwifi-6000g2a-6.ucode LICENCE.myri10ge_firmware mwl8k rt2561.bin sun v4l-cx23418-dig.fw
ar3k brcm i2400m-fw-usb-1.4.sbcf iwlwifi-6000g2b-5.ucode LICENCE.OLPC myri10ge_ethp_z8e.dat rt2561s.bin sxg v4l-cx23885-avcore-01.fw
ar7010_1_1.fw cis i2400m-fw-usb-1.5.sbcf iwlwifi-6000g2b-6.ucode LICENCE.phanfw myri10ge_eth_z8e.dat rt2661.bin TDA7706_OM_v2.5.1_boot.txt v4l-cx23885-enc.fw
ar7010.fw configure i6050-fw-usb-1.5.sbcf iwlwifi-6050-4.ucode LICENCE.qla2xxx myri10ge_rss_ethp_z8e.dat rt2860.bin TDA7706_OM_v3.0.2_boot.txt v4l-cx25840.fw
ar9170-1.fw cpia2 intelliport2.bin iwlwifi-6050-5.ucode LICENCE.ralink-firmware.txt myri10ge_rss_eth_z8e.dat rt2870.bin tehuti vicam
ar9170-2.fw cxgb3 isci kaweth LICENCE.rtlwifi_firmware.txt myricom rt3070.bin ti_3410.fw vntwusb.fw
ar9271.fw cxgb4 iwlwifi-1000-3.ucode keyspan LICENCE.tda7706-firmware.txt ositech rt3071.bin ti_5052.fw vxge
ath3k-1.fw dabusb iwlwifi-1000-5.ucode keyspan_pda LICENCE.ti-connectivity phanfw.bin rt3090.bin TIACX111.BIN WHENCE
ath6k dsp56k iwlwifi-100-5.ucode korg LICENCE.ueagle-atm4-firmware ql2100_fw.bin rt3290.bin ti-connectivity whiteheat.fw
atmsar11.fw dvb-fe-xc5000-1.6.114.fw iwlwifi-105-6.ucode lbtf_usb.bin LICENCE.via_vt6656 ql2200_fw.bin rt73.bin tigon whiteheat_loader.fw
av7110 dvb-usb-dib0700-1.20.fw iwlwifi-135-6.ucode lgs8g75.fw LICENCE.xc5000 ql2300_fw.bin RTL8192E tlg2300_firmware.bin WLANGEN.BIN
BCM2033-FW.bin dvb-usb-terratec-h5-drxk.fw iwlwifi-2000-6.ucode libertas LICENSE.dib0700 ql2322_fw.bin rtl_nic tr_smctr.bin yam
BCM2033-MD.hex e100 iwlwifi-2030-6.ucode LICENCE.agere LICENSE.radeon ql2400_fw.bin rtlwifi ttusb-budget yamaha
BCM-LEGAL.txt edgeport iwlwifi-3945-2.ucode LICENCE.atheros_firmware Makefile ql2500_fw.bin s2250.fw ueagle-atm zd1211

But I only need the files iwlwifi-5000-*.ucode, not all those other microcode files, so here is what I do:

# emerge linux-firmware
# cp /etc/portage/savedconfig/sys-kernel/linux-firmware-20120816 /home/fitzcarraldo/linux-firmware-20120816.bak
# awk '{ printf "#"; print }' /home/fitzcarraldo/linux-firmware-20120816.bak > /etc/portage/savedconfig/sys-kernel/linux-firmware-20120816
# nano /etc/portage/savedconfig/sys-kernel/linux-firmware-20120816 # Remove the comment symbol from the files I want to install.
# cp /etc/portage/savedconfig/sys-kernel/linux-firmware-20120816 /home/fitzcarraldo/linux-firmware-20120816 # I like to keep a backup of the edited file too.
# USE="savedconfig" emerge linux-firmware

Of course you can add the savedconfig USE flag in /etc/portage/package.use instead, so that you do not have to type USE=”savedconfig” every time:

# echo "sys-kernel/linux-firmware savedconfig" >> /etc/portage/package.use

For example, I edited /etc/portage/savedconfig/sys-kernel/linux-firmware-20120816 so that the lines are commented out for firmware my laptop does not need. I could have deleted the unwanted lines instead, but I preferred to comment out unwanted lines in case I made a mistake. The file now looks like this:

# Remove files that shall not be installed from this list.
#3com/typhoon.bin
#3com/3C359.bin
#acenic/tg1.bin
#acenic/tg2.bin
#adaptec/starfire_rx.bin
#adaptec/starfire_tx.bin
#advansys/3550.bin
#advansys/38C1600.bin
#advansys/38C0800.bin
#advansys/mcode.bin
#agere_ap_fw.bin
#agere_sta_fw.bin
#ar3k/ramps_0x01020201_26.dfu
#ar3k/ramps_0x01020200_40.dfu
#ar3k/AthrBT_0x11020000.dfu
#ar3k/1020201/RamPatch.txt
#ar3k/1020201/PS_ASIC.pst
#ar3k/1020200/RamPatch.txt
#ar3k/1020200/ar3kbdaddr.pst
#ar3k/1020200/PS_ASIC.pst
#ar3k/ramps_0x11020000_40.dfu
#ar3k/AthrBT_0x01020201.dfu
#ar3k/30101/RamPatch.txt
#ar3k/30101/ar3kbdaddr.pst
#ar3k/30101/PS_ASIC.pst
#ar3k/30000/RamPatch.txt
#ar3k/30000/ar3kbdaddr.pst
#ar3k/30000/PS_ASIC.pst
#ar3k/30101coex/PS_ASIC_aclHighPri.pst
#ar3k/30101coex/PS_ASIC_aclLowPri.pst
#ar3k/30101coex/RamPatch.txt
#ar3k/30101coex/ar3kbdaddr.pst
#ar3k/30101coex/PS_ASIC.pst
#ar3k/ramps_0x01020001_26.dfu
#ar3k/AthrBT_0x31010000.dfu
#ar3k/AthrBT_0x01020001.dfu
#ar3k/ramps_0x01020201_40.dfu
#ar3k/ramps_0x01020200_26.dfu
#ar3k/AthrBT_0x01020200.dfu
#ar3k/ramps_0x31010000_40.dfu
#ar7010_1_1.fw
#ar7010.fw
#ar9170-1.fw
#ar9170-2.fw
#ar9271.fw
#ath3k-1.fw
#ath6k/AR6002/athwlan.bin.z77
#ath6k/AR6002/eeprom.bin
#ath6k/AR6002/data.patch.hw2_0.bin
#ath6k/AR6002/eeprom.data
#ath6k/AR6004/hw1.2/bdata.bin
#ath6k/AR6004/hw1.2/fw-2.bin
#ath6k/AR6003.1/hw2.1.1/athwlan.bin
#ath6k/AR6003.1/hw2.1.1/bdata.SD31.bin
#ath6k/AR6003.1/hw2.1.1/data.patch.bin
#ath6k/AR6003.1/hw2.1.1/bdata.WB31.bin
#ath6k/AR6003.1/hw2.1.1/endpointping.bin
#ath6k/AR6003.1/hw2.1.1/otp.bin
#ath6k/AR6003.1/hw2.1.1/bdata.SD32.bin
#ath6k/AR6003/hw1.0/athwlan.bin.z77
#ath6k/AR6003/hw1.0/otp.bin.z77
#ath6k/AR6003/hw1.0/bdata.SD31.bin
#ath6k/AR6003/hw1.0/data.patch.bin
#ath6k/AR6003/hw1.0/bdata.WB31.bin
#ath6k/AR6003/hw1.0/bdata.SD32.bin
#ath6k/AR6003/hw2.0/athwlan.bin.z77
#ath6k/AR6003/hw2.0/otp.bin.z77
#ath6k/AR6003/hw2.0/bdata.SD31.bin
#ath6k/AR6003/hw2.0/data.patch.bin
#ath6k/AR6003/hw2.0/bdata.WB31.bin
#ath6k/AR6003/hw2.0/bdata.SD32.bin
#ath6k/AR6003/hw2.1.1/athwlan.bin
#ath6k/AR6003/hw2.1.1/bdata.SD31.bin
#ath6k/AR6003/hw2.1.1/fw-3.bin
#ath6k/AR6003/hw2.1.1/data.patch.bin
#ath6k/AR6003/hw2.1.1/bdata.WB31.bin
#ath6k/AR6003/hw2.1.1/endpointping.bin
#ath6k/AR6003/hw2.1.1/otp.bin
#ath6k/AR6003/hw2.1.1/fw-2.bin
#ath6k/AR6003/hw2.1.1/bdata.SD32.bin
#atmsar11.fw
#av7110/Boot.S
#av7110/bootcode.bin
#av7110/Makefile
#bnx2/bnx2-rv2p-06-6.0.15.fw
#bnx2/bnx2-rv2p-09-6.0.17.fw
#bnx2/bnx2-rv2p-06-4.6.16.fw
#bnx2/bnx2-rv2p-09-5.0.0.j3.fw
#bnx2/bnx2-rv2p-06-5.0.0.j3.fw
#bnx2/bnx2-mips-09-5.0.0.j15.fw
#bnx2/bnx2-rv2p-09-4.6.15.fw
#bnx2/bnx2-rv2p-09ax-6.0.17.fw
#bnx2/bnx2-mips-06-5.0.0.j3.fw
#bnx2/bnx2-mips-06-6.2.3.fw
#bnx2/bnx2-mips-09-5.0.0.j9.fw
#bnx2/bnx2-rv2p-09-5.0.0.j10.fw
#bnx2/bnx2-mips-09-6.2.1b.fw
#bnx2/bnx2-rv2p-09ax-5.0.0.j3.fw
#bnx2/bnx2-mips-06-6.0.15.fw
#bnx2/bnx2-mips-09-6.2.1.fw
#bnx2/bnx2-mips-09-5.0.0.j3.fw
#bnx2/bnx2-rv2p-09ax-5.0.0.j10.fw
#bnx2/bnx2-mips-06-5.0.0.j6.fw
#bnx2/bnx2-mips-06-4.6.16.fw
#bnx2/bnx2-mips-06-6.2.1.fw
#bnx2/bnx2-mips-09-6.2.1a.fw
#bnx2/bnx2-mips-09-4.6.17.fw
#bnx2/bnx2-mips-09-6.0.17.fw
#bnx2x/bnx2x-e1h-6.2.5.0.fw
#bnx2x/bnx2x-e1-7.2.16.0.fw
#bnx2x/bnx2x-e1h-6.2.9.0.fw
#bnx2x/bnx2x-e2-6.2.5.0.fw
#bnx2x/bnx2x-e2-6.0.34.0.fw
#bnx2x/bnx2x-e2-6.2.9.0.fw
#bnx2x/bnx2x-e1-7.0.23.0.fw
#bnx2x/bnx2x-e1-6.2.9.0.fw
#bnx2x/bnx2x-e1-7.2.51.0.fw
#bnx2x/bnx2x-e1h-7.0.23.0.fw
#bnx2x/bnx2x-e1h-6.0.34.0.fw
#bnx2x/bnx2x-e2-7.0.29.0.fw
#bnx2x/bnx2x-e1h-7.2.51.0.fw
#bnx2x/bnx2x-e1h-7.0.29.0.fw
#bnx2x/bnx2x-e1h-7.2.16.0.fw
#bnx2x/bnx2x-e1-6.2.5.0.fw
#bnx2x/bnx2x-e2-7.0.20.0.fw
#bnx2x/bnx2x-e1-6.0.34.0.fw
#bnx2x/bnx2x-e1-7.0.29.0.fw
#bnx2x/bnx2x-e2-7.2.51.0.fw
#bnx2x/bnx2x-e2-7.0.23.0.fw
#bnx2x/bnx2x-e2-7.2.16.0.fw
#bnx2x/bnx2x-e1h-7.0.20.0.fw
#bnx2x/bnx2x-e1-7.0.20.0.fw
#bnx2x-e1-4.8.53.0.fw
#bnx2x-e1-5.2.13.0.fw
#bnx2x-e1-5.2.7.0.fw
#bnx2x-e1h-4.8.53.0.fw
#bnx2x-e1h-5.2.13.0.fw
#bnx2x-e1h-5.2.7.0.fw
#brcm/bcm43xx-0.fw
#brcm/brcmfmac4329.bin
#brcm/brcmfmac43236b.bin
#brcm/brcmfmac4330.bin
#brcm/brcmfmac4334.bin
#brcm/bcm4329-fullmac-4.bin
#brcm/bcm43xx_hdr-0.fw
#cis/MT5634ZLX.cis
#cis/SW_555_SER.cis
#cis/COMpad2.cis
#cis/SW_7xx_SER.cis
#cis/NE2K.cis
#cis/src/MT5634ZLX.cis
#cis/src/COMpad2.cis
#cis/src/NE2K.cis
#cis/src/DP83903.cis
#cis/src/RS-COM-2P.cis
#cis/src/LA-PCM.cis
#cis/src/COMpad4.cis
#cis/src/PE-200.cis
#cis/src/tamarack.cis
#cis/src/3CCFEM556.cis
#cis/src/PCMLM28.cis
#cis/src/3CXEM556.cis
#cis/src/PE520.cis
#cis/DP83903.cis
#cis/RS-COM-2P.cis
#cis/LA-PCM.cis
#cis/SW_8xx_SER.cis
#cis/COMpad4.cis
#cis/PE-200.cis
#cis/tamarack.cis
#cis/3CCFEM556.cis
#cis/Makefile
#cis/PCMLM28.cis
#cis/3CXEM556.cis
#cis/PE520.cis
configure
#cpia2/stv0672_vp4.bin
#cxgb3/t3b_psram-1.1.0.bin
#cxgb3/ael2005_twx_edc.bin
#cxgb3/t3fw-7.4.0.bin
#cxgb3/t3fw-7.1.0.bin
#cxgb3/t3c_psram-1.1.0.bin
#cxgb3/t3fw-7.12.0.bin
#cxgb3/t3fw-7.10.0.bin
#cxgb3/ael2020_twx_edc.bin
#cxgb3/t3fw-7.0.0.bin
#cxgb3/ael2005_opt_edc.bin
#cxgb4/t4fw.bin
#cxgb4/t4fw-1.4.23.0.bin
#dabusb/bitstream.bin
#dabusb/firmware.fw
#dsp56k/bootstrap.bin
#dsp56k/concat-bootstrap.pl
#dsp56k/bootstrap.asm
#dsp56k/Makefile
#dvb-fe-xc5000-1.6.114.fw
#dvb-usb-dib0700-1.20.fw
#dvb-usb-terratec-h5-drxk.fw
#e100/d101m_ucode.bin
#e100/d102e_ucode.bin
#e100/d101s_ucode.bin
#edgeport/boot.fw
#edgeport/down.fw
#edgeport/down2.fw
#edgeport/down3.bin
#edgeport/boot2.fw
#emi26/bitstream.fw
#emi26/loader.fw
#emi26/firmware.fw
#emi62/bitstream.fw
#emi62/loader.fw
#emi62/spdif.fw
#emi62/midi.fw
#ene-ub6250/msp_rdwr.bin
#ene-ub6250/sd_init1.bin
#ene-ub6250/sd_init2.bin
#ene-ub6250/ms_init.bin
#ene-ub6250/ms_rdwr.bin
#ene-ub6250/sd_rdwr.bin
#ess/maestro3_assp_minisrc.fw
#ess/maestro3_assp_kernel.fw
#f2255usb.bin
GPL-3
#htc_7010.fw
#htc_9271.fw
#i2400m-fw-usb-1.4.sbcf
#i2400m-fw-usb-1.5.sbcf
#i6050-fw-usb-1.5.sbcf
#intelliport2.bin
#isci/create_fw.c
#isci/README
#isci/probe_roms.h
#isci/isci_firmware.bin
#isci/create_fw.h
#isci/Makefile
#iwlwifi-1000-3.ucode
#iwlwifi-1000-5.ucode
#iwlwifi-100-5.ucode
#iwlwifi-105-6.ucode
#iwlwifi-135-6.ucode
#iwlwifi-2000-6.ucode
#iwlwifi-2030-6.ucode
#iwlwifi-3945-2.ucode
#iwlwifi-4965-2.ucode
iwlwifi-5000-1.ucode
iwlwifi-5000-2.ucode
iwlwifi-5000-5.ucode
#iwlwifi-5150-2.ucode
#iwlwifi-6000-4.ucode
#iwlwifi-6000g2a-5.ucode
#iwlwifi-6000g2a-6.ucode
#iwlwifi-6000g2b-5.ucode
#iwlwifi-6000g2b-6.ucode
#iwlwifi-6050-4.ucode
#iwlwifi-6050-5.ucode
#kaweth/trigger_code_fix.bin
#kaweth/new_code.bin
#kaweth/new_code_fix.bin
#kaweth/trigger_code.bin
#keyspan/usa19qi.fw
#keyspan/usa28xb.fw
#keyspan/usa28x.fw
#keyspan/usa49wlc.fw
#keyspan/usa49w.fw
#keyspan/usa19w.fw
#keyspan/usa28xa.fw
#keyspan/usa28.fw
#keyspan/usa19qw.fw
#keyspan/mpr.fw
#keyspan/usa18x.fw
#keyspan/usa19.fw
#keyspan_pda/keyspan_pda.S
#keyspan_pda/xircom_pgs.S
#keyspan_pda/keyspan_pda.fw
#keyspan_pda/xircom_pgs.fw
#keyspan_pda/Makefile
#korg/k1212.dsp
#lbtf_usb.bin
#lgs8g75.fw
#libertas/gspi8682.bin
#libertas/sd8682_helper.bin
#libertas/gspi8688_helper.bin
#libertas/gspi8686_v9.bin
#libertas/cf8385_helper.bin
#libertas/usb8682.bin
#libertas/cf8381_helper.bin
#libertas/usb8388_v9.bin
#libertas/sd8686_v8.bin
#libertas/sd8385_helper.bin
#libertas/sd8686_v9.bin
#libertas/sd8686_v9_helper.bin
#libertas/cf8381.bin
#libertas/gspi8686_v9_helper.bin
#libertas/usb8388_v5.bin
#libertas/gspi8682_helper.bin
#libertas/lbtf_sdio.bin
#libertas/gspi8688.bin
#libertas/sd8385.bin
#libertas/sd8682.bin
#libertas/usb8388_olpc.bin
#libertas/sd8688.bin
#libertas/sd8688_helper.bin
#libertas/sd8686_v8_helper.bin
#libertas/cf8385.bin
#LICENCE.agere
#LICENCE.atheros_firmware
#LICENCE.broadcom_bcm43xx
#LICENCE.chelsio_firmware
#LICENCE.ene_firmware
#LICENCE.i2400m
LICENCE.iwlwifi_firmware
#LICENCE.Marvell
#LICENCE.mwl8335
#LICENCE.myri10ge_firmware
#LICENCE.OLPC
#LICENCE.phanfw
#LICENCE.qla2xxx
#LICENCE.ralink-firmware.txt
#LICENCE.rtlwifi_firmware.txt
#LICENCE.tda7706-firmware.txt
#LICENCE.ti-connectivity
#LICENCE.ueagle-atm4-firmware
#LICENCE.via_vt6656
#LICENCE.xc5000
#LICENSE.dib0700
LICENSE.radeon
Makefile
#matrox/g400_warp.fw
#matrox/g200_warp.fw
#mrvl/sd8787_uapsta.bin
#mts_cdma.fw
#mts_edge.fw
#mts_gsm.fw
#mts_mt9234mu.fw
#mts_mt9234zba.fw
#mwl8k/fmimage_8366.fw
#mwl8k/helper_8366.fw
#mwl8k/fmimage_8366_ap-2.fw
#mwl8k/fmimage_8366_ap-1.fw
#mwl8k/fmimage_8687.fw
#mwl8k/helper_8687.fw
#myri10ge_ethp_z8e.dat
#myri10ge_eth_z8e.dat
#myri10ge_rss_ethp_z8e.dat
#myri10ge_rss_eth_z8e.dat
#myricom/lanai.bin
#ositech/Xilinx7OD.bin
#phanfw.bin
#ql2100_fw.bin
#ql2200_fw.bin
#ql2300_fw.bin
#ql2322_fw.bin
#ql2400_fw.bin
#ql2500_fw.bin
#qlogic/12160.bin
#qlogic/isp1000.bin
#qlogic/sd7220.fw
#qlogic/1280.bin
#qlogic/1040.bin
#r128/r128_cce.bin
#radeon/R600_pfp.bin
#radeon/RV770_pfp.bin
#radeon/RS780_me.bin
#radeon/CEDAR_me.bin
#radeon/TURKS_me.bin
#radeon/R600_me.bin
#radeon/RS600_cp.bin
#radeon/SUMO_me.bin
#radeon/CAYMAN_pfp.bin
#radeon/CYPRESS_me.bin
#radeon/CAICOS_pfp.bin
#radeon/R520_cp.bin
#radeon/VERDE_ce.bin
#radeon/RV630_me.bin
#radeon/R700_rlc.bin
#radeon/RV610_pfp.bin
#radeon/JUNIPER_me.bin
#radeon/RV710_pfp.bin
#radeon/RS690_cp.bin
#radeon/CYPRESS_pfp.bin
#radeon/SUMO2_me.bin
#radeon/VERDE_mc.bin
#radeon/BARTS_mc.bin
#radeon/CAICOS_mc.bin
#radeon/ARUBA_pfp.bin
#radeon/RV635_pfp.bin
#radeon/R420_cp.bin
#radeon/R600_rlc.bin
#radeon/RV630_pfp.bin
#radeon/RV635_me.bin
#radeon/PITCAIRN_ce.bin
#radeon/RV730_pfp.bin
radeon/REDWOOD_me.bin
#radeon/PALM_me.bin
#radeon/BTC_rlc.bin
#radeon/BARTS_pfp.bin
#radeon/SUMO_rlc.bin
radeon/REDWOOD_rlc.bin
#radeon/JUNIPER_rlc.bin
#radeon/R100_cp.bin
#radeon/VERDE_pfp.bin
#radeon/RV610_me.bin
#radeon/TAHITI_mc.bin
#radeon/CAYMAN_mc.bin
#radeon/RS780_pfp.bin
#radeon/VERDE_rlc.bin
radeon/REDWOOD_pfp.bin
#radeon/TAHITI_pfp.bin
#radeon/RV670_me.bin
#radeon/RV770_me.bin
#radeon/RV730_me.bin
#radeon/PITCAIRN_mc.bin
#radeon/CEDAR_pfp.bin
#radeon/CAICOS_me.bin
#radeon/BARTS_me.bin
#radeon/CYPRESS_rlc.bin
#radeon/TAHITI_ce.bin
#radeon/CAYMAN_rlc.bin
#radeon/CAYMAN_me.bin
#radeon/ARUBA_rlc.bin
#radeon/PALM_pfp.bin
#radeon/ARUBA_me.bin
#radeon/RV710_me.bin
#radeon/RV620_pfp.bin
#radeon/VERDE_me.bin
#radeon/TAHITI_rlc.bin
#radeon/RV670_pfp.bin
#radeon/TURKS_mc.bin
#radeon/TURKS_pfp.bin
#radeon/TAHITI_me.bin
#radeon/PITCAIRN_me.bin
#radeon/RV620_me.bin
#radeon/PITCAIRN_pfp.bin
#radeon/JUNIPER_pfp.bin
#radeon/SUMO_pfp.bin
#radeon/R300_cp.bin
#radeon/PITCAIRN_rlc.bin
#radeon/R200_cp.bin
#radeon/CEDAR_rlc.bin
#radeon/SUMO2_pfp.bin
README
#rt2561.bin
#rt2561s.bin
#rt2661.bin
#rt2860.bin
#rt2870.bin
#rt3070.bin
#rt3071.bin
#rt3090.bin
#rt3290.bin
#rt73.bin
#RTL8192E/data.img
#RTL8192E/main.img
#RTL8192E/boot.img
#rtl_nic/rtl8105e-1.fw
#rtl_nic/rtl8168e-2.fw
#rtl_nic/rtl8168f-2.fw
#rtl_nic/rtl8168e-1.fw
#rtl_nic/rtl8411-1.fw
#rtl_nic/rtl8168d-2.fw
#rtl_nic/rtl8168g-1.fw
#rtl_nic/rtl8168f-1.fw
#rtl_nic/rtl8168e-3.fw
#rtl_nic/rtl8168d-1.fw
#rtl_nic/rtl8106e-1.fw
#rtl_nic/rtl8402-1.fw
#rtlwifi/rtl8192cufw.bin
#rtlwifi/rtl8192sefw.bin
#rtlwifi/rtl8192cfw.bin
#rtlwifi/rtl8192defw.bin
#rtlwifi/rtl8712u.bin
#rtlwifi/rtl8192cfwU_B.bin
#rtlwifi/rtl8192cfwU.bin
#s2250.fw
#s2250_loader.fw
#sb16/ima_adpcm_capture.csp
#sb16/alaw_main.csp
#sb16/ima_adpcm_init.csp
#sb16/ima_adpcm_playback.csp
#sb16/mulaw_main.csp
#slicoss/oasisdbgdownload.sys
#slicoss/gbrcvucode.sys
#slicoss/oasisdownload.sys
#slicoss/oasisrcvucode.sys
#slicoss/gbdownload.sys
#sun/cassini.bin
#sxg/saharadbgdownloadB.sys
#sxg/saharadownloadB.sys
#TDA7706_OM_v2.5.1_boot.txt
#TDA7706_OM_v3.0.2_boot.txt
#tehuti/bdx.bin
#ti_3410.fw
#ti_5052.fw
#ti-connectivity/wl128x-fw-ap.bin
#ti-connectivity/wl1271-fw-ap.bin
#ti-connectivity/wl128x-fw-4-mr.bin
#ti-connectivity/wl128x-fw-4-sr.bin
#ti-connectivity/wl127x-fw-5-sr.bin
#ti-connectivity/wl128x-nvs.bin
#ti-connectivity/wl127x-fw-3.bin
#ti-connectivity/wl1271-nvs.bin
#ti-connectivity/wl127x-fw-5-plt.bin
#ti-connectivity/wl1271-fw-2.bin
#ti-connectivity/wl1271-fw.bin
#ti-connectivity/wl128x-fw-5-sr.bin
#ti-connectivity/wl128x-fw.bin
#ti-connectivity/wl127x-fw-plt-3.bin
#ti-connectivity/wl127x-nvs.bin
#ti-connectivity/wl12xx-nvs.bin
#ti-connectivity/wl128x-fw-4-plt.bin
#ti-connectivity/wl128x-fw-5-plt.bin
#ti-connectivity/wl127x-fw-4-plt.bin
#ti-connectivity/wl127x-fw-5-mr.bin
#ti-connectivity/wl128x-fw-3.bin
#ti-connectivity/TIInit_7.2.31.bts
#ti-connectivity/wl128x-fw-5-mr.bin
#ti-connectivity/wl127x-fw-4-mr.bin
#ti-connectivity/wl128x-fw-plt-3.bin
#ti-connectivity/wl18xx-fw.bin
#ti-connectivity/wl127x-fw-4-sr.bin
#tigon/tg3_tso5.bin
#tigon/tg3.bin
#tigon/tg3_tso.bin
#tlg2300_firmware.bin
#tr_smctr.bin
#ttusb-budget/dspbootcode.bin
#ueagle-atm/eagleIII.fw
#ueagle-atm/CMVep.bin
#ueagle-atm/DSPei.bin
#ueagle-atm/CMVepFR04.bin
#ueagle-atm/eagleI.fw
#ueagle-atm/930-fpga.bin
#ueagle-atm/CMV4p.bin.v2
#ueagle-atm/CMV9p.bin
#ueagle-atm/CMVepES03.bin
#ueagle-atm/CMVepIT.bin
#ueagle-atm/eagleII.fw
#ueagle-atm/CMVepFR.bin
#ueagle-atm/eagleIV.fw
#ueagle-atm/CMVepWO.bin
#ueagle-atm/CMVepFR10.bin
#ueagle-atm/CMVepES.bin
#ueagle-atm/CMVeiWO.bin
#ueagle-atm/CMVei.bin
#ueagle-atm/adi930.fw
#ueagle-atm/CMV9i.bin
#ueagle-atm/DSPep.bin
#ueagle-atm/DSP4p.bin
#ueagle-atm/DSP9i.bin
#ueagle-atm/DSP9p.bin
#usbdux/fx2-include.asm
#usbdux/Makefile_dux
#usbdux/usbduxsigma_firmware.asm
#usbdux/README.dux
#usbdux/usbduxfast_firmware.asm
#usbdux/usbdux_firmware.asm
#usbduxfast_firmware.bin
#usbdux_firmware.bin
#usbduxsigma_firmware.bin
#v4l-cx231xx-avcore-01.fw
#v4l-cx23418-apu.fw
#v4l-cx23418-cpu.fw
#v4l-cx23418-dig.fw
#v4l-cx23885-avcore-01.fw
#v4l-cx23885-enc.fw
#v4l-cx25840.fw
#vicam/firmware.fw
#vntwusb.fw
#vxge/X3fw.ncf
#vxge/X3fw-pxe.ncf
WHENCE
#whiteheat.fw
#whiteheat_loader.fw
#yam/9600.bin
#yam/1200.bin
#yamaha/yss225_registers.bin
#yamaha/ds1_ctrl.fw
#yamaha/ds1_dsp.fw
#yamaha/ds1e_ctrl.fw

and the resulting files in /lib64/firmware/ after re-merging linux-firmware are now:

# ls /lib/firmware/
ACX100_USB.bin BCM2033-FW.bin BCM-LEGAL.txt GPL-3 iwlwifi-5000-2.ucode LICENCE.iwlwifi_firmware Makefile RADIO0d.BIN RADIO15.BIN STLC2500_R4_00_03.ptc STLC2500_R4_02_02_WLAN.ssf TIACX111.BIN WLANGEN.BIN
af9005.fw BCM2033-MD.hex configure iwlwifi-5000-1.ucode iwlwifi-5000-5.ucode LICENSE.radeon radeon RADIO11.BIN README STLC2500_R4_00_06.ssf STLC2500_R4_02_04.ptc WHENCE zd1211
# ls /lib/firmware/radeon
REDWOOD_me.bin REDWOOD_pfp.bin REDWOOD_rlc.bin

Compare that with the contents of /lib/firmware/ I listed earlier. Much tidier, isn’t it? I’ve saved quite a bit of wasted disk space.

I hope this post is helpful to others, as I searched unsucessfully for instructions on how to install the linux-firmware package so that only the necessary firmware files are installed. Don’t worry though: you could simply go ahead and install linux-firmware without editing the file in /etc/portage/savedconfig/sys-kernel/ if you don’t mind having unecessary files in /lib/firmware/ in addition to the firmware files you need.

Synchronise your Gentoo Linux clock with an Internet time server

There are a number of ways to synchronise Gentoo Linux with a time server on the Internet. Here I look at a few alternatives.

ntp-client

ntp-client and the NTP daemon ntpd are installed when you install the package net-misc/ntp. Although I have read on some Web sites that /etc/init.d/ntp-client should be added to the default runlevel in order to read the time from an NTP server (once-only, during start-up), this in fact does not work because usually the network connection is not up by the time the ntp-client initscript runs. Bear in mind that ntp-client does not run continuously; it syncs once with an external time server if there is a network connection, and that’s it.

NetworkManager Dispatcher

If you are using NetworkManager, an elegant solution is to use NetworkManagerDispatcher to restart ntp-client in order to resync your system clock every time a network connection comes up. This is my favoured solution for laptops; see further on for how to configure your machine to do this.

cronjob

Another way would be to create a cronjob to run periodically the ‘/etc/init.d/ntp-client restart‘ command or the ‘ntpd -q‘ command (the -q option means “set the time and quit”).

Wait a while after start up

A ‘quick-and-dirty’ method, which I have used sometimes to synchronise a laptop’s system clock every time it boots, would be to delay running ntp-client until the network is up by putting e.g. the command below in a file 10_ntp-client.start in the directory /etc/local.d/ (10 seconds is usually enough time for a wired or wireless connection to my home network to be established):

#!/bin/bash
sleep 10s && /etc/init.d/ntp-client restart

Don’t forget to make it executable:

# chmod 744 /etc/local.d/10_ntp-client.start

NTP daemon

Regarding the NTP daemon, it is possible to configure this from the command line, rather than via a Desktop Environment GUI, to run at start-up and continue running to adjust your system clock. The command:

# rc-update add ntpd default

will add the daemon’s initscript to the default runlevel so that it is launched automatically at the next startup, and the command:

# /etc/init.d/ntpd start

will start the daemon running right now.

Note that, by default, the NTP daemon won’t correct, all in one go, a time difference between your system clock and the remote NTP server if that difference is above a certain size. However, if you want to override the default behaviour, i.e. allow the NTP daemon to make a large first adjustment to the system clock, you can set the environment variable NTPD_OPTS in the file /etc/conf.d/ntpd as follows:

NTPD_OPTS="-g"
# The -g option enables ntpd to make large adjustments.

This would mean that you would not need to run ntp-client before ntpd. However, if you run ntp-client automatically — either once after start-up or periodically — then that would be good enough for the typical Desktop user, and could be an alternative to having a continuously-running NTP daemon. Nothing stops you doing both if you want, of course.

Updating the hardware clock

If you make clock_systohc="YES" in the file /etc/conf.d/hwclock then the time in the system clock will be written to the BIOS (CMOS) clock (a.k.a. hardware clock) when you shut down your PC.

How to configure NetworkManager Dispatcher to synchronise the system clock only when a network connection is made

If you’re using a machine that is permanently connected to a network, running the NTP daemon makes sense. But what if you have a machine that is not always connected to a network when it is powered up? I have a laptop and I don’t want the NTP daemon running all the time. But I would like my laptop to synchronise with an external time server once after start up when I connect to the Internet. NetworkManager has a handy tool called NetworkManager Dispatcher for doing just this.

If you have installed NetworkManager, you’ll find there is an initscript /usr/portage/net-misc/networkmanager/files/NetworkManagerDispatcher. Copy it to the directory /etc/init.d/ and give it the necessary restrictive permissions:

# cp /usr/portage/net-misc/networkmanager/files/NetworkManagerDispatcher /etc/init.d/
# chmod 744 NetworkManagerDispatcher

You no longer need to perform the above step regarding a NetworkManagerDispatcher initscript. See my update of September 23, 2014 at the bottom of this post.

Then create a shell script called e.g. 99_ntp-client in the directory /etc/NetworkManager/dispatcher.d/ to be run by NetworkManagerDispatcher when a network connection is established, containing the following code:

#!/bin/bash

INTERFACE=$1 # The interface which is brought up or down
STATUS=$2 # The new state of the interface

case "$STATUS" in
    'up') # $INTERFACE is up
        echo "System time before starting ntp-client:" > /home/fitzcarraldo/ntp-client.txt
        date >> /home/fitzcarraldo/ntp-client.txt
        echo "Starting ntp-client:" >> /home/fitzcarraldo/ntp-client.txt
        rc-config restart ntp-client &>> /home/fitzcarraldo/ntp-client.txt
        echo "System time after starting ntp-client:" >> /home/fitzcarraldo/ntp-client.txt
        date >> /home/fitzcarraldo/ntp-client.txt
        ;;
    'down') # $INTERFACE is down
        # Check for active interface and down if no one active
        if [ ! `nm-tool|grep State|cut -f2 -d' '` = "connected" ]; then
                echo "Stopping ntp-client at:" > /home/fitzcarraldo/ntp-client.txt
                date >> /home/fitzcarraldo/ntp-client.txt
                rc-config stop ntp-client &>> /home/fitzcarraldo/ntp-client.txt
        fi
        ;;
esac

Make the root user the owner of the script, and only allow the root user to write to it and execute it:

# cd /etc/NetworkManager/dispatcher.d/
# chown root:root 99_ntp-client
# chmod 744 99_ntp-client

Then add NetworkManagerDispatcher to the default runlevel so that it will be launched every time you boot your machine:

# rc-update add NetworkManagerDispatcher default

You no longer need to perform the above step regarding a NetworkManagerDispatcher initscript. See my update of September 23, 2014 at the bottom of this post.

As the package net-misc/ntp installs both /etc/init.d/ntpd and /etc/init.d/net-client, users could optionally add the NTP daemon ntpd to the default runlevel too if desired, which would provide continuous, incremental adjustments to the system clock once net-client has done its one-shot adjustment each time a network comes up:

# rc-update add ntpd default

But users who don’t leave their PCs on for days on end — or who use laptops — can ignore the above step and just stick with the NetworkManagerDispatcher and net-client solution, whereas users who leave their machines on for days or weeks on end can also use the NTP daemon to keep the system clock in sync in between the times when ntp-client has synchronised.

Don’t forget to delete ntp-client from the start-up level if you are using NetworkManagerDispatcher to run it:

# rc-update del ntp-client

Notice that the script /etc/NetworkManager/dispatcher.d/99_ntp-client logs some information in a text file ntp-client.txt in my home directory which I can check. Here is an example of what ntp-client.txt contains after I select a network (or it is selected automatically) following start up of my laptop:

System time before starting ntp-client:
Sun Jun 3 19:24:08 BST 2012
Starting ntp-client:
Restarting init script
* Setting clock via the NTP client 'ntpd' ...ntpd: time slew +0.067178s
[ ok ]
System time after starting ntp-client:
Sun Jun 3 19:24:17 BST 2012

As you can see above, the ntpd command was executed once by NetworkManagerDispatcher and made a small adjustment to the system time on my laptop.

Replacing ntpdate with ntpd in ntp-client

Just for the fun of it, I changed /etc/conf.d/ntp-client to use the command ntpd instead of ntpdate, even though the ntpdate command works fine. Anyway, here’s my /etc/conf.d/ntp-client file these days:

NTPCLIENT_CMD="ntpd"
NTPCLIENT_OPTS="-g -q"

I have added the -g option so that the ntpd command can make large adjustments to the system time if it is way off the actual time. This is useful at the beginning and end of Daylight Saving Time, or if you dual boot with Windows. Here is an example of the former when I powered up my laptop the morning after the clocks changed from BST to GMT at the end of Summer 2010:

$ cat /home/fitzcarraldo/ntp-client.txt
System time before starting ntp-client:
Sun Oct 31 09:37:23 GMT 2010
Starting ntp-client:
Starting init script
* Setting clock via the NTP client 'ntpd'...ntpd: time set -3600.122381s
[ ok ]
System time after starting ntp-client:
Sun Oct 31 08:37:30 GMT 2010

You can specify the NTP server or NTP server pool in the file /etc/ntp.conf, but the default server pool already specified in that file should work. Note again that, when ntpd is run with the -q option, it synchronises the system clock once and terminates, i.e. it is not running as a daemon.

UPDATE (September 23, 2014): Things have become easier since I wrote the above post. These days it is no longer necessary to create a NetworkManagerDispatcher initscript; you just need to put the shell script you want NetworkManagerDispatcher to execute into the directory /etc/NetworkManager/dispatcher.d/, give it attributes and permissions as shown in this post, and NetworkManager will take care of everything.

Editing from a Linux PC the phone book (contacts list) in an Android phone

A mobile phone stores contacts in the phone itself and/or on the SIM. Over the years, the phone book on my SIM became cluttered with duplicate entries, inconsistently-named contacts, and so on. I decided recently to tidy up the phone book, and looked for a way to do it from Linux.

Now, the last time I tidied up my phone book was back in 2003 when my SIM was in a Sony Ericsson T68i. These days I’m using the same SIM in an Android smartphone: the HTC Desire. Back then I used a shareware application called Mobile Navigator on a laptop running Windows XP. So, naturally, I thought it would be possible to do something similar from a PC running Linux.

An indirect method of editing a phone book in an Android phone is recommended in many Web forums. The advice is to synchronise the phone’s phone book with GMail on your PC, edit the contacts in GMail on the PC and then the contacts will be updated in the phone when the phone next synchronises with GMail. That is all very well, but I don’t want to import my phone contacts into GMail and thus have them stored in ‘The Cloud’, plus I don’t see why I should be forced to do that just to make it easier for me to tidy a phone book in my phone. So I set about searching for an application to do the job.

My search turned up three applications that appeared to enable a user to edit the phone book (phone and SIM):

1. Gammu (CLI) and Wammu (GUI front-end), FOSS with versions for both Linux and Windows.

2. MOBILedit!, a closed-source commercial product for Windows.

3. MyPhoneExplorer (Version 1.8.1), closed-source ‘donationware’ for Windows, recommended in various forums and that has been used with WINE in Linux. Not only does MyPhoneExplorer allow you to edit the phone book, it also provides a host of other features such as: viewing the phone’s call logs, messages, hardware status, files and applications; sending messages via the PC; etc. It’s a nifty application.

Web browsing told me that Gammu/Wammu does not yet work with the HTC Desire (see the bug report Don’t get any connection to HTC Desire via bluetooth in Wammu/Gammu). This is a pity, as Wammu and Gammu look well-designed, and Wammu has a professional feel to it.

The price for MOBILedit! is not extortionate but I wanted to find a cost-free solution if possible, and, more importantly, I could find no evidence on the Web of MOBILedit! having been used with WINE in Linux to edit the phone books in the HTC Desire.

The MyPhoneExplorer forums include a thread on using it with WINE, so MyPhoneExplorer looked like my only option (although it is a pity it is not FOSS). I installed MyPhoneExplorer with its own WINEPREFIX but, despite following the instructions in the MyPhoneExplorer forums, I was unable to get MyPhoneExplorer to connect to the HTC Desire via a USB cable in Linux. This may be because, despite what I have read on the android developers Web site (see Using Hardware Devices and OEM USB Drivers), as is the case with Windows it is necessary in Linux to install ADB USB drivers (the ADB drivers can be installed in Linux by installing the Android SDK). However, I was able to connect MyPhoneExplorer to my HTC Desire via WiFi at home (but not in a hotel, as connection depends on the router and internal network IP address space), and via Bluetooth (anywhere).

How to install MyPhoneExplorer in WINE

1. Use the Android Market to install MyPhoneExplorer Client on the phone.

2. Surf over to the MyPhoneExplorer Home Page and download MyPhoneExplorer_Setup_1.8.1.exe to ~/Desktop/

3. Open a Konsole/Terminal window and perform all the following steps in the same window.

4. Install MyPhoneExplorer on your PC under WINE:

$ cd
$ export WINEPREFIX=$HOME/.wine-myphoneexplorer
$ export WINEARCH="win32"
$ winecfg
$ wget "http://download.microsoft.com/download/5/a/d/5ad868a0-8ecd-4bb0-a882-fe53eb7ef348/VB6.0-KB290887-X86.exe"
$ wine VB6.0-KB290887-X86.exe
$ cd ./.wine-myphoneexplorer/drive_c/
$ cp $HOME/Desktop/MyPhoneExplorer_Setup_1.8.1.exe .
$ mv ${WINEPREFIX}/drive_c/windows/system32/oleaut32.dll ${WINEPREFIX}/drive_c/windows/system32/oleaut32-alt.dll
$ mv ${WINEPREFIX}/drive_c/windows/system32/olepro32.dll ${WINEPREFIX}/drive_c/windows/system32/olepro32-alt.dll
$ echo -e REGEDIT4\\n\\n[HKEY_CURRENT_USER\\Software\\Wine\\DllOverrides]\\n\"asycfilt\"=\"native\"\\n\"comcat\"=\"native\"\\n\"msvbvm60\"=\"native\"\\n\"oleaut32\"=\"native\"\\n\"oleaut32\"=\"native\"\\n\"olepro32\"=\"native\"\\n\"stdole2.tlb\"=\"native\"\\n[HKEY_CURRENT_USER\\Software\\MyPhoneExplorer]\\n\"Language\"=\"English.lng\" > temp.reg
$ wine regedit temp.reg
$ wget http://www.kegel.com/wine/winetricks
$ chmod +x winetricks
$ ./winetricks # Install Visual Basic 6 SP6 (I had to do this as well as wine VB6.0-KB290887-X86.exe)
$ ./winetricks # Install msxml3
$ wine MyPhoneExplorer_Setup_1.8.1.exe # Install MyPhoneExplorer

(Make sure you select the WINEPREFIX first when using winetricks)

5. Edit your Desktop Environment’s menu to use the following command for launching MyPhoneExplorer:

env WINEPREFIX="/home/fitzcaraldo/.wine-myphoneexplorer" WINEARCH="win32" wine C:\\windows\\command\\start.exe /Unix /home/fitzcarraldo/.wine-myphoneexplorer/dosdevices/c:/users/Public/Start\ Menu/Programs/MyPhoneExplorer/MyPhoneExplorer.lnk

(Of course replace “fitzcarraldo” with your user name.)

How to connect via Bluetooth

1. Look up the phone’s Bluetooth MAC address in the phone itself, write it down and keep it to hand. (I use the MAC address 11:22:33:AA:BB:C1 in the examples below.)

2. Enable Blutooth on your PC and phone, make them both discoverable, and pair them.

3. Launch MyPhoneExplorer Client on the phone and wait a few seconds for it to load and run.

4. Now check which channel is used by MyPhoneExplorer Client (In the example below it is Channel 17):

$ sudo sdptool browse
Inquiring ...
Browsing 11:22:33:AA:BB:C1 ...
Service RecHandle: 0x10000
Service Class ID List:
"PnP Information" (0x1200)

Service Name: Headset Gateway
Service RecHandle: 0x10001
Service Class ID List:
"Headset Audio Gateway" (0x1112)
"Generic Audio" (0x1203)
Protocol Descriptor List:
"L2CAP" (0x0100)
"RFCOMM" (0x0003)
Channel: 1
Profile Descriptor List:
"Headset" (0x1108)
Version: 0x0100

Service Name: Handsfree Gateway
Service RecHandle: 0x10002
Service Class ID List:
"Handsfree Audio Gateway" (0x111f)
"Generic Audio" (0x1203)
Protocol Descriptor List:
"L2CAP" (0x0100)
"RFCOMM" (0x0003)
Channel: 2
Profile Descriptor List:
"Handsfree" (0x111e)
Version: 0x0105

Service Name: Object Push
Service RecHandle: 0x10003
Service Class ID List:
"OBEX Object Push" (0x1105)
Protocol Descriptor List:
"L2CAP" (0x0100)
"RFCOMM" (0x0003)
Channel: 3
"OBEX" (0x0008)
Profile Descriptor List:
"OBEX Object Push" (0x1105)
Version: 0x0100

Service RecHandle: 0x10004
Service Class ID List:
"AV Remote Target" (0x110c)
Protocol Descriptor List:
"L2CAP" (0x0100)
PSM: 23
"AVCTP" (0x0017)
uint16: 0x100
Profile Descriptor List:
"AV Remote" (0x110e)
Version: 0x0100

Service Name: BRCM Advanced Audio
Service RecHandle: 0x10005
Service Class ID List:
"Audio Source" (0x110a)
Protocol Descriptor List:
"L2CAP" (0x0100)
PSM: 25
"AVDTP" (0x0019)
uint16: 0x102
Profile Descriptor List:
"Advanced Audio" (0x110d)
Version: 0x0102

Service Name: Phonebook Access PSE
Service RecHandle: 0x10006
Service Class ID List:
"Phonebook Access - PSE" (0x112f)
Protocol Descriptor List:
"L2CAP" (0x0100)
"RFCOMM" (0x0003)
Channel: 4
"OBEX" (0x0008)
Profile Descriptor List:
"Phonebook Access" (0x1130)
Version: 0x0100

Service Name: OBEX File Transfer
Service RecHandle: 0x10007
Service Class ID List:
"OBEX File Transfer" (0x1106)
Protocol Descriptor List:
"L2CAP" (0x0100)
"RFCOMM" (0x0003)
Channel: 5
"OBEX" (0x0008)
Profile Descriptor List:
"OBEX File Transfer" (0x1106)
Version: 0x0100

Service Name: MyPhoneExplorer
Service RecHandle: 0x10008
Service Class ID List:
UUID 128: 00001101-0000-1000-7000-00304b7f34de
Protocol Descriptor List:
"L2CAP" (0x0100)
"RFCOMM" (0x0003)
Channel: 17

5. Bind a virtual serial device to the phone (You can look up the phone’s Bluetooth MAC address in the phone itself to double check):

$ sudo rfcomm bind 1 11:22:33:AA:BB:C1 17

N.B. If you have been tinkering already with binding, and the virtual device /dev/rfcomm1 is therefore already bound, you will get an error message saying “Can't create device: Address already in use“. You can release the virtual device by using the command:

$ sudo rfcomm release /dev/rfcomm1

6. Create a symbolic link for the virtual serial link:

$ export WINEPREFIX=$HOME/.wine-myphoneexplorer
$ sudo ln -is /dev/rfcomm1 ${WINEPREFIX}/dosdevices/com2
$ sudo chmod 777 ${WINEPREFIX}/dosdevices/com2 # you may not need to do this, as the permissions may already be 777.

7. Launch MyPhoneExplorer (e.g. in KDE this would be: Kickoff > Applications > Wine> Programs > MyPhoneExplorer > MyPhoneExplorer), then press F2 (or select File > Settings).

8. Select ‘Connection’ in the left pane and then select ‘Phone type’ to be ‘SonyEricsson phone with modeminterface’. Tick ‘Stable connection (some features are deactivated)’.

9. Select ‘Connection’ in the left pane and then select ‘Phone type’ to be ‘Phone with Google Android-OS’.

10. Select ‘Connection’ in the left pane and then select ‘Connect via…’ to be ‘Bluetooth’ and enter “COM2″ (upper case, and without the quotes) and click on ‘OK’.

11. Press F1 (or select File > Connect) and your PC should be able to connect to the phone and synchronise with your phone’s phone book (Extras > Start Multi-sync), thus enabling you to edit the contents and re-synchronise to update the phone book in the phone.

Script to make subsequent connections via Bluetooth easier

Note that the channel used by MyPhoneExplorer Client will change the next time you want to connect, so there is no point editing /etc/bluetooth/rfcomm.conf (the Linux configuration file in which you would normally specify the channel). Therefore, to make life a little easier, I wrote a simple Bash script to automate as much as possible the process of reconnecting via Bluetooth in future. If you want to do the same, use your favourite text editor and save the following script with the file name myphoneexplorer.sh:

#!/bin/bash
echo -n "Please switch on Bluetooth via System Tray icon, make Bluetooth discoverable then press ENTER: "
read RESPONSE
echo -n "Please enable Bluetooth on the phone, make it discoverable then press ENTER: "
read RESPONSE
export WINEPREFIX="/home/fitzcarraldo/.wine-myphoneexplorer"
export WINEARCH="win32"
echo "Checking current rfcomm status..."
sudo rfcomm -a
echo "Trying to release rfcomm1 in case it is in use (no message means rfcomm1 is released and is now OK to use,"
echo "and the message Cannot release device: No such device also means rfcomm1 is OK to use)..."
sudo rfcomm release /dev/rfcomm1
echo -n "Now please launch MyPhoneExplorer Client on the phone, wait a few seconds then press ENTER: "
read RESPONSE
echo "Find channel of MyPhoneExplorer Client:"
sudo sdptool browse
echo -n "Enter the channel number: "
read RESPONSE
sudo rfcomm bind 1 11:22:33:AA:BB:C1 $RESPONSE
echo "Checking current rfcomm status..."
sudo rfcomm -a
echo "If all is OK then please launch MyPhoneExplorer from Kickoff > Applications > Wine > Programs > MyPhoneExplorer"
echo "and press F1 to connect to the phone."

(Of course replace “fitzcarraldo” with your user name, and replace “11:22:33:AA:BB:C1” with the Bluetooth MAC address of your phone.)

Then make the script executable:

$ chmod +x myphoneexplorer.sh

The next time you want to use MyPhoneExplorer, open a Konsole/Terminal, execute the script:

$ sh myphoneexplorer.sh

and follow the instructions it displays in the Konsole/Terminal window.

How to connect via WiFi

Connecting MyPhoneExplorer to the phone via WiFi is easier than via Bluetooth. Note that WiFi connection will not work with a public WiFi network, just a home WiFi network.

1. Enable WiFi on your PC and phone.

2. Launch MyPhoneExplorer Client on the phone and wait a few seconds for it to load and run.

3. Launch MyPhoneExplorer (e.g. in KDE this would be: Kickoff > Applications > Wine> Programs > MyPhoneExplorer > MyPhoneExplorer), then press F2 (or select File > Settings).

4. Select ‘Connection’ in the left pane and then select ‘Phone type’ to be ‘SonyEricsson phone with modeminterface’. Tick ‘Stable connection (some features are deactivated)’.

5. Select ‘Connection’ in the left pane and then select ‘Phone type’ to be ‘Phone with Google Android-OS’.

6. Select ‘Connection’ in the left pane and then select ‘Connect via…’ to be ‘WiFi’ and click on ‘OK’.

7. Press F1 (or select File > Connect) and your PC should be able to connect to the phone and synchronise with your phone’s phone book (Extras > Start Multi-sync), thus enabling you to edit the contents and re-synchronise to update the phone book in the phone.

Useful references

The MyPhoneExplorer forums are oriented to Windows as it is a Windows application, but there is a thread for Linux users: HowTo: Use MyPhoneExplorer under GNU/Linux (English Version)

The thread for Windows users of MyPhoneExplorer may also be of some use: Howto and FAQ: Use Android Phones with MyPhoneExplorer

Limitations in WINE

The only limitation I have found using MyPhoneExplorer 1.8.1 in WINE is that it crashes if I try to cut and paste when editing a phone book entry. Additionally, some people have reported that the buttons on the button bar do not work when you are connected to the phone; they usually do work for me (apparently it depends on whether you have installed msxml3) but sometimes don’t. In any case, if they don’t then you can use the pull-down menus from the menu bar instead.

Other than that, MyPhoneExplorer works well in WINE and enables me to edit the phone book in my Android phone without involving Big Brother! It’s a nice application.

Firewall rules if using WiFi

If you’re using MyPhoneExplorer to connect with the phone via WiFi instead of Bluetooth, and your PC has a firewall enabled, according to a post on 7 June 2011 in the MyPhoneExplorer forums you have to configure the firewall with the following rules:

TCP port 80 (outgoing) – Check for update
TCP port 5210 (outgoing) – Communication with client
UDP port 5211 (outgoing) – Communication with client
UDP port 5212 (inbound) – Broadcast from the client

Below I list the rules I implemented in Uncomplicated Firewall:

# ufw status
Status: active

To              Action          From

--              ------          ----
Anywhere        ALLOW           5212/udp

80/tcp          ALLOW OUT       Anywhere
5210/tcp        ALLOW OUT       Anywhere
5211/udp        ALLOW OUT       Anywhere

Alternatively you could just disable the firewall on your PC while you’re using MyPhoneExplorer with your phone, which I do anyway when I’m at home as my home network is protected by the firewall in my router.

EDIT (October 25, 2012): Now there is another way of editing an Android phone’s contacts list from Linux: AirDroid. And you don’t need to mess around with WINE to use it. For details see my post AirDroid, a handy Android app for managing your phone from Linux.

Cannot browse some Web sites: yet another cause

Having spent hours yesterday trying to figure out why I could no longer browse a few specific Web sites from my old Gateway Solo 9300 laptop running Linux, whereas all the other Linux and Windows laptops that use my wireless network can browse any Web site, I thought I’d post the solution as Google did not turn up this particular cause.

There are several possible reasons why one may not be able to browse some Web sites: IPv6; the MTU; a black hole router en route; the settings in the various ip_* and tcp_* files in /proc/sys/net/ipv4/, and so on. So, unfortunately I had many avenues to pursue.

My old Gateway Solo 9300 laptop had enabled me to browse the Web reliably via my home wireless network until recently. Suddenly I could neither browse the Sabayon Linux Web site nor access the Entropy package manager’s repository. I could also no longer browse some other Web sites, although most Web sites were still accessible without trouble.

I tried many different things without success, and then finally remembered that I had reconfigured my router a couple of weeks ago because one of my family had reset it whilst I was away from home. Now, when this model of router (BT Home Hub, Version 1.0) is reset it defaults to WEP encryption for wireless networking. However, I normally have it set to use WPA-PSK encryption. So, when I got home I accessed the router’s Web interface via Ethernet from a Desktop PC and changed wireless networking encryption to “WPA-PSK Version: WPA+WPA2″. In the past I had set it to “WPA-PSK Version: WPA”, and thought that setting “WPA+WPA2″ instead of “WPA” this time would not cause any problems. Well, it didn’t on all the other laptops using my network, but my old Gateway Solo 9300 with Linksys CardBus card (‘Linksys WPC54G (EU) v7.1 wireless notebook adapter card’) was different.

As soon as I wondered if the encryption setting was the cause of my problem, I browsed to the BT Home Hub configuration page and changed wireless networking encryption from “WPA-PSK Version: WPA+WPA2″ to “WPA-PSK Version: WPA”. Bingo, my Gateway Solo 9300 running Sabayon Linux E17 Edition and Firefox 4 could browse all Web sites again. Mind you, I also need to have the ipv6 module disabled (I had previously uncommented the line alias net-pf-10 off in the file /etc/modprobe.d/aliases.conf and used the command update-modules) as well as the modifications mentioned in an earlier post (Why can’t I access a specific Web site?). But all those other measures do not solve the problem if the router is configured for “WPA-PSK Version: WPA+WPA2″.

The router’s wireless security option “WPA-PSK Version: WPA” is intended for a network that would only be used by clients configured to use WPA encryption; the router’s option “WPA-PSK Version: WPA2″ is intended for a network that would only be used by clients configured to use WPA2 encryption; the router’s option “WPA-PSK Version: WPA+WPA2″ is intended for a network that would be used by clients configured to use either WPA or WPA2 encryption. So I wonder why there was a problem, as the laptop and CardBus card are configured for “WPA & WPA2 Personal” in nm-applet, and the card supports WPA (TKIP) and WPA2 (CCMP a.k.a. AES).

Why can’t I access a specific Web site?

Is there one specific Web site that you can never access? That always causes your Web browser to stall when you click on a link to that site or enter the site’s URL in the browser’s address bar? Perhaps it’s an Internet banking site? You don’t have trouble with other sites, just this one particular site or perhaps just a couple of sites?

The chances are that this problem is caused by what is called a ‘black hole’ router somewhere between you and that site. For the technical explanation of a black hole router, see e.g. the article Black Hole (networking).

I experienced this precise problem a couple of days ago with the popular Web site IMDb. The old Gateway Solo 9300 laptop I was using has no built-in networking hardware so I use a couple of CardBus cards for wireless and wired network access. The Linksys WPC54G (EU) v7.1 wireless notebook adapter works fine but, irrespective of the Web browser, I could not access the IMDb Web site; the browser always stalled when trying to load the site. I discovered I also had the same problem with my bank’s Web site.

I could ping other sites by IP address and by domain name, but pinging the IMDb site never received a reply (and it still doesn’t, even after the fix explained below which allows browsing of the site).

I also experienced this problem several years ago under Windows XP when trying to access the Amazon UK Web site, using an MTU that I had incorrectly set to a value smaller than possible. The problem this time was due to a correctly-set MTU. In both cases, the two MTUs are smaller than a router somewhere en route to those sites wanted to handle.

BACKGROUND

Bear with me while I explain how the problem arose, as it’s relevant (and useful) information.

I had just installed Sabayon Linux on the laptop and got the wireless network connection up, and the first thing I then did was to launch Firefox. With an MTU of 1500 for wlan0, Firefox would only load Google (and that, only intermittently). All other sites would stall. So I used the following command iteratively in order to find the MTU for this hardware, which is 1464 (the maximum packet size in bytes that does not fragment + 28 bytes):

# ping -M do -s packet_size_in_bytes www.cisco.com

e.g.

# ping -M do -s 1472 www.cisco.com

I just varied the packet size in the ping command until “Frag needed and DF set” was not displayed.

I can reduce the MTU to 1464 as follows:

# ifconfig wlan0 mtu 1464

I could make this permanent by adding an entry (mtu_wlan0=”1464″) to the file /etc/conf.d/net, but I chose instead to make it permanent by adding the above ifconfig command to the file /etc/conf.d/local. This (correct) MTU works fine for all sites I have visited so far except for two, which just stall the browser: IMDb and my bank’s Web site.

I also have a Belkin F5D5010 CardBus Network Card (wired Ethernet) for the laptop. It works fine with an MTU of 1500, and there is no problem accessing the IMDb Web site in Firefox. So, apparently, the MTU is the problem when using the wireless network connection. Now let’s look at the solution…

THE SOLUTION

Well, in the case of Windows it is possible to edit the Registry to solve the problem of network ‘black holes’. But what do you do in the case of Linux? It turns out that the kernel /proc file system provides an easy way to enable and disable TCP MTU Probing by changing a value in the ‘file’ /proc/sys/net/ipv4/tcp_mtu_probing. A value of 0 = disabled; 1 = enabled when a black hole router is detected; 2 = always enabled.

This is what my laptop had in that ‘file':

# cat /proc/sys/net/ipv4/tcp_mtu_probing
0

So all I needed to do was:

# echo 2 > /proc/sys/net/ipv4/tcp_mtu_probing

and, bingo, a browser can access IMDb and my bank’s Web site without a problem. To make it permanent, I just added the above command to the file /etc/conf.d/local so that it is executed every time I boot the laptop. Here is what my file /etc/conf.d/local looks like now:

# Here is where you can put anything you need to start
# that there is not an init script for.

local_start() {
# This is a good place to load any misc programs
# on startup (use &>/dev/null to hide output)

# START OF MY ADDITIONS
# The Linksys CardBus card does not work with a MTU greater than 1464:
ifconfig wlan0 mtu 1464
# Enable TCP MTU Probing in order to deal with black hole routers:
echo 2 > /proc/sys/net/ipv4/tcp_mtu_probing
# END OF MY ADDITIONS

# We should always return 0
return 0
}

local_stop() {
# This is a good place to unload any misc.
# programs you started above.

# We should always return 0
return 0
}

UPDATE (May 13, 2011): OpenRC 0.8.0 and later in Gentoo and Sabayon Linux no longer use the file /etc/conf.d/local but instead require the commands to be in files in the directory /etc/local.d/. So I created a file /etc/local.d/01network.start containing the following lines:

# The Linksys CardBus card does not work with MTU greater than 1464:
ifconfig wlan0 mtu 1464
# Enable TCP MTU probing to deal with black hole routers:
echo 2 > /proc/sys/net/ipv4/tcp_mtu_probing

and made it executable:

# chmod +x /etc/local.d/01network.start

UPDATE (April 11, 2012): If “echo 2″ does not solve the problem, try “echo 1″ instead. The possible values are:

0   Do not perform PLPMTUD (Packetization Layer Path MTU Discovery)
1   Perform PLPMTUD only after detecting a ‘blackhole’.
2   Always perform PLPMTUD.

Follow

Get every new post delivered to your Inbox.

Join 52 other followers