    #!/bin/sh
    #
    # All SIP traffic rate, per host.
    RATE=100/minute

    # Burst
    BURST=30

    # Interface(s) to protect. Seperate multiple interfaces with spaces.
    IFACE="eth0"

    # Location of iptables binary.
    IPTABLES=`which iptables`

    if [ ! "$1" ]
    then
    echo "SIP DoS/DDoS mitigation script for iptables
    See top of script for configuration

    Usage:
    $0 [start|stop|status]"
    exit 1
    fi

    if [ "$1" = "status" ]
    then
    $IPTABLES -L -v -n
    exit
    fi

    # Setup iptables
    $IPTABLES -F sipdos 2> /dev/null
    $IPTABLES -X sipdos 2> /dev/null
    $IPTABLES -N sipdos 2> /dev/null

    if [ "$1" = "stop" ]
    then
    echo "Clearing iptables rules…"
    $IPTABLES -F INPUT 2> /dev/null
    exit
    fi

    # Send the right traffic through our chain
    for i in $IFACE
    do
    $IPTABLES -A INPUT -i $i -m tcp -p tcp --dport 5061 -j sipdos
    done

    # Finally set limits…
    $IPTABLES -A sipdos -m hashlimit --hashlimit $RATE --hashlimit-burst $BURST --hashlimit-mode srcip,dstport --hashlimit-name sip_o_limit -j ACCEPT

    # Take action
    $IPTABLES -A sipdos -j LOG
    $IPTABLES -A sipdos -j DROP
