Articles

Adventures in Red Hat Enterprise Linux, CentOS, Fedora, OpenBSD and other open source solutions.

Bash completion for Mac OS X

If your are using the Terminal application of your Apple computer running Mac OS X, try bash programmable completion. It allow you to use the TAB key more often, for example in scp: (If you are using ssh-keys.)

$ scp shell01:/etc/pa
/etc/pam.d/         /etc/pam_smb.conf   /etc/passwd
/etc/pam_pkcs11/    /etc/pango/         /etc/passwd-
$ scp shell01:/etc/pa

The steps to start using this great utility are these:

  1. Download the bash programmable completion .tar.gz file.
  2. In a Terminal on your Apple, untar it. (tar -xvf bash-completion-20060301.tar
  3. Copy the bash_completion shell-script to /etc (sudo cp bash_completion/bash_completion /etc)
  4. Add the bash complation to your login script. (echo ". /etc/bash_completion" >> ~/.profile)
  5. Start a new terminal and see the result!

Using DynDNS for iPhone OS 3.0 without crontab but with launchd

Apple iPhone OS 3.0 does not have crontab anymore. You are supposed to use launchd's facilities to execute something at a scheduled interval. Here is an example of a simple script to update the IP-address at DynDNS.org.

The script /var/mobile/update-dyndns.org contains:

#!/bin/sh

host="your-host-name.dyndns.org"
user="your-username"
pass="your-password"

oldip=$(cat /tmp/ip)
wget -o /dev/null -O - http://ip.serverchief.com/ > /tmp/ip
ip=$(cat /tmp/ip)

if [ "$oldip" != "$ip" ] ; then
echo -n "$(date) "
echo $(/usr/local/bin/wget -O - "http://$user:$[email protected]/nic/update?hostname=$host&wildcard=NOCHG&bacakmx=NOCHG"  2> /dev/null)
fi

The file /var/LaunchDaemons/org.dyndns.update.plist contains:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict> 
<key>Label</key>
<string>org.dyndns.update</string>
<key>ProgramArguments</key>
<array>
<string>~/mobile/dyndns-update.sh</string>
</array>
<key>StartCalendarInterval</key>
<dict> 
<key>Minute</key>
<integer>3</integer>
</dict>
</dict>
</plist>

And execute:

# launchctl load org.dyndns.update.plist

Now your IP will be update every 3-rd minute. Have fun!

A shell script to measure network throughput on Linux machines.

Here is a shell script to see how many (kilo-, mega-, giga-, terra-) bytes pass a network interface. The output looks like this:

$ ./network-traffic.sh --help
Usage: ./network-traffic.sh [-i INTERFACE] [-s INTERVAL] [-c COUNT]

-i INTERFACE
    The interface to monitor, default is eth0.
-s INTERVAL
    The time to wait in seconds between measurements, default is 3 seconds.
-c COUNT
    The number of times to measure, default is 10 times.
$ ./network-traffic.sh        
Monitoring eth0 every 3 seconds. (RXbyte total = 706 Mb TXbytes total = 1 Gb)
RXbytes = 104 b TXbytes = 194 b
RXbytes = 80 b TXbytes = 188 b
RXbytes = 52 b TXbytes = 146 b
RXbytes = 689 b TXbytes = 8 Kb
RXbytes = 52 b TXbytes = 146 b
RXbytes = 52 b TXbytes = 146 b
RXbytes = 52 b TXbytes = 146 b
RXbytes = 52 b TXbytes = 146 b
RXbytes = 4 Kb TXbytes = 4 Kb
RXbytes = 716 b TXbytes = 5 Kb

Here is the script:

#!/bin/sh

usage(){
echo "Usage: $0 [-i INTERFACE] [-s INTERVAL] [-c COUNT]"
echo
echo "-i INTERFACE"
echo "    The interface to monitor, default is eth0."
echo "-s INTERVAL"
echo "    The time to wait in seconds between measurements, default is 3 seconds."
echo "-c COUNT"
echo "    The number of times to measure, default is 10 times."
exit 3
}

readargs(){
while [ "$#" -gt 0 ] ; do
  case "$1" in
   -i)
    if [ "$2" ] ; then
     interface="$2"
     shift ; shift
    else
     echo "Missing a value for $1."
     echo
     shift
     usage
    fi
   ;;
   -s)
    if [ "$2" ] ; then
     sleep="$2"
     shift ; shift
    else
     echo "Missing a value for $1."
     echo
     shift
     usage
    fi
   ;;
   -c)
    if [ "$2" ] ; then
     counter="$2"
     shift ; shift
    else
     echo "Missing a value for $1."
     echo
     shift
     usage
    fi
   ;;
   *)
    echo "Unknown option $1."
    echo
    shift
    usage
   ;;
  esac
done
}

checkargs(){
if [ ! "$interface" ] ; then
  interface="eth0"
fi
if [ ! "$sleep" ] ; then
  sleep="3"
fi
if [ ! "$counter" ] ; then
  counter="10"
fi
}

printrxbytes(){
/sbin/ifconfig "$interface" | grep "RX bytes" | cut -d: -f2 | awk '{ print $1 }'
}

printtxbytes(){
/sbin/ifconfig "$interface" | grep "TX bytes" | cut -d: -f3 | awk '{ print $1 }'
}

bytestohumanreadable(){
multiplier="0"
number="$1"
while [ "$number" -ge 1024 ] ; do
  multiplier=$(($multiplier+1))
  number=$(($number/1024))
done
case "$multiplier" in
  1)
   echo "$number Kb"
  ;;
  2)
   echo "$number Mb"
  ;;
  3)
   echo "$number Gb"
  ;;
  4)
   echo "$number Tb"
  ;;
  *)
   echo "$1 b"
  ;;
esac
}
 
printresults(){
while [ "$counter" -ge 0 ] ; do
  counter=$(($counter - 1))
  if [ "$rxbytes" ] ; then
   oldrxbytes="$rxbytes"
   oldtxbytes="$txbytes"
  fi
  rxbytes=$(printrxbytes)
  txbytes=$(printtxbytes)
  if [ "$oldrxbytes" -a "$rxbytes" -a "$oldtxbytes" -a "$txbytes" ] ; then
   echo "RXbytes = $(bytestohumanreadable $(($rxbytes - $oldrxbytes))) TXbytes = $(bytestohumanreadable $(($txbytes - $oldtxbytes)))"
  else
   echo "Monitoring $interface every $sleep seconds. (RXbyte total = $(bytestohumanreadable $rxbytes) TXbytes total = $(bytestohumanreadable $txbytes))"
  fi
  sleep "$sleep"
done
}

readargs "$@"
checkargs
printresults

iPhone OS 3.0 Bluetooth tethering with Mac Book Pro

Here is a step by step guide to help you get online with your iPhone using OS 3.0.

  1. Go to this page: http://www.iphone-notes.de/mobileconfig/ It will send you an email. Download that email on you iPhone. It contains a profile to enable Tethering.
  2. Now go to your iPhone preferences, under Network you can enable tethering, activate it
  3. On your Mac Book Pro, go to the bluetooth preferences. Add your iPhone. I had to press "continue" on my Mac Book pro after accepting the pairing request on the iPhone. Waiting here resulted in an error.
  4. On you Mac Book Pro, connect to your iPhone using bluetooth
  5. Now on your Mac Book Pro, under Network Preferences, add a connection: "Bluetooth PAN".

You can now tether using your iPhone!

For tethering, an extra network interface is added, in my case "en5". To see what the IP-address of your connection is, open a Terminal and type:

ifconfig en5

In my case I see that I am using a private class (192.168.20.0/24) IP address. That means that T-Mobile in the Netherlands is NAT-ing my connection. Not a problem, but connecting back to my laptop is not possible from the internet.

Convert a human readable date to epoch with a shell script on OpenBSD and Mac OS X

Dates can be quite challenging. Especially if you systematically want to use dates, for example to compare what date is older.

If you would like to convert this date into epoch, take these steps.

$ # The first step is to print the date.
$ echo "2009/05/25 18:34:30;"
2009/05/25 18:34:30;
$ # This step is to strip the /-es.
$ echo "2009/05/25 18:34:30;" | sed 's%/%%g'
20090525 18:34:30;
$ # This step removes the space
$ echo "2009/05/25 18:34:30;" |  sed 's%/%%g;s% %%g'
2009052518:34:30;
$ # This step removes the trailing :30;.
$ echo "2009/05/25 18:34:30;" | sed 's%/%%g;s% %%g;s%:..;%%'
2009052518:34
$ # This step removes the :.
$ echo "2009/05/25 18:34:30;" | sed 's%/%%g;s% %%g;s%:..;%%;s%:%%g'
200905251834
$ # Finally feed that output to the "date" command.
$ date -j "+%s" $(echo "2009/05/25 18:34:30;" | sed 's%/%%g;s% %%g;s%:..;%%;s%:%%g')
1243269240

On Mac OS X you'd have to use this command:

$ date -j -f date -j -f "%Y/%m/%d %T" "2009/10/15 04:58:06" +"%s"
1255575486

Configure soekris as a OpenBSD wireless NAT router.

I use a Soekris device, bought mine for € 70,- with a wireless network interface. (wi0)
Besides that interface, this "machine" has two other ports; sis0 going to the modem and sis1 is not used, but any computer may be connected.

How difficult would it be to use this machine as a router using OpenBSD? Not difficult at all!

First install your Soekris with OpenBSD.

Now login and configure a few things.

# vi /etc/rc.conf.local
# Start NTP, it syncs time and requires very little maintenance.
ntpd_flags="-s"
# Start a DNS server.
named_flags=
# Clients should receive an IP-address. DHCP will only listen on sis1 and wi0, the network
# interfaces where computers will connect on. Don't start DHCP on your "modem-port".
dhcpd_flags="sis1 wi0"
# Enable Packet Filter.
pf=
# Here are the rules for PF.
pf_rules=/etc/pf.conf

Configure named, the DNS server.

# cat /var/named/etc/named.conf                                                                                      
// $OpenBSD: named-simple.conf,v 1.9 2008/08/29 11:47:49 jakob Exp $
//
// Example file for a simple named configuration, processing both
// recursive and authoritative queries using one cache.


// Update this list to include only the networks for which you want
// to execute recursive queries. The default setting allows all hosts
// on any IPv4 networks for which the system has an interface, and
// the IPv6 localhost address.
//
acl clients {
        localnets;
        ::1;
};

options {
        version "";     // remove this to allow version queries

        listen-on    { any; };
        listen-on-v6 { any; };

        empty-zones-enable yes;

        allow-recursion { clients; };
};

logging {
        category lame-servers { null; };
};

// Standard zones
//
zone "." {
        type hint;
        file "etc/root.hint";
};

zone "localhost" {
        type master;
        file "standard/localhost";
        allow-transfer { localhost; };
};

zone "127.in-addr.arpa" {
        type master;
        file "standard/loopback";
        allow-transfer { localhost; };
};

zone "0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa" {
        type master;
        file "standard/loopback6.arpa";
        allow-transfer { localhost; };
};

zone "lan.meinit.nl" {
        type master;
        file "master/lan.meinit.nl";
};

zone "wifi.meinit.nl" {
        type master;
        file "master/wifi.meinit.nl";
};

zone "1.168.192.in-addr.arpa" {
        type master;
        file "master/1.168.192.in-addr.arpa";
};

zone "2.168.192.in-addr.arpa" {
        type master;
        file "master/2.168.192.in-addr.arpa";
};

Now add all zones.

# cat lan.meinit.nl                                                                                                            
$ORIGIN lan.meinit.nl.
$TTL 6h

@       IN      SOA     lan.meinit.nl. root.meinit.nl. (
                        1       ; serial
                        1h      ; refresh
                        30m     ; retry
                        7d      ; expiration
                        1h )    ; minimum

                        NS      soekris.lan.meinit.nl.
soekris                 A       192.168.1.1
32                      A       192.168.1.32
33                      A       192.168.1.33
34                      A       192.168.1.34
35                      A       192.168.1.35
36                      A       192.168.1.36
37                      A       192.168.1.37
38                      A       192.168.1.38
39                      A       192.168.1.39
40                      A       192.168.1.40
41                      A       192.168.1.41
42                      A       192.168.1.42
43                      A       192.168.1.43
44                      A       192.168.1.44
45                      A       192.168.1.45
46                      A       192.168.1.46
47                      A       192.168.1.47
48                      A       192.168.1.48
49                      A       192.168.1.49
50                      A       192.168.1.50
51                      A       192.168.1.51
52                      A       192.168.1.52
53                      A       192.168.1.53
54                      A       192.168.1.54
55                      A       192.168.1.55
56                      A       192.168.1.56
57                      A       192.168.1.57
58                      A       192.168.1.58
59                      A       192.168.1.59
60                      A       192.168.1.60
61                      A       192.168.1.61
62                      A       192.168.1.62
63                      A       192.168.1.63
64                      A       192.168.1.64
65                      A       192.168.1.65
66                      A       192.168.1.66
67                      A       192.168.1.67
68                      A       192.168.1.68
69                      A       192.168.1.69
70                      A       192.168.1.70
71                      A       192.168.1.71
72                      A       192.168.1.72
73                      A       192.168.1.73
74                      A       192.168.1.74
75                      A       192.168.1.75
76                      A       192.168.1.76
77                      A       192.168.1.77
78                      A       192.168.1.78
79                      A       192.168.1.79
80                      A       192.168.1.80
81                      A       192.168.1.81
82                      A       192.168.1.82
83                      A       192.168.1.83
84                      A       192.168.1.84
85                      A       192.168.1.85
86                      A       192.168.1.86
87                      A       192.168.1.87
88                      A       192.168.1.88
89                      A       192.168.1.89
90                      A       192.168.1.90
91                      A       192.168.1.91
92                      A       192.168.1.92
93                      A       192.168.1.93
94                      A       192.168.1.94
95                      A       192.168.1.95
96                      A       192.168.1.96
97                      A       192.168.1.97
98                      A       192.168.1.98
99                      A       192.168.1.99
100                     A       192.168.1.100
101                     A       192.168.1.101
102                     A       192.168.1.102
103                     A       192.168.1.103
104                     A       192.168.1.104
105                     A       192.168.1.105
106                     A       192.168.1.106
107                     A       192.168.1.107
108                     A       192.168.1.108
109                     A       192.168.1.109
110                     A       192.168.1.110
111                     A       192.168.1.111
112                     A       192.168.1.112
113                     A       192.168.1.113
114                     A       192.168.1.114
115                     A       192.168.1.115
116                     A       192.168.1.116
117                     A       192.168.1.117
118                     A       192.168.1.118
119                     A       192.168.1.119
120                     A       192.168.1.120
121                     A       192.168.1.121
122                     A       192.168.1.122
123                     A       192.168.1.123
124                     A       192.168.1.124
125                     A       192.168.1.125
126                     A       192.168.1.126
127                     A       192.168.1.127

# cat wifi.meinit.nl                                                                                                           
$ORIGIN wifi.meinit.nl.
$TTL 6h

@       IN      SOA     wifi.meinit.nl. root.meinit.nl. (
                        1       ; serial
                        1h      ; refresh
                        30m     ; retry
                        7d      ; expiration
                        1h )    ; minimum

                        NS      soekris.wifi.meinit.nl.
soekris                 A       192.168.2.1
32                      A       192.168.2.32
33                      A       192.168.2.33
34                      A       192.168.2.34
35                      A       192.168.2.35
36                      A       192.168.2.36
37                      A       192.168.2.37
38                      A       192.168.2.38
39                      A       192.168.2.39
40                      A       192.168.2.40
41                      A       192.168.2.41
42                      A       192.168.2.42
43                      A       192.168.2.43
44                      A       192.168.2.44
45                      A       192.168.2.45
46                      A       192.168.2.46
47                      A       192.168.2.47
48                      A       192.168.2.48
49                      A       192.168.2.49
50                      A       192.168.2.50
51                      A       192.168.2.51
52                      A       192.168.2.52
53                      A       192.168.2.53
54                      A       192.168.2.54
55                      A       192.168.2.55
56                      A       192.168.2.56
57                      A       192.168.2.57
58                      A       192.168.2.58
59                      A       192.168.2.59
60                      A       192.168.2.60
61                      A       192.168.2.61
62                      A       192.168.2.62
63                      A       192.168.2.63
64                      A       192.168.2.64
65                      A       192.168.2.65
66                      A       192.168.2.66
67                      A       192.168.2.67
68                      A       192.168.2.68
69                      A       192.168.2.69
70                      A       192.168.2.70
71                      A       192.168.2.71
72                      A       192.168.2.72
73                      A       192.168.2.73
74                      A       192.168.2.74
75                      A       192.168.2.75
76                      A       192.168.2.76
77                      A       192.168.2.77
78                      A       192.168.2.78
79                      A       192.168.2.79
80                      A       192.168.2.80
81                      A       192.168.2.81
82                      A       192.168.2.82
83                      A       192.168.2.83
84                      A       192.168.2.84
85                      A       192.168.2.85
86                      A       192.168.2.86
87                      A       192.168.2.87
88                      A       192.168.2.88
89                      A       192.168.2.89
90                      A       192.168.2.90
91                      A       192.168.2.91
92                      A       192.168.2.92
93                      A       192.168.2.93
94                      A       192.168.2.94
95                      A       192.168.2.95
96                      A       192.168.2.96
97                      A       192.168.2.97
98                      A       192.168.2.98
99                      A       192.168.2.99
100                     A       192.168.2.100
101                     A       192.168.2.101
102                     A       192.168.2.102
103                     A       192.168.2.103
104                     A       192.168.2.104
105                     A       192.168.2.105
106                     A       192.168.2.106
107                     A       192.168.2.107
108                     A       192.168.2.108
109                     A       192.168.2.109
110                     A       192.168.2.110
111                     A       192.168.2.111
112                     A       192.168.2.112
113                     A       192.168.2.113
114                     A       192.168.2.114
115                     A       192.168.2.115
116                     A       192.168.2.116
117                     A       192.168.2.117
118                     A       192.168.2.118
119                     A       192.168.2.119
120                     A       192.168.2.120
121                     A       192.168.2.121
122                     A       192.168.2.122
123                     A       192.168.2.123
124                     A       192.168.2.124
125                     A       192.168.2.125
126                     A       192.168.2.126
127                     A       192.168.2.127

# cat 1.168.192.in-addr.arpa                                                                                                   
$ORIGIN 1.168.192.in-addr.arpa.
$TTL 6h

@       IN      SOA     lan.home.meinit.nl. root.meinit.nl. (
                        1       ; serial
                        1h      ; refresh
                        30m     ; retry
                        7d      ; expiration
                        1h )    ; minimum

                        NS      soekris.lan.meinit.nl.
1                       PTR     soekris.lan.meinit.nl.
$GENERATE       32-127  $       PTR     $.lan.meinit.nl.

# cat 2.168.192.in-addr.arpa                                                                                                   
$ORIGIN 2.168.192.in-addr.arpa.
$TTL 6h

@       IN      SOA     wifi.meinit.nl. root.meinit.nl. (
                        1       ; serial
                        1h      ; refresh
                        30m     ; retry
                        7d      ; expiration
                        1h )    ; minimum

                        NS      soekris.home.meinit.nl.
1                       PTR     soekris.wifi.meinit.nl.
$GENERATE       32-127  $       PTR     $.wifi.meinit.nl.

And setup the DHCP server.

# cat /etc/dhcpd.conf                                                                                                          
subnet 192.168.1.0 netmask 255.255.255.0 {
        option domain-name "lan.meinit.nl";
        option domain-name-servers 192.168.1.1;
        option routers 192.168.1.1;
        range 192.168.1.32 192.168.1.127;
}
subnet 192.168.2.0 netmask 255.255.255.0 {
        option domain-name "wifi.meinit.nl";
        option domain-name-servers 192.168.2.1;
        option routers 192.168.2.1;
        range 192.168.2.32 192.168.2.127;
}

Finally configure your PF in /etc/pf.conf:

# wan is the interface to which the modem is connected.
wan = sis0
# This is an extra interface, not in use right now, but you could connect a cable.
lan = sis1
# This is the (Prism 2) wireless network card. Clients will connect to this interface mostly.
wifi = wi0

scrub in all

nat on $wan from !($wan) to any -> ($wan)

Now beter reboot to activate all changes. (Sure you could start every daemon by hand...)

Using Virtualbox on Mac OS X

Virtualbox is a open source virtualization tool that runs on many operating systems, including Mac OS X It's free, simple and it works, but you'll need to be aware of how to use it. Here are my experiences with different settings.

The default network driver makes an airport interface (en1) on Mac OS X unstable. So; either map the virtual interface to a wired network interface (en0) or use another driver. The Intel PRO/1000 MT Desktop (8254OEM) works fine for me, the PCnet-FAST II (Am78C973) does not work well for me.

For FreeBSD guest operating systems, the default IDE disk causes timeouts. Better use a SATA emulation, IDE emulation causes errors during the install.

Have fun using Virtualbox, after all, its free!

Update Soekris bios firmware from your Apple Mac OS X machine

When you are using a Soekris, a new bios is published every now and then. Because I had to search-copy-try-paste quite some time to get my Apple Mac OS X to upload the most recent Soekris (net4521) bios.

Here is what you need:

I downloaded b4501_133.bin.

The driver for the IOGear USB-to-serial cable creates a device called /dev/tty.PL2303-00002006. The Soekris will most likely run on 19200 bps. If your Soekris spits out unreadable text, try a speed like 9600. If you are able to access the Soekris bios, you can always change the serial speed using "set ConSpeed=19200" for example.

# cu -l /dev/tty.PL2303-00002006 -s 19200
POST: 012345689bcefghipsajklnopqr,,,tvwxy

comBIOS ver. 1.33  20080103  Copyright (C) 2000-2007 Soekris Engineering.

net45xx

0064 Mbyte Memory                        CPU Elan SC520 133 Mhz

Pri Mas  LEXAR ATA FLASH                 LBA Xlt 999-32-63  1007 Mbyte

Slot   Vend Dev  ClassRev Cmd  Stat CL LT HT  Base1    Base2   Int
-------------------------------------------------------------------
0:00:0 1022 3000 06000000 0006 2280 00 00 00 00000000 00000000
0:17:0 104C AC51 06070000 0107 0210 10 3F 82 A0000000 020000A0 10
0:17:1 104C AC51 06070000 0107 0210 10 3F 82 A0001000 020000A0 10
0:18:0 100B 0020 02000000 0107 0290 00 3F 00 0000E101 A0002000 11
0:19:0 100B 0020 02000000 0107 0290 00 3F 00 0000E201 A0003000 05

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

> download -

Start sending file using XMODEM/CRC protocol.
~+./lsz -X b4501_133.bin
Sending b4501_133.bin, 608 blocks: Give your local XMODEM receive command now.
Bytes Sent:  77824   BPS:1745                           

Transfer complete

File downloaded succesfully, size 608 Blocks.

> flashupdate
Updating BIOS Flash ,,,,,,,,,,,,..,,,,.. Done.

> reboot

Good, you are done!

Install your Soekris (or any other machine) with OpenBSD using OpenBSD

To install OpenBSD on your Soekris machine, (or any other machine) take these steps to create an OpenBSD installation server. This instruction help you setup a DHCP, TFTP and HTTP server required for a network installation of OpenBSD.

This setup creates an autonomous install server, that can be disconnected from the internet. During the setup this machine is connected to the internet to install all required software.

First; install an OpenBSD machine. This may either be virtual or physical. Just install the default set of software and make sure it's connected to the internet. (It does not matter if you are using DHCP or a static IP configuration.)

This instruction is based on OpenBSD 4.5, but will likely work for future releases.

Install a DHCP server.

# export PKG_PATH=http://mirror.roothell.org/pub/OpenBSD/4.5/packages/i386/
# pkg_add isc-dhcp-server
isc-dhcp-server-3.1.1: complete

Configure the DHCP server. This step is very dependent of your network configuration, so don't just copy paste everything, but try to understand (using man pages) what's configured.
My /etc/dhcpd.conf looks like this now:

option  domain-name "home.meinit.nl";
option  domain-name-servers 192.168.1.1;

subnet 192.168.1.0 netmask 255.255.255.0 {
        range 192.168.1.32 192.168.1.127;
        host pxe-client {
                hardware ethernet 02:03:04:05:06:07;
                filename "pxeboot";
                next-server 192.168.1.1;
        }
}

Be aware; the "hardware ethernet" address mentioned above is not correct. It needs to be set to what the MAC address is of the machine you would like to install.

Make sure it start by modifying /etc/rc.conf.local, like this:

# echo "dhcpd_flags=" >> /etc/rc.conf.local

Enable the TFTP server in /etc/inetd.conf: (It's installed by default on an OpenBSD installation!)

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

Create some directories and restart inetd:
# pkill -HUP inetd

Now get the kernel that is being used when booting over the network and retreive the PXE boot code.

# cd /tftpboot
# ftp http://mirror.roothell.org/pub/OpenBSD/4.5/i386/bsd.rd
Trying 88.198.153.75...
Requesting http://mirror.roothell.org/pub/OpenBSD/4.5/i386/bsd
100% |*******************************************************************************|  5461 KB    00:06
Successfully retrieved file.
# echo "set tty com0
stty com0 19200
boot bsd.rd" > etc/boot.conf
# ftp http://mirror.roothell.org/pub/OpenBSD/4.5/i386/pxeboot
Trying 88.198.153.75...
Requesting http://mirror.roothell.org/pub/OpenBSD/4.5/i386/pxeboot
100% |*******************************************************************************| 53276       00:00   
Successfully retrieved file.

Enable a HTTP server.

# echo "httpd_flags=" >> /etc/rc.conf.local

Now get all required software sets you'd like to offer.

# ftp http://mirror.roothell.org/pub/OpenBSD/4.5/i386/index.txt
Trying 88.198.153.75...
Requesting http://mirror.roothell.org/pub/OpenBSD/4.5/i386/index.txt
100% |*******************************************************************************|   266       00:00   
Successfully retrieved file.
# cat index.txt | grep -v '.iso' | tee index.txt | while read file ; do
>  ftp http://mirror.roothell.org/pub/OpenBSD/4.5/i386/"$file"         
> done
100% |********************************************************************************|   106 KB    00:00   
100% |********************************************************************************| 22356       00:00   
100% |********************************************************************************|  1022       00:00   
100% |********************************************************************************| 46941 KB    00:27   
100% |********************************************************************************|  6539 KB    00:02   
100% |********************************************************************************|  6558 KB    00:03   
100% |********************************************************************************|  5461 KB    00:02   
100% |********************************************************************************| 44724       00:00   
100% |********************************************************************************|  2048       00:00   
100% |********************************************************************************| 87874 KB    00:59   
100% |********************************************************************************|   501 KB    00:00   
100% |********************************************************************************|  1440 KB    00:00   
100% |********************************************************************************|  1440 KB    00:00   
100% |********************************************************************************|  1440 KB    00:00   
100% |********************************************************************************|  2555 KB    00:00   
100% |********************************************************************************|  8032 KB    00:03   
100% |********************************************************************************|  2866 KB    00:02   
100% |********************************************************************************| 53276       00:00   
100% |********************************************************************************|  9761 KB    00:07   
100% |********************************************************************************| 75214       00:01   
100% |********************************************************************************| 34745 KB    00:26   
100% |********************************************************************************| 19478 KB    00:11   
100% |********************************************************************************|  2698 KB    00:06   

Now that everything is ready, reconfigure your network to use a static IP which is usable in the network you are planning this installation server.

NOTA BENE: you have enabled a DHCP server, if your network already uses a DHCP server, clients might get an IP address from your DHCP server, which is likely incorrect and/or conflicting with the exiting DHCP server. Normally you'd like to use one DHCP server per network.

# echo "inet 192.168.1.1 255.255.255.0 192.168.1.255" > /etc/hostname.em0
# echo "lookup file" > /etc/resolv.conf
# reboot

Now in the freshly installed client, modify/create /etc/boot.conf with this content:

set tty com0
stty com0 19200

The Soekris uses these setting to be able to access the serial console.

Okay, after your install server has been rebooted, go and boot an uninstalled client.

For soekris users; connect your console cable, see the machine boot.

You will see that it's first getting the pxeboot code, then the kernel (bsd). When the kernel has booted, select your bootservers IP address to install software from and enter "/" at the server directory question.

Add a permanent static route to Mac OS X

As a reminder for myself, but likely useful for you! If you are in a situation where you'd like to add a static route to you Mac OS X machine, you could issue:

$ sudo route add 10.0.0.0/8 192.168.1.1

This commands tells the TCP/IP stack to sent traffic with the destination 10.*.*.* via 192.168.1.1. But, this command is only active after issuing it and before the next reboot. To "save" this command, make it permanent, you can take these simple steps.
$ sudo mkdir /Library/StartupItems/AddRoute
# cd /Library/StartupItems/AddRoute
$ echo "{
        Description     = \"Add static routing tables\";
        Provides        = (\"AddRoutes\");
        Requires        = (\"Network\");
        OrderPreference = \"None\";
}" > StartupParameters.plist
$ echo "#!/bin/sh

# Set up static routing tables
# Roark Holz, Thursday, April 6, 2006

. /etc/rc.common

StartService ()
{
        ConsoleMessage "Adding Static Routing Tables"
sudo route add 10.0.0.0/8 192.168.200.15
}

StopService ()
{
        return 0
}

RestartService ()
{
        return 0
}

RunService "$1"" > AddRoutes
$ sudo chmod 755 AddRoutes

Now you should be prepared. After a reboot, the route will be visible. (netstat -rnf inet)

About Consultancy Articles Contact




References Red Hat Certified Architect By Robert de Bock Robert de Bock
Curriculum Vitae By Fred Clausen +31 6 14 39 58 72
By Nelson Manning [email protected]
Syndicate content