HOWTO install quagga on pfSense

From Chaos

Jump to: navigation, search
This article is part of the HOWTO series.

Contents

Summary

This howto will describe how to install quagga on pfSense.

Caveats

  1. You must be familiar with pfSense.
  2. You must be familiar with quagga.
  3. You must understand that the scope of this document covers how to install quagga, not how to set up the individual routing daemons.

Details

Install the quagga package

1. Log in to pfSense via SSH, and install the quagga package:

root@localhost:~# pkg_add ftp://ftp.freebsd.org/pub/FreeBSD/ports/i386/packages-6.1-release/net/quagga-0.99.3_2.tbz

Setup the startup scripts

1. Once you have the quagga package installed, create the file /usr/local/etc/quagga/quagga.sh, and add the following contents in it. Note: if you are using other daemons than zebra/bgpd, you should probably modify this script:

#!/bin/sh

zebra_daemon="zebra"
zebra_args="-d"
bgpd_daemon="bgpd"
bgpd_args="-d"

start () {
        DAEMON=$1
        ARGS=$2

        ${DAEMON} ${ARGS}
}

stop () {
        DAEMON=$1

        kill -9 `pgrep ${DAEMON}`
}

case "$2" in
	start)
		eval start \$${1}_daemon \$${1}_args
		;;
	stop)
		eval stop \$${1}_daemon
		;;
	restart)
		eval stop \$${1}_daemon
		sleep 1
		eval start \$${1}_daemon \$${1}_args
		;;
	*)
		echo "Usage: `basename $0` zebra|bgpd start|stop|restart"
		;;
esac

2. Save the file, and exit. Mark the script as executable:

root@localhost:/usr/local/etc/quagga# chmod +x quagga.sh

3. Go to /usr/local/etc/rc.d/, and create the file watchquagga.sh (you can safely remove the old watchquagga script). If you are using daemons other than zebra/bgpd, you might want to change the variable 'DAEMONS':

root@localhost:/usr/local/etc/quagga# cd ../rc.d
root@localhost:/usr/local/etc/rc.d# rm watchquagga
root@localhost:/usr/local/etc/rc.d# vi watchquagga.sh
#!/bin/sh
DAEMONS="zebra bgpd"

case "$1" in
  start)
        # Start daemons.
        echo -n "Starting watchquagga... "
	if [ ! -d /var/run/quagga ] ; then
		mkdir /var/run/quagga
		chown -R quagga:quagga /var/run/quagga
	fi
	/usr/local/sbin/watchquagga -Adz -r '/usr/local/etc/quagga/quagga.sh %s restart' -s '/usr/local/etc/quagga/quagga.sh %s start' -k '/usr/local/etc/quagga/quagga.sh %s stop' -m 5 -M 10 ${DAEMONS}
	echo "done."
        ;;
  stop)
        # Stop daemons.
        echo -n "Stopping watchquagga... "
        kill -9 `pgrep watchquagga`
	for prog in ${DAEMONS} ; do
		kill -9 `pgrep ${prog}`
	done
	echo "done."
        ;;
  restart)
        $0 stop
        $0 start
        exit $?
        ;;
  *)
        echo "Usage: `basename $0` {start|stop|restart}"
        exit 1
esac

exit 0

4. Mark the watchquagga.sh script as executable:

root@localhost:/usr/local/etc/rc.d# chmod +x watchquagga.sh

5. Attempt to start watchquagga, which will then start zebra, bgpd, etc. (depending on which daemons you have enabled). You can also use watchquagga.sh to stop/restart watchquagga and the individual daemons also. Just run it with 'stop' or 'restart' for the args instead of 'start':

root@localhost:/usr/local/etc/rc.d# ./watchquagga.sh start
Personal tools
Sponsored Links