tech notes

April 28, 2008

Running OpenBSD 4.2 on the Soekris net 5501

Filed under: bsd — admin @ 2:25 pm

soekirs net 5501Why OpenBSD?

A bit of explanation first. I did some test installations of FreeBSD 6.x on an older Soekris net 4801 box and found out, to my surprise, that it wasn’t running as fast and stable as OpenBSD. Additionally, comparing to OpenBSD, installing FreeBSD over PXE on Soekris was a bit of a nightmare.

Instructions

Console connection

As Soekris boxes don’t come with VGA cards the only way to access and configure them is through a console cable. I’m using a standard console cable connected to my FreeBSD box. The only non standard thing is the default console speed which in Soekris is set up to 19200. So to get it working under FreeBSD you need to do:

# cu -s 19200 -l /dev/cuad0

If you reboot your Soekris now you should be able to see something like:

comBIOS ver. 1.33  20070103  Copyright (C) 2000-2007 Soekris Engineering.
net5501
0512 Mbyte Memory                        CPU Geode LX 500 Mhz
Pri Mas  CF CARD 2GB                     LBA Xlt 983-64-63  1982 Mbyte

Slot   Vend Dev  ClassRev Cmd  Stat CL LT HT  Base1    Base2   Int

-------------------------------------------------------------------
0:01:2 1022 2082 10100000 0006 0220 08 00 00 A0000000 00000000 10
0:06:0 1106 3053 02000096 0117 0210 08 40 00 0000E101 A0004000 11
0:07:0 1106 3053 02000096 0117 0210 08 40 00 0000E201 A0004100 05
0:08:0 1106 3053 02000096 0117 0210 08 40 00 0000E301 A0004200 09
0:09:0 1106 3053 02000096 0117 0210 08 40 00 0000E401 A0004300 12
0:20:0 1022 2090 06010003 0009 02A0 08 40 80 00006001 00006101
0:20:2 1022 209A 01018001 0005 02A0 08 00 00 00000000 00000000
0:21:0 1022 2094 0C031002 0006 0230 08 00 80 A0005000 00000000 15
0:21:1 1022 2095 0C032002 0006 0230 08 00 00 A0006000 00000000 15

1 Seconds to automatic boot.   Press Ctrl-P for entering Monitor.

Intel UNDI, PXE-2.0 (build 082)

Copyright (C) 1997,1998,1999  Intel Corporation

VIA Rhine III Management Adapter v2.43 (2005/12/15)

CLIENT MAC ADDR: 00 00 24 DE AD AA

And your system will start a PXE boot. At this point, copy your MAC address (in this case 00:00:24:DE:AD:AA) as you may need it in the next step.

DHCP

I’m using a ports based installation of isc-dhcp3-server running on FreeBSD.

To boot your soekris box over PXE you need to set up a DHCP server to send tftp server details. I’m doing it by creating a separate host configuration for my soekris.

host soekris {
hardware ethernet 00:00:24:DE:AD:AA;
option tftp-server-name "10.0.0.1";
option root-path "10.0.0.1:/tftpboot";
next-server 10.0.0.1;
filename "pxeboot";
option    routers 10.0.0.1;
}

What it does is it tells the Soekris box that it should use a tftp server at 10.0.0.1 and fetch and run the pxeboot file from it.

TFTP

I’m running a tftp server on my FreeBSD on 10.0.0.1. To set it up just comment out this line in your /etc/inetd.conf:

tftp dgram udp wait root /usr/libexec/tftpd tftpd -l -s /tftpboot

Now you have to enable inetd in your /etc/rc.conf and start it (/etc/rc.d/inetd start)

At this point you have your tftp ready, now it’s time to prepare all the files needed to install OpenBSD. Mount your OpenBSD installation CD (or an ISO of it) and do the following on your TFTP server:

# cd /tftpboot
# mkdir 4.2 etc
# cp /mnt/cdrom/4.2/i386/bsd.rd /mnt/cdrom/4.2/i386/pxeboot .
# cp -Rv /mnt/cdrom/4.2/i386 4.2/

and finally create a /tftpboot/etc/boot.conf file with the following content:

set tty com0
stty com0 19200
set image /4.2/i386/bsd.rd

Installation

At this moment, after rebooting your Soekris it should fetch OpenBSD kernel image and ram disk and start the installation process. Follow it as you would do normally ( http://openbsd.org/faq/faq4.html ) with only these exceptions:

  • do not create a swap partition if you are using a CF card, unless you really know what you’re doing.
  • answer yes when asked “change the default console to com0″
  • answer 19200 when asked “Which one should com0 use?” about the speed of your com0 console

after installing all required packages and finishing the whole process you should have a working OpenBSD installation on your Soekris.

There is only one last thing to be done. By default Soekris boots via PXE first and then uses its primary IDE drive (your CF card in this case) . You can either comment out the soekris section in your DHCP configuration or change the default boot order in Soekris BIOS. To do that reboot the Soekris, hit ctrl+p to enter Monitor and type:

set BootDrive=80 81 F0 FF

April 10, 2008

IPsec synchronization with OpenBSD

Filed under: bsd — admin @ 12:03 am

The goal is to have two IPsec hubs, one master and one slave, where the slave can take over when the master goes down and it can do it without losing all established IPsec tunnels.

With OpenBSD it’s really straight forward, as all features needed to do it are in the base system. They are: carp, pfsync and sasyncd.

We start with two hosts - master with IP 192.168.1.1 and slave with 192.168.1.2.

First we set up carp so both servers will share one IP address. This IP will be used as the end point for establishing all IPsec tunnels.

master# echo “inet 192.168.1.10 255.255.255.0 192.168.1.255 vhid 1 pass yoursecretpasswd” > /etc/hostname.carp0

and

slave# echo “inet 192.168.1.10 255.255.255.0 192.168.1.255 vhid 1 pass yoursecretpasswd advskew 100″ > /etc/hostname.carp0

We also need pfsync, not only to synchronize pf states but we will also need it to synchronize SA replay counters. Ideally pf states should be synchronized over a dedicated interface and a crossover cable (in case of 2 failover boxes).

master# echo ” up syncdev rl0 syncpeer 172.16.31.2″ > /etc/hostname.pfsync0
slave# echo “up syncdev rl0 syncpeer 172.16.31.1″ > /etc/hostname.pfsync0

And now it’s time to set up sasyncd. In this simple configuration sasyncd only needs information about peer name, carp interface which state it will follow (acting as the master sasyncd if the carp interface is in MASTER state or as a slave when the carp interface is in BACKUP state) and a shared key which will be used to encrypt SA updates.

Edit /etc/sasyncd.conf , on master:

peer 172.16.31.2
interface carp0
sharedkey 0×078433394b762e8c526d5921768e633676a8733db242c7ddd49993c0dca5092a

use openssl rand -hex 32 to generate your shared key.

and on slave:

peer 172.16.32.1
interface carp0
sharedkey 0×078433394b762e8c526d5921768e633676a8733db242c7ddd49993c0dca5092a

Now on both servers enable sasyncd by adding sasyncd_flags=”" to your /etc/rc.conf.local files.

At this moment you can either reboot your servers to get everything started or do

# sh /etc/netstart
# sasyncd

Test it on your slave box, after a second you should be able to see exactly the same flows and SAD entries with ipsecctl -sa

Powered by WordPress