1000baseT for RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller

I have a Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller (rev 06) in my new Ubuntu Trusty (14.04.1) server. As you can see here:

root@orac:/home/jj5# lspci
...
02:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller (rev 06)
...

I was having a problem with the card only supporting 100baseT speeds. I downloaded and installed the Realtek driver (and rebooted):

# bunzip2 r8168-8.039.00.tar.bz2
# tar xf r8168-8.039.00.tar
# cd r8168-8.039.00
# ./autorun.sh
# reboot

That didn’t fix the problem.

I installed the ethtool package and ran it:

# apt-get install ethtool
# ethtool p2p1
Settings for p2p1:
        Supported ports: [ TP ]
        Supported link modes:   10baseT/Half 10baseT/Full 
                                100baseT/Half 100baseT/Full 
                                1000baseT/Full 
        Supported pause frame use: No
        Supports auto-negotiation: Yes
        Advertised link modes:  10baseT/Half 10baseT/Full 
                                100baseT/Half 100baseT/Full 
                                1000baseT/Full 
        Advertised pause frame use: Symmetric Receive-only
        Advertised auto-negotiation: Yes
        Speed: 100Mb/s
        Duplex: Full
        Port: Twisted Pair
        PHYAD: 0
        Transceiver: internal
        Auto-negotiation: on
        MDI-X: Unknown
        Supports Wake-on: pumbg
        Wake-on: g
        Current message level: 0x00000033 (51)
                               drv probe ifdown ifup
        Link detected: yes

As you can see the speed is 100Mb/s, not 1000Mb/s. It says that 1000baseT full duplex is supported. I tried forcing the speed:

# ethtool -s p2p1 speed 1000 duplex full advertise 0 autoneg off

But that didn’t work. The ethtool program reported the card was still operating and 100Mb/s.

Then I tried plugging in a different cable… and that fixed the problem!

Making SSH client use line buffered stream

So I found out about stdbuf. To get it:

# apt-get install coreutils

If you want your ssh client to use line-buffered streams use -t -t.

So I ended up with:

# su -c "stdbuf -oL ssh -t -t /usr/bin/tail -f /var/input.log | stdbuf -oL tr -c '\\11\\12\\15\\40-\\176" myuser \
  | tee -a /tmp/input.log \
  | grep --line-buffered -v "...ignore..." \
  >> /tmp/output.log

Holy command-line Batman!

Mounting Windows SMB share from Debian Wheezy

Configuring an SMB mount from my Linux box to my Windows box. This was helpful.

Basically:

# apt-get install cifs-utils

Then create your credentials file:

# cat > /root/amanda.smbpass  <<EOF
username=jj5
password=SECRET
EOF

Then edit /etc/fstab and add:

//amanda.jj5.net/Users  /media/amanda cifs defaults,noauto,credentials=/root/amanda.smbpass 0 2

Then create /etc/network/if-up.d/mount-amanda like this:

#!/bin/bash
mount /media/amanda

And make sure it’s executable:

# chmod +x /etc/network/if-up.d/mount-amanda

Mounting can also be done from the command-line:

# mount -t cifs -o username=jj5,password=SECRET //amanda.jj5.net/Users /media/amanda

Installing Subversion on Mac OS X with WebDAV support (serf library)

cd ~/Development/svn-install
wget http://prdownloads.sourceforge.net/scons/scons-2.3.4.tar.gz
wget http://mirror.ventraip.net.au/apache/apr/apr-1.5.1.tar.gz
wget http://mirror.ventraip.net.au/apache/apr/apr-util-1.5.4.tar.gz
wget http://mirror.ventraip.net.au/apache/subversion/subversion-1.8.10.tar.gz
tar xzf scons-2.3.4.tar.gz
tar xzf apr-1.5.1.tar.gz 
tar xzf apr-util-1.5.4.tar.gz
tar xzf subversion-1.8.10.tar.gz
cd scons-2.3.4
sudo python setup.py install
cd ../apr-1.5.1
./configure --prefix=/usr/local
make
sudo make install
cd ../apr-util-1.5.4
./configure --with-apr=/usr/local --prefix=/usr/local
make
sudo make install
cd ../subversion-1.8.10
sh get-deps.sh serf
cd serf
scons APR=/usr/local APU=/usr/local OPENSSL=/usr/local PREFIX=/usr/local
sudo scons PREFIX=/usr/local install
cd ..
./configure --with-openssl --with-serf=/usr/local --prefix=/usr/local
make
sudo make install

Nuff said!

Oh, wait… there’s a problem with misconfigured CA certificates…

cd ~/Development/svn-install
wget https://distfiles.macports.org/MacPorts/MacPorts-2.3.3-10.10-Yosemite.pkg

Run the MackPorts*.pkg…

xcode-select --install

Then…

sudo /opt/local/bin/port install curl-ca-bundle

Then…

sudo -s
cd /System/Library/OpenSSL/certs/
ln -s /opt/local/etc/openssl/cert.pem cert.pem
cd /usr/local/etc/openssl/certs
ln -s /opt/local/etc/openssl/cert.pem cert.pem

Testing:

openssl s_client -connect www.progclub.org:443 -CApath /opt/local/etc/openssl/

Using MacPorts OpenSSL:

sudo port install openssl
cd ~/Development/svn-install/subversion-1.8.10/serf/
scons APR=/usr/local APU=/usr/local OPENSSL=/opt/local PREFIX=/usr/local
sudo scons PREFIX=/usr/local install

Done!

Fixing CA Certificates after upgrade to Ubuntu 14.04.1

After using do-release-upgrade to upgrade Ubuntu to version 14.04.1 I started having the following problem:

root@orac:/root# wget https://www.progclub.org/robots.txt                                                      
--2014-11-20 13:49:28--  https://www.progclub.org/robots.txt                                                   
Resolving www.progclub.org (www.progclub.org)... 67.207.128.184                                                
Connecting to www.progclub.org (www.progclub.org)|67.207.128.184|:443... connected.                            
ERROR: cannot verify www.progclub.org's certificate, issued by '/C=GB/ST=Greater Manchester/L=Salford/O=COMODO CA Limited/CN=COMODO RSA Domain Validation Secure Server CA’:                                                  
  Self-signed certificate encountered.                                                                         
To connect to www.progclub.org insecurely, use `--no-check-certificate'.

To start with I did this:

root@orac:/root# cd /etc/ssl/certs
root@orac:/etc/ssl/certs# mv ssl-cert-snakeoil.pem ../
root@orac:/etc/ssl/certs# cd /etc/ssl/private
root@orac:/etc/ssl/private# mv ssl-cert-snakeoil.key ../

Then I got rid of the symlink(s) for the ssl-cert-snakeoil.pem, e.g.:

root@orac:/etc/ssl# cd /etc/ssl/certs
root@orac:/etc/ssl/certs# ll | grep 'snake'
lrwxrwxrwx 1 root root   21 Jan 10  2012 c8882f98 -> ssl-cert-snakeoil.pem
lrwxrwxrwx 1 root root   21 Mar 25  2014 c8882f98.0 -> ssl-cert-snakeoil.pem
root@orac:/etc/ssl/certs# mv c8882f98* ../

Then I ran: dpkg-reconfigure ca-certificates:

root@orac:/root# dpkg-reconfigure ca-certificates 

On the first screen I selected ‘ask’:

  ┌───────────────────────────────────┤ ca-certificates configuration ├────────────────────────────────────┐   
  │ This package may install new CA (Certificate Authority) certificates when upgrading. You may want to   │   
  │ check such new CA certificates and select only certificates that you trust.                            │   
  │                                                                                                        │   
  │  - yes: new CA certificates will be trusted and installed;                                             │   
  │  - no : new CA certificates will not be installed by default;                                          │   
  │  - ask: prompt for each new CA certificate.                                                            │   
  │                                                                                                        │   
  │ Trust new certificates from certificate authorities?                                                   │   
  │                                                                                                        │   
  │                                                  yes                                                   │   
  │                                                  no                                                    │   
  │                                                  ask                                                   │   
  │                                                                                                        │   
  │                                                                                                        │   
  │                                                                                                    │   
  │                                                                                                        │   
  └────────────────────────────────────────────────────────────────────────────────────────────────────────┘   

On the next screen I unselected everything:

Package configuration                                                                                          
                                                                                                               
  ┌────────────────────────────────────┤ ca-certificates configuration ├────────────────────────────────────┐  
  │ This package installs common CA (Certificate Authority) certificates in /usr/share/ca-certificates. .   │  
  │ Please select the certificate authorities you trust so that their certificates are installed into       │  
  │ /etc/ssl/certs. They will be compiled into a single /etc/ssl/certs/ca-certificates.crt file.            │  
  │                                                                                                         │  
  │ Certificates to activate:                                                                               │  
  │                                                                                                         │  
  │    [ ] mozilla/ACEDICOM_Root.crt                                                                    ↑   │  
  │    [ ] mozilla/AC_Raíz_Certicámara_S.A..crt                                                         ▮   │  
  │                                                                                                         │  
  │                                                                                                         │  
  │                                                                                                     │  
  │                                                                                                         │  
  └─────────────────────────────────────────────────────────────────────────────────────────────────────────┘  

Then I ran: dpkg-reconfigure ca-certificates again:

root@orac:/root# dpkg-reconfigure ca-certificates 

On the first screen I selected ‘ask’:

  ┌───────────────────────────────────┤ ca-certificates configuration ├────────────────────────────────────┐   
  │ This package may install new CA (Certificate Authority) certificates when upgrading. You may want to   │   
  │ check such new CA certificates and select only certificates that you trust.                            │   
  │                                                                                                        │   
  │  - yes: new CA certificates will be trusted and installed;                                             │   
  │  - no : new CA certificates will not be installed by default;                                          │   
  │  - ask: prompt for each new CA certificate.                                                            │   
  │                                                                                                        │   
  │ Trust new certificates from certificate authorities?                                                   │   
  │                                                                                                        │   
  │                                                  yes                                                   │   
  │                                                  no                                                    │   
  │                                                  ask                                                   │   
  │                                                                                                        │   
  │                                                                                                        │   
  │                                                                                                    │   
  │                                                                                                        │   
  └────────────────────────────────────────────────────────────────────────────────────────────────────────┘   

On the next screen I selected everything:

Package configuration                                                                                          
                                                                                                               
  ┌────────────────────────────────────┤ ca-certificates configuration ├────────────────────────────────────┐  
  │ This package installs common CA (Certificate Authority) certificates in /usr/share/ca-certificates. .   │  
  │ Please select the certificate authorities you trust so that their certificates are installed into       │  
  │ /etc/ssl/certs. They will be compiled into a single /etc/ssl/certs/ca-certificates.crt file.            │  
  │                                                                                                         │  
  │ Certificates to activate:                                                                               │  
  │                                                                                                         │  
  │    [*] mozilla/ACEDICOM_Root.crt                                                                    ↑   │  
  │    [*] mozilla/AC_Raíz_Certicámara_S.A..crt                                                         ▮   │  
  │                                                                                                         │  
  │                                                                                                         │  
  │                                                                                                     │  
  │                                                                                                         │  
  └─────────────────────────────────────────────────────────────────────────────────────────────────────────┘  

Then magically everything was working again!

root@orac:/root# wget https://www.progclub.org/robots.txt
--2014-11-20 14:35:50--  https://www.progclub.org/robots.txt
Resolving www.progclub.org (www.progclub.org)... 67.207.128.184
Connecting to www.progclub.org (www.progclub.org)|67.207.128.184|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 364 [text/plain]
Saving to: 'robots.txt.1’

100%[=====================================================================>] 364         --.-K/s   in 0s      

2014-11-20 14:35:51 (8.54 MB/s) - 'robots.txt.1’ saved [364/364]