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

2 thoughts on “Null Routing in FreeBSD

  1. dan Post author

    Oh and to make them permanent… add them to /etc/rc.local or (preferrably) a script running in /usr/local/etc/rc.d/ 😉

    Reply
  2. kirgudu

    /etc/rc.conf

    static_routes=”d1 d2 d3″
    route_d1=”-net 192.168.0.0/16 127.0.0.1 -reject”
    route_d2=”-net 10.0.0.0/8 127.0.0.1 -reject”
    route_d3=”-net 172.16.0.0/12 127.0.0.1 -reject”

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *