Tag Archives: karl glover

Null Routing in FreeBSD

Ok Karl… Null routing – real easy 🙂

If you wanted to null route a single IP (192.168.0.1), you would run (as root):

/sbin/route add 192.168.0.1 127.0.0.1 -blackhole

If you wanted to null route a block of IPs (192.168.0.0/24), then use:

/sbin/route add -net 192.168.0.0/24 127.0.0.1 -blackhole

If you would rather generate a “Destination Host Unreachable” ICMP response instead of blackholing the traffic, replace -blackhole with -reject

RTG FreeBSD Startup Script

Ok Karl, here you go… Once you have installed RTG on your server from FreeBSD ports and configured it, you can add this script to your /usr/local/etc/rc.d/ folder.  Make sure it runs AFTER your mysql server starts or it will be useless!

#!/bin/sh

case “$1” in
‘start’)
rm /tmp/rtgpoll.pid
/usr/local/bin/rtgpoll -c /usr/local/etc/rtg/rtg.conf -t /usr/local/etc/rtg/targets.cfg &
;;
‘stop’)
;;
*)
echo “Please specify ‘start’ or ‘stop'”
;;
esac