Thursday, 19 September 2013

Disable DNSMASQ on KVM host

I have a fleet of servers with bridged, static IP's running as KVM guests. These servers do not require DHCP yet KVM by default starts up dnsmasq regardless.

Normally this is not an issue but I just so happened to need dnsmasq for DNS on one of the KVM hosts and it would refuse to start due to it being already invoked by libvirt.

You can't just disable the libvirt dnsmasq because it seems required for any virtual network that is active. You can however disable the unused virtual network which has the same effect.

# virsh net-destroy default
# virsh net-autostart --disable default



Then you can configure dnsmasq by editing /etc/dnsmasq.conf and it should work normally.

Wednesday, 18 September 2013

SOLVED: nss_getpwnam errors in CentOS 6

I've been getting an annoying error in the system logs for newly installed CentOS 6 servers with NFS4 configured.  

rpc.idmapd[6004]: nss_getpwnam: name 'root@localdomain' does not map into domain 'mydomain.net'

This error doesn't appear to cause any issues but I don't like that sort of thing constantly spamming my logs so I wanted to fix it. So, it turns out that RHEL6/CentOS6 has a dodgy default configuration for the rpcidmapd service that you need to fix.

Edit this file:

 # vi /etc/idmapd.conf

Find the setting for "Domain" which is incorrectly set to an edu domain and change it so that it is like this:

 Domain = localdomain

Restart the service:

 # service rpcidmapd restart

After this you should no longer get the above error in your system log.

Tuesday, 17 September 2013

HOWTO: Send mail via a mailhub in CentOS

To do this I use ssmtp which is far easier to configure for a simple task than sendmail or even postfix. If you are intending to build a full mail server then this is not the correct way to do so, I only want my CentOS server to be able to send out mail alerts, not act as a full on mail hub.

So, let's get down to it, I will be starting from a "minimal" install of CentOS 6. You must also ensure that your host has a FQDN on your network otherwise your mail hub will refuse to relay any emails from it.

Firstly, as is often the case the standard CentOS repos are a lot more sparse than those in Debian/Ubuntu land so we need to add a Fedora repository:

rpm -Uvh http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

Note: The above is for CentOS 6 x64, if you are using CentOS 5 or a 32 bit OS then modify the above line accordingly. For example, for CentOS 5/32 you would browse to this URL: http://download.fedoraproject.org/pub/epel/5/i386
and then find the epel package at that address e.g. epel-release-5-4.noarch.rpm


We will need to remove postfix

# yum remove postfix

Now install SSMTP and mailx

# yum install ssmtp mailx

Backup the default ssmtp config file

# cp /etc/ssmtp/ssmtp.conf /etc/ssmtp/ssmtp.conf.default
# vi /etc/ssmtp/ssmtp.conf


Find the mailhub=mail line and change it to the hostname of your main mail server:

e.g. mailhub=mail.tuxnetworks.com

You can now send a test email:

mail -s TEST me@mydomain.com
(type in some text and press ctrl+d when done)

You can check how things went in your mail log:

# tail -f /var/log/maillog

If all went well you should see something like this:

Sep 17 09:19:20 myhost sSMTP[31558]: Sent mail for root@myhost.tuxnetworks.com (221 2.0.0 Service closing transmission channel) uid=0 username=root outbytes=510

If you see that and your email arrives then congratulations, you are done.

Tuesday, 10 September 2013

CentOS 6 minimal does not install cron

To install it:

# yum install crontabs

Don't forget to turn it on and start up on reboot:

# service crond start
 # chkconfig crond on


Here are some other things you might want to install after doing a CentOS "minimal" install.

Wednesday, 4 September 2013

I Like Pi

So, I finally got myself a Raspberry Pi to play around with and here are some things that I've found.

The first thing I discovered is that there is no point powering the Pi up without a properly prepared SD card. I got mine thinking I had a spare SD card kicking around but when the Pi arrived I couldn't find one. So, I figured I could at least hook everything else up and at least get a POST screen but no, you get nothing, but a red led and a blank screen from your Pi without a properly imaged SD card.

So, I went out and bought a 4GB card for a whopping $6 and downloaded the standard "Raspbian" image based on Debian "Wheezy".

A quick dd later and the card was prepared, inserted and booted up.

Now, what I really want is to run xbox media center so jumped straight in and tried apt-get install xbmc but got an unresolvable dependency error installing xbmc-bin.

Not to worry, I already knew that the proper way to do this is to download the Raspbmc image which has all that stuff already set up for you, so off to their website I went.

On the Raspbmc site you are given a choice, 1) download a small netinstall image which will "download the most up to date version of xbmc" or 2) download the full image which they don't recommend.

So, I took option 1 re-imaged my SD card and booted the Pi up again. The script then went to work and started downloading and install a bunch of things. This took some time because I have a bad Internet connection.

Eventually it finished and the Pi rebooted but got stuck in a crash/restart loop repeatedly showing a message "Relax, xbmc will restart shortly" over and over and over and over.

So, off to google I go and found somebody who had the same problem and "fixed it" by downloading the full image and installing that instead. I'm usually not a fan of net installers so I found myself asking why I'd gone that route in the first place. Oh well, no matter.

So next step, download the full image instead.