Tag Archives: Linux - Page 2

Changing the verbosity of wpa_supplicant on Ubuntu

Sometimes you need to change the log verbosity of wpa_supplicant for debugging purposes. First check which log verbosity you are currently running with.

ps -ef | grep wpa_supplicant | grep -v grep

-d represents verbose
-dd represents extra verbose

To change the log verbosity, edit /usr/share/dbus-1/system-services/fi.epitest.hostap.WPASupplicant.service and add -d or -dd as appropriate. Example:

[D-BUS Service]
Name=fi.epitest.hostap.WPASupplicant
Exec=/sbin/wpa_supplicant -u -d -f /var/log/wpa_supplicant.log
User=root

Restart NetworkManager and run the check again to see which log verbosity you are running with.

DV editing on Fedora

Recently, a friend asked me if I could copy her home videos from a miniDV tape onto a DVD. I said sure, OK, and if she lent me her camcorder I’d be able to get it done.

I’ve never actually used miniDV before, and I’ve only ever tried to process video on Linux a handful of times – and it’s usually been a disaster. Fedora seems to be a rock-steady platform for many tasks, although I would say it can be a bit lacking in high-quality media tools. I decided to give it a go on Fedora, but I was also prepared to fail over to Windows Movie Maker if necessary. Yuck.

So I searched the Fedora repos for the term DV, and came across a tool called Kino.

Kino is a non-linear DV editor for GNU/Linux. It features excellent integration with IEEE-1394 for capture, VTR control, and recording back to the camera. It captures video to disk in Raw DV and AVI format, in both type-1 DV and type-2 DV (separate audio stream) encodings.

Great – sounds like it will do the job. I plugged in the camcorder (a Sharp VL-NZ50) and fired up Kino. It immediately recognised the camera, no intervention necessary. Kino has full control of the tape – I was able to start, stop, rewind, and fast-forward the video. There was a single button to capture the entire tape to disk.

I found it made a new file for each time recording had been restarted on the camcorder. This might be ideal if you wanted to later burn a DVD with scene selection, but I wanted to create a single video.

After capture was complete, approximately one hour of video took up just over 12 GB – luckily I have crazy disks in my PC!

Kino also has features to export video in various formats. I simply exported as a single DV file (no re-encoding required).

Then I used DeVeDe to wrap the raw video file in a nice DVD format with a basic menu, and create an ISO image that I could simply burn to DVD.

I was very pleasantly surprised at how easy it was to get great results copying a miniDV tape to a DVD using Fedora.

My crazy partition setup

My requirements

When I built this computer back in January, I had carefully considered the RAID storage configuration. My requirements were basically:

  • Must dual boot Fedora and some flavour of Windows (unfortunately)
  • Fedora must have a redundant /home partition, as it holds my most important data
  • Windows must have a fast Media (aka /home) partition for my audio work
  • Would also be nice to have redundant OS partitions

The initial plan

So I decided to buy a pair of identical 320GB disks for the OS, a set of three 640GB disks for my media. My new motherboard had 4 SATA ports on an ICH10R controller, and 2 SATA ports on some other SATA controller.

It seemed best to set up a fakeraid RAID5 array across the 3 media disks in the ICH10R controller, and to let the OSs do their own thing on the 2 OS disks.

I split both of the OS disks in half to allow Linux software RAID1 (mirroring) across both of its RAID partitions, which would be mounted as /. The two partitions showed up to Windows as C: and D:. It is not possible to use Windows software RAID (aka Dynamic Disks) on a Windows boot partition so I installed Windows on C: and used D: for Program Files.

I created a RAID5 array across the 3 disks using the ICH10R RAID BIOS. Booting into Windows, it was immediately spotted so I cut the device in half and created drive J: for my media. Sorted – it was fast and worked nicely.

No such luck with Fedora 10 (the latest relkease at the time I built this PC). Anaconda, the Fedora installer, was not able to see the RAID partition – it only saw the three separate disks. Try as I might, I could not get round this. Kind of a showstopper.

Onto plan B

I figured that I could avoid using the ICH10R fakeraid by keeping the disks as 3 separate disks, cutting each in half and using three halves for Linux software RAID, and 3 halves for Windows Dynamic Disks. No such luck – Windows is only able to use a whole disk as a Dynamic Disk, and wasn’t able to share it with Linux. Bugger.

What I ended up with

Given that Windows and Linux cannot share a RAID array, whether it be software or pseudo-hardware, my only choice was to somehow divide up the disks.

The two OS disks were fine as they were; Windows was not using RAID but rather a more manual approach to having two disks (OS on C: and Program Files on D:).

Eventually I decided to give Windows two of the media disks and use them in a RAID0 (striped) Dynamic Disk for performance. This still gives approximately the performance of a 3-disk RAID5 array, but without the redunancy. I get around this by not keeping anything permanently on the RAID0 array. It is only used as a cache/buffer during audio work, and the audio files are primarily stored on my server via the network.

This left just a single disk for Fedora’s /home partition. It doesn’t tick the box of having redunandcy, but thanks to my hourly backup script this is less essential.

This diagram shows my current sub-optimal setup. Click for a bigger version. Windows partitions are in red and Linux in blue.

My partition setup

My partition setup

The future

Since setting up this PC, I happened across a blog post that seems to be the answer to my prayers. It’s a bit hacky, but it’s the only documented way I have seen of getting a dual-boot system to share an ICH10R array.

Next time I can be bothered to reinstall both OSs, I will write about it here.

Moving away from Windows

I’ve dabbled in Linux for several years now – I’ve looked after Linux servers at work and at home, and I’ve had a secondary desktop PC running some version of Fedora or other.

Two years ago I switched over my PC at work from Vista to Fedora, and I haven’t looked back. I didn’t have any particularly unusual requirements of a work PC; just an ssh client to configure servers. I actually prefer the GNOME desktop to a Windows desktop, and I’ve been getting on with Fedora very well indeed.

A couple of months after this I decided to install Fedora on my main PC at home. I felt that I’d learned enough about desktop Linux to be able to get it going satisfactorily. And while it’s all good and well having a secondary Linux PC, you get any good at it unless it’s your primary.

The transition went very smoothly on the whole – I got most of my hardware working and I was very pleased with the usability. But it still nags me that there are a handful of things that don’t work (either satisfactorily, or in some cases at all) on Linux, so I’m still forced to keep Windows.

Audio Editing

I’m a massive fan of home audio production. I play a few musical instruments and I own a set of decent recording equipment (see my Equipment List), including a Phonic Helix Board 24 firewire mixer. I purchased the mixer when I was still running Windows XP as my primary OS, and it worked very nicely. I used to use Syntrillium’s Cool Edit Pro (now Adobe Audition) and I got on very well with it.

When I moved over to Linux, I was keen to get the mixer working. There exists a project named ffado which strives to get firewire audio devices working on Linux. Unfortunately it doesn’t offer full support for Phonic devices. I did have it working at one point, although it was iffy at best, and a pain to configure each time I wanted to use it.

And while Ardour is a pretty decent piece of software, I had grown used to Cool Edit and Audition and didn’t see why I should move away. So I still boot into Windows for my audio work.

Gaming

This is one of the most common complaints from individuals who migrate to Linux. Their games don’t work.

I’m not a massive gamer anyway, but I did often enjoy spending the odd hour on Age of Empires or one of a number of driving games.

Of course some games work under wine, but many don’t. Of the ones that do, they often have missing features or oddities. So I still return to Windows for my occasional gaming.

Unfortunately, since upgrading my Windows installation from XP to Vista, I’ve discovered that Age of Empires doesn’t work on Vista either. A Microsoft game… on a Microsoft OS. Quality. I don’t play Age of Empires any more.

Scanning

For those who read my review of my slide scanner, you’ll recall that it doesn’t work on Linux (at all) or Vista (at all) so I had to use the XP installation on my laptop to scan in 3,000+ slides.

I also have a Canon LiDE 25 flatbed scanner which is detected and apparently works out of the box on Fedora – but unfortunately the colours are funny and broken. I haven’t found a way to remedy this so I still scan on Windows. At least it works on Vista on my desktop PC.

Other applications

And of course, there are always the rare occasions when you encounter the need to use a specific application that is Windows-only, or a file format that somehow ties you to Windows. Recently, I’ve needed to use Windows for…

  • Boson online testing environment – for practising Cisco exams
  • Noteworthy Composer – a MIDI editor that’s so good I’ve never found a Linux application that comes close. It does actually work quite nicely under wine with Timidity, but some screen fonts break.
  • TomTom Home – software for updating the maps on my sat nav
  • Vue – a 3D rendering suite that I occasionally play with

Summary

Overall, it’s a shame I can’t drop Windows completely. The vast majority of my needs are satisfied by Linux, and Fedora in particular has come a long way since I started using it at Fedora Core 5.

So who’s to blame for this dependence on Windows? In my opinion, the blame must lie with the application developers who write their applications and games for only one OS; the hardware vendors who don’t bother to write drivers for any but the most common OSs.

Linux developers work hard to provide drivers and applications for new devices and new file formats. Their task is made harder by manufacturers who stick to closed formats and proprietary devices. It’s a shame, because it ruins my life!

Windows file sharing on a Linux server

In this guide, we will set up your home Linux server to share files in a Windows-friendly format. This is ideal for interacting with Windows PCs on your network, or for generic appliances such as media streaming boxes.

First we install Samba:

[root@zeus ~]# yum install samba

Before we configure Samba, you need to think about who is going to need access to this. For an enterprise solution, clearly you’ll need some fancy authentication backend. For a home situation, it’s easier to set up a handful of users on your local system. Let’s assume you want to set up access for your wife, Sue.

[root@zeus ~]# useradd sue
[root@zeus ~]# passwd sue

So now Sue is set up on the server and has a password. Now we need to tell Samba that it’s OK to let system users get access to files. Open the file /etc/samba/smbusers. It should already have a couple of entries in, but you will need to add one for each user you want to use the file shares.

# Unix_name = SMB_name1 SMB_name2 ...
root = administrator admin
nobody = guest pcguest smbguest
sue = sue
tvuser = tvuser

We back up and open the Samba config file for editing:

[root@zeus ~]# cp /etc/samba/smb.conf /etc/samba/smb.conf.old
[root@zeus ~]# vim /etc/samba/smb.conf

Delete all the contents of smb.conf. For now just add the contents of the global section below, but don’t close your editor yet – we need to define the shares.

[global]
dns proxy = no
log file = /var/log/samba/%m.log
cups options = raw
server string = Samba Server
socket options = TCP_NODELAY IPTOS_THROUGHPUT
username map = /etc/samba/smbusers
hosts allow = 192.168.0. 127.
max log size = 50

Now for some examples of how to define shares. The homes example automatically connects each user to their home directory, e.g. /home/sue. If you want this, keep it. If you don’t use your Linux home directories, don’t bother adding this section.

[homes]
comment = Home Directories
browseable = no
writeable = yes

This next one is an example of a media share for a TV streaming box or similar. All users can read it; only sue can write to it.

[media]
path = /media/public
writeable = yes
public = yes
write list = sue

This one is a private share only accessible by sue

[private]
path = /media/private
writeable = yes
valid users = sue

After you’ve defined your shares, save the config, start the service and set it to run on boot

[root@zeus ~]# service smb start
[root@zeus ~]# chkconfig smb on

Building a Linux home server, gateway, firewall & router

Overview

This guide will attempt to show you how to build your own home server. I’ve included sections that I believe would be useful to home users, without over-complicating things. I’ve tried to make this guide accessible enough for people who are new to Linux, too.

We will assume that the core function of this server will be a gateway/firewall/router for your home network. If this is what you want, read on. However, if you wanted to build just a regular web/file/etc server, don’t follow this guide – it only works if the server is acting as a gateway for your LAN.

The goal of building a gateway/firewall/router relies upon a handful of other functions, such as DHCP and DNS. At the end of this article, there are also several optional extra features that you can add later.

Hardware

So, you’ve decided to build a home Linux server. What hardware do you need? Well, let’s look at each type of resource in turn:

Processor

Literally any processor will do for most applications. Even if you’re using your Internet connection heavily, the CPU will not be pushed at all. The only task in the list above that will even begin to push your CPU might be running some sort of PHP website.

Memory

Again, for a simple home server you don’t need a lot of RAM. My fully loaded server at home is currently using 309MB of its memory. For a basic server setup you could get away with 256MB but I’d recommend 512MB or more if you’re going to run a web server. The more you have, the better, as Linux will use it for caching frequently used files.

Disks/storage

A fully loaded CentOS server will probably need less than 3GB of disk space. As memory cards are so cheap these days, you could install to a CompactFlash card for a quieter server. The only thing that might take up space is a large website, or if youdecide to run a file server.

Network

Any old network connection will do for the Internet-facing side of your server. Whatever you have, it’ll be faster than your broadband/cable connection. The important network connection is the one that serves your private network. If you’re running a file server you might prefer to have a gigabit ethernet connection.

So now you know that a Linux home server doesn’t really need a lot of welly. It’s an ideal use for an old/spare desktop PC. The main problem with using an old PC is that they are noisy, and ineffecient at using power. Most older desktop PCs use around 100W. Very, very roughly, 1W for one year comes to around £1. So that’s £100/year running costs!

Depending on your house and the server’s location, the noise of an old PC might get on your nerves. It certainly does in my house. You might like to think about using a laptop (with an additional USB network adapter) or even something smaller and quiet like a Mac Mini or an EeeBox. According to Google, a Mac Mini only uses about 23W, too.

Choosing the OS

All Linux distributions are not equal. They vary greatly and it’s impossible to say that one is “better” than another. In this guide, I will be writing about building a server that runs CentOS. CentOS is a clone of Red Hat so the instructions should work on that too, as well as the closely-related Fedora. If you’re new to Linux, my advice would be to try CentOS unless you have a reason for installing something else.

Installing the OS

This is pretty straightforward on most modern Linux distributions. Just download and burn the CD or DVD, boot from it in your new server, and follow the instructions. If your server doesn’t have a CD drive, some distributions provide images designed to boot from a USB flash disk.

The most important thing to add here is that you should install the bare minimum of packages. Untick the boxes for everything – we will add what we need later.

Don’t forget the root password that you set – you’ll need that in a minute. After the installer has done its magic, wait for the server to restart and log on using the root username and password.

Setting up your network

Before we can get much further, the new server needs an Internet connection. If you have an existing home network, plug it into that. This guide assumes that you have a cable modem with an Ethernet connection into the server.

The basic network setup

The basic network setup

This diagrams shows the basic layout of your network. The modem plugs into the server’s Ethernet port. On CentOS and related distributions, Ethernet ports are known by the system as eth0, eth1 and so on. You need to find out which port is which on your server. The best way of doing this is to simply plug the modem into whichever port takes your fancy. Assuming you already logged onto your server, simply type ipconfig at the terminal, as shown below:


[root@zeus ~]# ifconfig
eth1      Link encap:Ethernet  HWaddr 00:19:5B:5D:21:B0
inet addr:84.x.y.z  Bcast:84.255.255.255  Mask:255.0.0.0
inet6 addr: fe80::219:5bff:fe5d:21b0/64 Scope:Link
UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
RX packets:17643164 errors:0 dropped:0 overruns:0 frame:0
TX packets:16261842 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:154049552 (146.9 MiB)  TX bytes:943414355 (899.7 MiB)
Interrupt:17 Base address:0xa000

If you have two Ethernet adapters, there will be entries for eth0 and eth1. One of them should have an “inet addr”, also known as an IP address. This one is then your Internet-facing network adapter. Make a note of it! Throughout the rest of this guide, I assume that eth0 faces the private network and eth1 faces the Internet.

Just to make sure that everything is alive on your server, test the connection:

[root@zeus ~]# ping -c4 www.google.com
PING www.l.google.com (209.85.229.147) 56(84) bytes of data.
64 bytes from ww-in-f147.google.com (209.85.229.147): icmp_seq=1 ttl=244 time=27.2 ms
64 bytes from ww-in-f147.google.com (209.85.229.147): icmp_seq=2 ttl=244 time=26.5 ms
64 bytes from ww-in-f147.google.com (209.85.229.147): icmp_seq=3 ttl=244 time=26.8 ms
64 bytes from ww-in-f147.google.com (209.85.229.147): icmp_seq=4 ttl=244 time=27.3 ms

--- www.l.google.com ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 4030ms
rtt min/avg/max/mdev = 26.516/26.920/27.331/0.332 ms

If you get 4 responses, all is well. If not, go back and fix it. Yep, it’s that kind of guide ;) Now let’s move on to…

Setting up the basics

First things first, we need to update the packages that were installing when you installed CentOS from the CD.

[root@zeus ~]# yum -y update

This could take some time, so just let yum work its magic. After this, we need to install a few more packages to perform core functions.

[root@zeus ~]# yum -y install bind bind-chroot dhcp hddtemp vim nano

Disable remote root login:

[root@zeus ~]# echo "PermitRootLogin no" >> /etc/ssh/sshd_config

I recommend you reboot after this:

[root@zeus ~]# init 6

Now we need to set up the other network connection – the one that serves your private LAN. For this we will use the private range of IP addresses – the ones that start 192.168.x.y.
For the first time since building the server, you need to use a text editor. I use vim but nano is a good one for beginners. Google for comparisons of various editors if you’re not sure. We need to edit the file the controls the private network connection. Double-check that you’ve chosen the right eth before you type this command:

[root@zeus ~]# vim /etc/sysconfig/networking/devices/ifcfg-eth0

There are a few entries in this file that must be changed – but there are also some that must be kept the same. Set the following ones to these values:


BOOTPROTO=none
IPADDR=192.168.0.1
ONBOOT=yes
NETMASK=255.255.255.0

Don’t change DEVICE, HWADDR, or TYPE. Anything else can be safely deleted. Save your changes when you’re happy. To make this change take effect, type

[root@zeus ~]# service network restart

Just to make sure it worked, try ipconfig again and make sure that eth0 has an IP address of 192.168.0.1 and eth1 has some random other IP address.

Routing & Firewall

The routing (sending traffic to the right place, either inbound or outbound) and firewalling (filtering traffic) are controlled by iptables. First we need to enable the ability to route traffic between the two network interfaces:

[root@zeus ~]# echo 1 > /proc/sys/net/ipv4/ip_forward
[root@zeus ~]# echo 1 > /proc/sys/net/ipv4/tcp_syncookies

And we also need to make sure this ability is switched on every time you start the server:

echo "echo 1 > /proc/sys/net/ipv4/ip_forward" >> /etc/rc.local
echo "echo 1 > /proc/sys/net/ipv4/tcp_syncookies" >> /etc/rc.local

Now for the tricky part. Writing an iptables config that protects the server while allowing the Internet through to the computers on your network. I will include a basic config here which should be enough to get you going. It allows all computers on your network to access the Internet, but does not allow unsolicited incoming traffic. It also open up your server to run as a web server. If this isn’t what you want, delete the two lines that mention 80 and 443 from the tcp_wan_inbound section. If you want to customise it a little, try playing with the Easy Firewall Generator for iptables.

If you use this exemplar config, open the file /etc/sysconfig/iptables for editing. Delete all the contents, and replace them with the following.

*mangle :P REROUTING ACCEPT [30:2184]
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [219:28347]
:OUTPUT ACCEPT [21:2964] :P OSTROUTING ACCEPT [427:80322]
COMMIT
*nat :P REROUTING ACCEPT [0:0] :P OSTROUTING ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A POSTROUTING -o eth1 -j MASQUERADE
COMMIT
*filter
:INPUT DROP [0:0]
:FORWARD DROP [0:0]
:OUTPUT DROP [4:912]
# DEFINE VARIOUS CHAINS
:bad_packets - [0:0]
:bad_tcp_packets - [0:0]
:icmp_packets - [0:0]
:tcp_lan_inbound - [0:0]
:tcp_wan_inbound - [0:0]
:tcp_outbound - [0:0]
:udp_lan_inbound - [0:0]
:udp_wan_inbound - [0:0]
:udp_outbound - [0:0]
:syn_flood - [0:0]
# ALLOCATE TRAFFIC TO CHAINS
-A INPUT -i lo -j ACCEPT
-A INPUT -j bad_packets
-A INPUT -d 224.0.0.1 -j DROP
-A INPUT -s 192.168.0.0/255.255.255.0 -i eth0 -j ACCEPT
-A INPUT -d 192.168.0.255 -i eth0 -j ACCEPT
-A INPUT -i eth0 -p udp -m udp --sport 68 --dport 67 -j ACCEPT
-A INPUT -i eth0 -p udp -m udp --dport 53 -j ACCEPT
-A INPUT -i eth1 -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -i eth0 -p tcp -j tcp_lan_inbound
-A INPUT -i eth1 -p tcp -j tcp_wan_inbound
-A INPUT -i eth0 -p udp -j udp_lan_inbound
-A INPUT -i eth1 -p udp -j udp_wan_inbound
-A INPUT -i eth1 -p icmp -j icmp_packets
-A INPUT -i eth1 -p tcp --syn -j syn_flood
-A INPUT -m pkttype --pkt-type broadcast -j DROP
-A FORWARD -j bad_packets
-A FORWARD -i eth0 -p tcp -j tcp_outbound
-A FORWARD -i eth0 -p udp -j udp_outbound
-A FORWARD -i eth0 -j ACCEPT
-A FORWARD -i eth1 -m state --state RELATED,ESTABLISHED -j ACCEPT
-A OUTPUT -p icmp -m state --state INVALID -j DROP
-A OUTPUT -s 127.0.0.1 -j ACCEPT
-A OUTPUT -o lo -j ACCEPT
-A OUTPUT -s 192.168.0.1 -j ACCEPT
-A OUTPUT -o eth0 -j ACCEPT
-A OUTPUT -o eth1 -j ACCEPT
-A bad_packets -s 192.168.0.0/255.255.255.0 -i eth1 -j DROP
-A bad_packets -m state --state INVALID -j DROP
-A bad_packets -p tcp -j bad_tcp_packets
-A bad_packets -j RETURN
-A bad_tcp_packets -i eth0 -p tcp -j RETURN
-A bad_tcp_packets -p tcp -m tcp ! --tcp-flags FIN,SYN,RST,ACK SYN -m state --state NEW -j DROP
-A bad_tcp_packets -p tcp -m tcp --tcp-flags FIN,SYN,RST,PSH,ACK,URG NONE -j DROP
-A bad_tcp_packets -p tcp -m tcp --tcp-flags FIN,SYN,RST,PSH,ACK,URG FIN,SYN,RST,PSH,ACK,URG -j DROP
-A bad_tcp_packets -p tcp -m tcp --tcp-flags FIN,SYN,RST,PSH,ACK,URG FIN,PSH,URG -j DROP
-A bad_tcp_packets -p tcp -m tcp --tcp-flags FIN,SYN,RST,PSH,ACK,URG FIN,SYN,RST,ACK,URG -j DROP
-A bad_tcp_packets -p tcp -m tcp --tcp-flags SYN,RST SYN,RST -j DROP
-A bad_tcp_packets -p tcp -m tcp --tcp-flags FIN,SYN FIN,SYN -j DROP
-A bad_tcp_packets -p tcp -j RETURN
-A icmp_packets -p icmp -f -j DROP
-A icmp_packets -p icmp -m limit --limit  2/s --limit-burst 5 -j ACCEPT
-A icmp_packets -p icmp -m icmp --icmp-type 8 -j ACCEPT
-A icmp_packets -p icmp -m icmp --icmp-type 11 -j ACCEPT
-A icmp_packets -p icmp -j RETURN
-A tcp_wan_inbound -p tcp -m tcp --dport 80 -j ACCEPT
-A tcp_wan_inbound -p tcp -m tcp --dport 443 -j ACCEPT
-A tcp_wan_inbound -i eth1 -p tcp --dport 22 -m state --state NEW -m recent --set --name SSH
-A tcp_wan_inbound -i eth1 -p tcp --dport 22 -m state --state NEW -m recent --update --seconds 60 --hitcount 4 --rttl --name SSH -j DROP
-A tcp_wan_inbound -p tcp -m tcp --dport 22 -j ACCEPT
-A tcp_wan_inbound -p tcp -j RETURN
-A tcp_outbound -p tcp -j ACCEPT
-A udp_lan_inbound -p udp -j RETURN
-A udp_wan_inbound -p udp -m udp --dport 137 -j DROP
-A udp_wan_inbound -p udp -m udp --dport 138 -j DROP
-A udp_wan_inbound -p udp -j RETURN
-A udp_outbound -p udp -j ACCEPT
-A syn_flood -m limit --limit 1/s --limit-burst 3 -j RETURN
-A syn_flood -j DROP
COMMIT

After you’re done inserting the firewall rules, you must apply them:

[root@zeus ~]# service iptables restart

DHCP

Let’s move on to setting up DHCP. This is a service that dynamically allocates IP addresses to other computers on your network, so they will automatically work when you connect them. Open dhcpd.conf in your editor:

[root@zeus ~]# vim /etc/dhcpd.conf

And make it look like this:

ddns-update-style interim;
ignore client-updates;
subnet 192.168.0.0 netmask 255.255.255.0 {
option routers 192.168.0.1;
option subnet-mask 255.255.255.0;
option domain-name-servers 192.168.0.1;
option ip-forwarding off;
range dynamic-bootp 192.168.0.100 192.168.0.254;
default-lease-time 21600;
max-lease-time 43200;
}

Save it, close it, and let’s start the DHCP service.

[root@zeus ~]# service dhcpd start

Assuming that all goes OK, we also need to tell DHCP to start every time you turn the server on:

[root@zeus ~]# chkconfig --level 2345 dhcpd on

DNS

Now we come to set up DNS, so the clients on your network can look up domain names (e.g. google.com) and resolve them to IP addresses (e.g. 209.85.227.147).

The config here sets up your server as a DNS caching forwarder. Every time a computer on your network looks up a domain name, the server asks the upstream DNS servers (provided by your ISP), forwards the reply to the client and remembers the answer so next time a different client asks for the same domain name, the server can respond without wasting time by referring to the upstream DNS servers.

So first, you need to know the IP address(es) of the DNS servers provided by your ISP. As your server is already online and working, it should already know at least one DNS server, and you can make it tell you like this:

[root@zeus ~]# cat /etc/resolv.conf
nameserver 83.146.21.6
nameserver 212.158.249.5

There may be one or more nameservers (DNS servers), and there may be other lines too. But all we want for now is to write down the IP addresses of all the DNS servers. We back up and edit the DNS config file to set these options:

[root@zeus ~]# cp /var/named/chroot/etc/named.conf /var/named/chroot/etc/named.conf.old
[root@zeus ~]# vim /var/named/chroot/etc/named.conf

Make it look like this, replacing my fictitious 1.1.1.1 and 2.2.2.2 with the IP addresses of your own DNS servers.

options {
listen-on port 53 { 192.168.0.1; 127.0/8; };
listen-on-v6 port 53 { ::1; };
directory "/var/named";
dump-file "/var/named/data/cache_dump.db";
statistics-file "/var/named/data/named_stats.txt";
memstatistics-file "/var/named/data/named_mem_stats.txt";
allow-query { 192.168.0.0/24; 127.0/8; };
recursion yes;
forwarders { 1.1.1.1; 2.2.2.2; }; #IP of upstream ISP nameservers
forward only; #rely completely on our upstream nameservers
};

When you are done, restart the service and set it to start on boot:

[root@zeus ~]# service named restart
[root@zeus ~]# chkconfig --level 2345 named on

Optional steps

So, now you should find that you are able to simply connect a computer to your private network and it should pick up an IP address and all the details of your DNS system and just work automatically on the Internet. It’s worth restarting your server too, just to make sure it starts all of the services when it loads up (otherwise you’ll wonder why there’s no Internet after a power cut!).

I have also written some guides for setting up other, more advanced features for your home server, including:

More on Ubuntu Netbook Remix

For those of you who read my earlier post, Ubuntu Netbook Remix on an EeePC 701, you’ll know that I installed Ubuntu Netbook Remix (UNR) on my other half’s EeePC 701. The clue is very much in the name.

Initially I was sceptical of using it myself. I’m a Red Hat / CentOS / Fedora fan. All my home machines are Fedora; my work PC is Fedora and all the servers I look after are CentOS. My own EeePC 901 was, until yesterday, running Fedora too. I had no real gripes about Fedora on my 901, except the boot time, which was acceptable but slightly slow.

But after seeing how well thought-out UNR is, I was tempted to give it a shot. Despite being a Red Hat fan, I eventually decided that I didn’t actually use my 901 for anything Red Hat specific – basically I use it as a web browser, email client, MSN/AIM client and ssh terminal. So I’m not tied to any particular OS at all.

Installation from a Live USB was a breeze. My 901 has a so-called 20GB SSD, which is actually a 4GB SSD and a 16GB SSD. I’ve also added a 16GB SDHC card. In the end I set up my partitioning like:

  • 4GB SSD: /var
  • 16GB SSD: /boot, /
  • 16GB SDHC: /home

In short, this gives me 16GB for the OS, and 16GB for my stuff. This is a pretty healthy amount for a netbook, and more than I’m likely to use in a hurry.

So what are my first thoughts on this Debian-based OS that I’m supposed to hate?

Well, it’s pretty good. The first thing I notice is how polished everything is. The login screen, the custom menu, the theme… UNR looks like a saleable OS. The UNR custom menu looks smart and is easy to use on a netbook screen – 9″ in my case, and 7″ in Hana’s.

I was able to configure my installation the way I like it without using a terminal. Of course, the terminal is there if I want it but I think this distro marks a new era – a Linux distribution that can be installed, configured and used without the user having to use the terminal. I’ve already said that my non-geek girlfriend Hana is using UNR and finds it great. I’d also be happy to recommend it to other non-technical users.

Well done Ubuntu!

Ubuntu Netbook Remix on an EeePC 701

This morning I tried Ubuntu Netbook Remix (UNR) for the first time. My first impression was that it’s very polished and usable by non-geeks.

I’m not an Ubuntu user myself; I use Fedora on all my machines – including my EeePC 901. But my other half, Hana, has an EeePC 701. She’s not a geek, and she just wants something that will work for her. She’s seen XP on a 701 and agreed the 7″ screen isn’t really up to scratch.

Recently we tried gOS on the 701. It’s Ubuntu based and very friendly. It’s well laid out and easy to use. Hana used it for a couple of months and got on well with it. The main problem was that wireless never quite worked properly, and using an Ethernet cable kind of spoils the point of a tiny laptop,

So this morning I swapped gOS for UNR. The installation was painless, and first boot went without hitch. The main snag I ran into on the 701 was that the animated menus made the whole system slow down. This turned out to be a bug which was easily remedied by installing two packages.

It’s early days yet – the system has only been functional for about an hour and Hana hasn’t used it yet. I’ll post again with more comments on UNR when we’ve had a chance to play with it.

Getting old

I realised I was getting old earlier when I was listening to an internet radio station and a trance tune came on. My first thought was that my ALSA server had gone wrong, what with the jittering and odd noises.

Back in my day, trance was tuneful, I’m sure of it…