Speeding up wireless internet on Crunchbang 11

On a recent new install of Crunchbang 11 I was having major problems connecting to my router with a Ralink RT3370 wireless USB dongle from my main tower. After investigating and playing around, this is my list of changes which got me sorted:

1. AES vs TKIP Encryption:
Connect to the router and change the WPA2 encryption from AES to TKIP. My first suspicon about the lack of connection was the encryption method and maybe the latest RT3370 drivers and wpasupplicant. After changing to TKIP I could connect, allbeit with a slow connection due to packet loss.

2. Move Adapter from USB2 to USB3:
Moved the Dongle from the front USB2 connector to a blue USB3 connector at the back, and I noticed a slight speed increase. After these hardware changes, it was time to go for some terminal-fu and edit a few files to get some extra internet speed.

3. Firstly I edited /etc/nsswitch.conf:
sudo vim /etc/nsswitch.conf
I commented out the original line:
#hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4
And changed it to:
hosts: files dns

4. Next I disabled ipV6 in Iceweasel:
In the address bar I typed “about:config” and changed “network.dns.disableIPv6” to “true” with a double-click.

5. Next up was to disable ipV6 system wide:
echo "#disable ipv6" | sudo tee -a /etc/sysctl.conf
echo "net.ipv6.conf.all.disable_ipv6 = 1" | sudo tee -a /etc/sysctl.conf
echo "net.ipv6.conf.default.disable_ipv6 = 1" | sudo tee -a /etc/sysctl.conf

6. Adaptor Power Management:
Another thing I had heard is that sometimes powercontrol can interfere with wireless speed as well so I disabled it for the USB dongle:
sudo iwconfig wlan0 power off

7. Swap nm-applet and network-manager for a Manual Static Wireless Connection:
First I disabled nm-applet from autostarting:
sudo mv /etc/xdg/autostart/nm-applet.desktop /etc/xdg/autostart/BKPnm-applet
Then I stopped Network Manager:
sudo /etc/init.d/network-manager stop
And completely Disabled it:
sudo echo "manual" | sudo tee /etc/init/network-manager.override

8. Just needed to add my manual network config:
sudo vim /etc/network/interfaces
Added my wifi info:
auto wlan0
iface wlan0 inet static
address 192.168.1.136
netmask 255.255.255.0
gateway 192.168.1.1
wpa-ssid ROUTER_ESSID
wpa-psk MYPASSWORD

Then manually added the Google dns addresses:
sudo vim /etc/resolv.conf
And add these:
nameserver 8.8.8.8
nameserver 8.8.4.4

Rebooted into a system with awesome internet cow-power-fu speeds!!

Stop resolv.conf being overwritten by Network Manager

Going Minimal and Manual
This is one of those niggly little problems that happens when people who install full desktop environments face when they go for a bit of fluff reduction and start doing things manually.

Network-Manager and Wicd
I’ve already written about manually setting up a wireless connection, and static wired connections, which will just usually takeover and leave network-manager-gnome or wicd redundant but still showing the applet in your panel.
I completely remove network-manager-gnome anyway, but you may have a reason for keeping it just in case.


Resolvconf
The thing is, you still have the resolvconf package installed which will automatically take over and wipe your manually edited /etc/resolv.conf file, it even tells you what will happen at the top of the file in a commented out warning.

Quick n Easy Method
Just edit and change the write permissions on the resolv.conf file so that resolvconf can’t wipe it.

sudo vim /etc/resolv.conf

Add your nameservers (Iuse Google’s)

nameserver 8.8.8.8
nameserver 8.8.4.4

Then change it to read only (Can be reveresed by changing the + to a – in that command)

sudo chattr +i /etc/resolv.conf

Now reboot, you should have a nice manually configured wireless connection with no DNS issues or resolv.conf overwriting.