28 February 2012

83. Configuring route for multiple network interfaces on Debian Testing

In my previous post I got rid of network-manager.

On my main desktop, which serves as a gateway for two subnets and serves them with access to the internet and has three ifs (eth0 goes to outside world, eth1 serves 192.168.0-127 and provides inet passthrough, eth2 serves 192.168.128-255), I had issues getting the internet connection to work once network-manager was gone -- the issue was the routing table.

Here's what I did to diagnose and solve it:

When I got rid of network manager I set up my /etc/network/interfaces like this:
auto lo
iface lo inet loopback
auto eth0

iface eth0 inet dhcp
auto eth1
iface eth1 inet static
address 192.168.1.1
netmask 255.255.255.0
gateway 192.168.1.1

auto eth2
iface eth2 inet static
address 192.168.1.129
netmask 255.255.255.128
gateway 192.168.1.129
But it gives
sudo route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.1.129   0.0.0.0         UG    0      0        0 eth2
0.0.0.0         192.168.1.1     0.0.0.0         UG    0      0        0 eth1
0.0.0.0         XXX.XXX.XXX.254 0.0.0.0         UG    0      0        0 eth0
XXX.XXX.XXX.0   0.0.0.0         255.255.248.0   U     0      0        0 eth0
169.254.0.0     0.0.0.0         255.255.0.0     U     1000   0        0 eth0
192.168.1.0     0.0.0.0         255.255.255.0   U     0      0        0 eth1
192.168.1.128   0.0.0.0         255.255.255.128 U     0      0        0 eth2
The problem is that I DON'T want all traffic via eth2 and eth1. I want the default gateway to be my eth0. Inverting the order of the ifs in /etc/network/interfaces doesn't fix it either.

A quick fix is to do
 sudo route add default dev eth0
 which adds this as the first line:
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         0.0.0.0         0.0.0.0         U     0      0        0 eth0
It looks like we might want to manually configure route.

Turns out you can just add the route options to your /etc/network/interfaces file

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet dhcp

auto eth1
iface eth1 inet static
address 192.168.1.1
netmask 255.255.255.0
gateway 192.168.1.1

auto eth2
iface eth2 inet static
address 192.168.1.129
netmask 255.255.255.128
gateway 192.168.1.129

auto wlan0
iface wlan0 inet static
address 192.168.2.1
netmask 255.255.255.0
gateway 192.168.2.1

post-up ip route flush all
post-up route add default dev eth0
post-up route add -net 169.254.0.0 netmask 255.255.0.0 dev eth0 metric 1000
post-up route add -net 192.168.1.0 netmask 255.255.255.0 gw 192.168.1.1 eth1
post-up route add -net 192.168.1.128 netmask 255.255.255.128 gw 192.168.1.129 eth2
post-up route add -net 192.168.2.0 netmask 255.255.255.0 gw 192.168.2.1 wlan0

The script gives us a nice, compact routing table on doing
sudo service networking restart

sudo route -n
Kernel IP routing table Destination     Gateway         Genmask         Flags Metric Ref    Use Iface 0.0.0.0         0.0.0.0         0.0.0.0         U     0      0        0 eth0 169.254.0.0     0.0.0.0         255.255.0.0     U     1000   0        0 eth0 192.168.1.0     192.168.1.1     255.255.255.0   UG    0      0        0 eth1 192.168.1.128   192.168.1.129   255.255.255.128 UG    0      0        0 eth2

Edit::
An earlier version of this post used a separate script (see below). This works fine on boot. However, sudo service networking restart
does not invoke it -- so you may end up with a faulty route table. Thus, it is preferable to use the method above in which the route options are added to the end of /etc/network/interfaces

The following (below) is kept for posterity only:

We put the commands below into /etc/routing_table.sh:
#!/bin/sh
sudo ip route flush all
sudo route add default dev eth0
sudo route add -net 169.254.0.0 netmask 255.255.0.0 dev eth0 metric 1000
sudo route add -net 192.168.1.0 netmask 255.255.255.0 gw 192.168.1.1 eth1
sudo route add -net 192.168.1.128 netmask 255.255.255.128 gw 192.168.1.129 eth2
exit 0
We change the atttributes:
sudo chmod o-rwx /etc/routing_table.sh
sudo chmod g-rwx /etc/routing_table.sh
sudo chmod u+rwx /etc/routing_table.sh
Here user is root. This way only root can execute and edit the table. I guess the 'sudo' is a bit superfluous in our script.
To make it start on boot, add a line to your /etc/rc.local
My rc.local now looks like this:
#!/bin/sh -e echo "1" > /proc/sys/net/ipv4/ip_forward sh /etc/firewall-rules.sh sh /etc/routing_table.sh exit 0
The firewall-rules.sh script is described in another post on ip tables.

27 February 2012

82. Getting rid of network-manager (and trying wicd) on Debian Testing

Network-manager is a fine program, but it interferes with the 'linux' way of doing things by using text files for configuration.

While network-manager makes it easy to do easy things,  /etc/network/interfaces makes it easy to do everything since it makes every setting transparent.

The main problem with remove network-manager is that gnome-core depends on it. Remove network-manager, everything in gnome goes. No good, and completely unnecessary.

I'm still a bit hesitant about configuring WPA on the command line, so I want to have wicd as a backup once network manager is gone.

--START HERE --
So
sudo apt-get install wicd-cli wicd-curses wicd-gtk wpasupplicant

Turn off network-manager (temporarily) and restart your network
sudo service networking restart && sudo service network-manager stop

Start wicd-gtk and configure your wireless network (if that's what you need) to make sure that everything is in working order and you can live without network-manager.

sudo apt-get install rcconf

sudo rcconf

Uncheck network-manager and exit.
update-rc.d: using dependency based boot sequencing
update-rc.d: warning: network-manager start runlevel arguments (none) do not match LSB Default-Start values (2 3 4 5)
update-rc.d: warning: network-manager stop runlevel arguments (0 1 2 3 4 5 6) do not match LSB Default-Stop values (0 1 6)
You can use sysv-rc-conf instead.  Don't worry about the warning about the LSB default -start values -- (2 3 4 5) just means that by default network-manager should be running at runlevels 2-5 (i.e. normal operation). 0 would be halt, 1 would effectively be rescue mode ('single-user mode') and 6 is system reboot. Anyway, here's sysv-rc-conf:


After your next reboot you can check whether network-manager has started:

sudo service network-manager status
[sudo] password for me:
NetworkManager is not running ... failed!

You can make wicd-gtk autostart on starting gnome:
start gnome-sessions-manager and add wicd-gtk if it isn't /already/ there.



The wicd network manager icon will show up in the notification area in gnome (lower right) instead of top right (see picture above). You can supposedly use this to move it: http://blog.norida.me/blog/2011/12/05/move-wicds-icon-to-gnome-shells-status-bar-top-bar/

Given that I use Faenza I also use this: http://gnome-look.org/content/show.php/Faenza+Wicd+Iconset?content=133821
(unzip it, go to the directory and do sh install )


Anyway, the real advantage of wicd is hat there are cli and curses versions available e.g. wicd-curses:


Links to this post:
http://eulez.blogspot.com.es/2013/07/de-ubuntu-debian.html

81. nvidia 295.20 bug causing gnome-shell to crash on Debian Testing


UPDATE: Here's how to downgrade your drivers:
http://verahill.blogspot.com.au/2012/03/debian-testing-downgrading-nvidia.html

Update: 
A bigger issue is what this bug does to evolution:
http://verahill.blogspot.com.au/2012/02/debian-testing-wheezy-64-no-real.html


The symptoms:
I've tried to use the correct gnome-shell terminology.

1. Go to the top left corner (Hot Corner) of the desktop to get the Overview and Search Entry field
2. Start typing in the name of an application
3. The window will flicker as if gnome-shell is being restarted (similar to alt+f2++r)
4. Do it again and you get a full-on crash with an unhappy looking computer

dmesg based on repeatedly crashing gnome-shell says:

[ 7011.967820] gnome-shell[32742]: segfault at 10 ip 00007fa1b6d98c0f sp 00007fa1914a1638 error 6 in libnvidia-tls.so.295.20[7fa1b6d98000+3000]
[ 7111.276979] gnome-shell[748]: segfault at 10 ip 00007ff7eb598c0f sp 00007ff7beffc638 error 6 in libnvidia-tls.so.295.20[7ff7eb598000+3000]
[ 7620.952276] gnome-shell[2933]: segfault at 10 ip 00007f0a9fdd9c0f sp 00007f0a710fe638 error 6 in libnvidia-tls.so.295.20[7f0a9fdd9000+3000]
[ 7628.106656] gnome-shell[2986]: segfault at 10 ip 00007f26423f3c0f sp 00007f2612ffd638 error 6 in libnvidia-tls.so.295.20[7f26423f3000+3000]
[ 7658.755466] gnome-shell[3818]: segfault at 10 ip 00007f76bbf2cc0f sp 00007f7691a77638 error 6 in libnvidia-tls.so.295.20[7f76bbf2c000+3000]
[ 7666.310714] gnome-shell[3905]: segfault at 10 ip 00007f3279e64c0f sp 00007f325469d638 error 6 in libnvidia-tls.so.295.20[7f3279e64000+3000]
[ 7717.061483] gnome-shell[4829]: segfault at 10 ip 00007f245ad26c0f sp 00007f243469c638 error 6 in libnvidia-tls.so.295.20[7f245ad26000+3000]


The libnvidia-tls files are found here:
/usr/lib/x86_64-linux-gnu/libnvidia-tls.so.295.20
/usr/lib/x86_64-linux-gnu/tls/libnvidia-tls.so.295.20

and
 dpkg --search libnvidia-tls.so.295.20 
gives
libgl1-nvidia-glx: /usr/lib/x86_64-linux-gnu/tls/libnvidia-tls.so.295.20
libgl1-nvidia-glx: /usr/lib/x86_64-linux-gnu/libnvidia-tls.so.295.20
Ergo, that's where the bug is.


Cause:
Bad nvidia drivers -- in package libgl1-nvidia-glx

This is not unique to debian.
"Confirmed, I'm seeing the same on Gentoo ~amd64. gnome-shell 3.2.2.1 crashes while doing a search with nvidia-drivers 295.20 installed (backtrace is in libnvidia-tls.so). Downgrading to nvidia-drivers 290.10 resolves the issue, so it is a problem with the drivers."

http://www.nvnews.net/vbulletin/showthread.php?t=174049 (14 Feb 2012)

UPDATE: Here's how to downgrade your drivers:
http://verahill.blogspot.com.au/2012/03/debian-testing-downgrading-nvidia.html


There are no bugs listed for libgl1-nvidia-glx
http://bugs.debian.org/cgi-bin/pkgreport.cgi?pkg=libgl1-nvidia-glx

But nvidia-glx has it's fair share of bugs filed against it:
http://bugs.debian.org/cgi-bin/pkgreport.cgi?package=nvidia-glx

From what I can tell this is the relevant bug report (17 February 2012):
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=660189
which points to
http://www.nvnews.net/vbulletin/showthread.php?t=174049&page=3

Solution:

1. The 'proper way':
Downgrade your drivers.

UPDATE: Here's how to downgrade your drivers:
http://verahill.blogspot.com.au/2012/03/debian-testing-downgrading-nvidia.html


2. The easy, interesting way:
"For me deleting recently-used.xbel and recreating it with no content solved the problem just temporary. But instead of creating a equally named directory one could also sudo chattr +i recently-used.xbel to keep the file empty.  Keeping the file empty also significantly speeds up the application launcher for me. so it would be nice to have a way to configure this instead of fixing it that rude way, for folks that dont want or need recently used files."


In practical terms, this means:

echo ""> ~/.local/share/recently-used.xbel
sudo chattr +i ~/.local/share/recently-used.xbel

And you are done!

Once the bug has been fixed, you can do
 chattr -i ~/.local/share/recently-used.xbel 


to restore normal functionality

This solution worked for me on an up-to-date debian testing.

Oh well. At least the folks at nvidia are aware of the bug:


Thoughts:
The nvidia binaries only entered the debian testing repos around the 25-26 of February from what I can tell. The bug was known for ten days by then, so why did the binaries get promoted to testing?

Here's what I've got installed:

i A glx-alternative-nvidia          - allows the selection of NVIDIA as GLX prov
i A libgl1-nvidia-alternatives      - transition libGL.so* diversions to glx-alt
i A libgl1-nvidia-glx               - NVIDIA binary OpenGL libraries          
i A libglx-nvidia-alternatives      - transition libgl.so diversions to glx-alte
pi  libnvidia-compiler-ia32         - NVIDIA runtime compiler library (32-bit)
i A libnvidia-ml1                   - NVIDIA management library (NVML) runtime l
i A nvidia-alternative              - allows the selection of NVIDIA as GLX prov
i A nvidia-compute-profiler         - NVIDIA Compute Visual Profiler          
i   nvidia-cuda-dev                 - NVIDIA CUDA development files          
i A nvidia-cuda-doc                 - NVIDIA CUDA and OpenCL documentation    
i A nvidia-cuda-gdb                 - NVIDIA CUDA GDB                        
i A nvidia-cuda-toolkit             - NVIDIA CUDA toolkit                    
i   nvidia-glx                      - NVIDIA metapackage                      
i A nvidia-installer-cleanup        - Cleanup after driver installation with the
i   nvidia-kernel-3.1.0-1-amd64     - NVIDIA binary kernel module for Linux 3.1.
i   nvidia-kernel-common            - NVIDIA binary kernel module support files
i A nvidia-kernel-dkms              - NVIDIA binary kernel module DKMS source
i   nvidia-kernel-source            - NVIDIA binary kernel module source      
i A nvidia-libopencl1               - NVIDIA OpenCL library                  
i   nvidia-libopencl1-ia32          - NVIDIA OpenCL 32-bit library            
pi  nvidia-opencl-common            - NVIDIA OpenCL driver                    
i   nvidia-opencl-dev               - NVIDIA OpenCL development files        
pi  nvidia-opencl-icd-ia32          - NVIDIA OpenCL ICD (32-bit)              
i   nvidia-settings                 - Tool for configuring the NVIDIA graphics d
i A nvidia-smi                      - NVIDIA System Management Interface      
i A nvidia-support                  - NVIDIA binary graphics driver support file
i A nvidia-vdpau-driver             - NVIDIA vdpau driver                    
pi  nvidia-xconfig                  - X configuration tool for non-free NVIDIA d
i A xserver-xorg-video-nvidia       - NVIDIA binary Xorg driver