Archive for the ‘FreeBSD’ Category

Finding the time

Friday, April 21st, 2006 in FreeBSD

It seems I’ve never got enough time these days.

I’m a FreeBSD ports committer, but recently I’ve hardly done anything. All I’ve managed to do is keep my own ports updated. It’s quite frustrating because I want to be more involved. Then there’s the other projects like libstatgrab, they don’t even get a look in.

I blame the “day job”; if it’s not using my actual time it’s occuping my mind…

  • Share/Bookmark

Router rebuild (or, an excuse to play with IPv6?)

Sunday, March 19th, 2006 in Computing, FreeBSD

So recently my router decided it didn’t want to whir its fans anymore and consequently gave up on life. It’s a dual CPU machine and both CPU fans had managed to wedge. After fixing them and getting things running again I heard klunking noises coming from the front of the case; one of the disks in the mirror had failed. I rapidly copied everything off the remaining disk, but didn’t have a spare to hand. Next morning the remaining disk went too. I wasn’t having much luck really, but on the positive side I did have a full backup.

After a day or so of fiddling with hardware I got something that resembled a working machine; I’d gone through a stack of various old disks by this point, most of which were dead. For a while I’d been pondering a fresh install for the machine, so this was the perfect opportunity. I decided to think about what I wanted it to do – this is what I came up with.

  1. Obviously needs ADSL connection (via rather old, but working, USB modem)
  2. I’d quite like a VPN connection to work for various (but not all) work servers
  3. IPv6 routing both internally and out to the world
  4. Internal NIC with my private and public address ranges
  5. A second internal NIC for my wireless network
  6. A better firewall setup (I decided on PF in the end)

Rather predictably I decided to do all this with FreeBSD. Nothing exciting about the install, other than I used gmirror this time. I’m still trying to find the best RAID solution on FreeBSD. So far I think gmirror has impressed me most compared to ataraid and gvinum.

So most of the things I wanted the router to do are things it did before. The new things were the VPN, IPv6 and PF. Those are what I’ll write about.

Setting up the VPN was straightforward. I installed the net/pptpclient port, bunged the sample config and my credentials in /etc/ppp/ppp.conf, and knocked up a quick RC script (let me know if you’d like a copy). I also added specific entries to ppp.conf for the hosts I wanted to route over the VPN, rather than letting it route whole subnets.

Something worth noting about ppp is the -unitN flag. Using this you can make sure ppp always uses the same numbered tun device. For example, my VPN connection has -unit1 ensuring it is always tun1. This makes firewall configuration a bit more manageable.

I’ve also knocked up a slightly better RC script for starting the ADSL connection (compared to the one provided with net/pppoa) that checks the line is up before returning. This allows subsequent startup scripts to be pretty much guaranteed access to the Internet. Again, let me know if you’d like a copy.

The next task was getting the IPv6 connection going. I decided to use the BT IPv6 Tunnel Broker service. In retrospect this might not have been the best choice; it’s been down for the last few days. I’ll let you know how I decide to proceed with that, but I’m reluctant to change because I’ll get a whole new address range. Getting this set up was pleasantly simple, particularly when compared with my past experiences trying to set up an IPv6 tunnel. Upon registering I was allocated an IP range and given a FreeBSD-compatible script to bring the link up. I decided to set things up more permanently using the excellent guide on the FreeBSD Diary website and the details from the broker’s script.

Surprisingly with the relevant tunneling, routing, and advertisments going setting up clients was a doddle. On my FreeBSD desktop machine I turned on ipv6_enable in rc.conf and it sprang to life (after a reboot). Even on our Windows systems it was as simple as running “ipv6 install”.

This finally left PF. Now that I’ve finished setting it up I can happily say it seems much nicer than IPFW, but I won’t pretend the journey was easy. It took a while to get my head around the differences, the main one being last-match versus first-match rules. I still need to figure out some of the ALTQ stuff though; my last attempt left me throttling internal traffic to 0.5Mb/s :-)

  • Share/Bookmark

Upgrading from FreeBSD 5.2 to 5.5 (RELENG_5)

Wednesday, March 15th, 2006 in FreeBSD

I’ve been putting off upgrading my remotely hosted server from FreeBSD 5.2.1 for a while now, but after I started getting random problems I decided I had to move forward.

To start with there were a few reasons putting me off doing the upgrade:

  1. From version 5.3 of FreeBSD vinum was pretty much broken, so I’d need to switch to gvinum.
  2. The threading library changed from libc_r to libpthread.
  3. A handful of key libraries in /lib and /usr/lib had their versions bumped.

The first problem is pretty straightforward to work around. Changing “vinum_load” to “gvinum_load” in /boot/loader.conf, and changing “vinum” to “gvinum” in /etc/fstab was all it took. To be on the safe side I did a fsck of the filesystems after rebooting in to 5.5.

The other two problems can be dealt with after a reboot by rebuilding all the applications on the machine. This is as simple as running “portupgrade -af”, but I chose to do it in chunks so I could get key things up and running quickly. One trick I used was to touch a file in each directory under /var/db/pkg, which would get removed when the package was upgraded. This allowed me to easily see what I still needed to do.

Most of this information was gathered from looking at mailing list archives and most importantly from reading /usr/src/UPDATING.

So, what problems had I been having before this that forced me to do the upgrade?

  1. When piping a message to a command in mutt the pipe would never close. So, for example, piping to cat would display the message and then just hang.
  2. PHP would hang when applications used the PHP mail() function; this forked sendmail and piped the message to it. I suspect this is the same problem as above.
  3. Various things, most noticeably MySQL 5, would not compile. The problem was the recent libtool upgrade; libtool filters out -lc_r linker arguments.

After doing the upgrade these problems went away. The whole procedure was far less painful than I had been expecting.

Of course, the next challenge is upgrading to RELENG_6. But maybe I’ll leave that for another couple of years… :-)

  • Share/Bookmark