All pastes #808296 Raw Edit

Untitled

public text v1 · immutable
·published 2007-12-07 13:31 UTC
rendered paste body
[root@Lost ~] cat /etc/init.d/rc.filter 
#!/bin/sh

IPTABLES=/bin/iptables
LAN_NET="$(net `/bin/nvram get lan_ipaddr` `/bin/nvram get lan_netmask`)"
PPP_IFACE=`/bin/nvram get ppp_ifname`
LAN_BR=`/bin/nvram get lan_ifname`

case "$1" in

        start)
        
        
        if [ "`/bin/nvram get winfilter_active`" = "on" ]
        then
                #Filtrage TCP/UDP : 135, 137, 138, 139, 445
                $IPTABLES -A FORWARD -i $PPP_IFACE -p tcp -m tcp --dport 135 -j DROP
                $IPTABLES -A FORWARD -i $PPP_IFACE -p tcp -m tcp --dport 137:139 -j DROP
                $IPTABLES -A FORWARD -i $PPP_IFACE -p tcp -m tcp --dport 445 -j DROP

                $IPTABLES -A FORWARD -i $PPP_IFACE -p udp -m udp --dport 135 -j DROP
                $IPTABLES -A FORWARD -i $PPP_IFACE -p udp -m udp --dport 137:139 -j DROP
                $IPTABLES -A FORWARD -i $PPP_IFACE -p udp -m udp --dport 445 -j DROP

                $IPTABLES -A FORWARD -o $PPP_IFACE -p tcp -m tcp --dport 135 -j DROP
                $IPTABLES -A FORWARD -o $PPP_IFACE -p tcp -m tcp --dport 137:139 -j DROP
                $IPTABLES -A FORWARD -o $PPP_IFACE -p tcp -m tcp --dport 445 -j DROP

                $IPTABLES -A FORWARD -o $PPP_IFACE -p udp -m udp --dport 135 -j DROP
                $IPTABLES -A FORWARD -o $PPP_IFACE -p udp -m udp --dport 137:139 -j DROP
                $IPTABLES -A FORWARD -o $PPP_IFACE -p udp -m udp --dport 445 -j DROP
        fi
        ;;

        stop)
                #Filtrage TCP/UDP : 135, 137, 138, 139, 445
                $IPTABLES -D FORWARD -i $PPP_IFACE -p tcp -m tcp --dport 135 -j DROP
                $IPTABLES -D FORWARD -i $PPP_IFACE -p tcp -m tcp --dport 137:139 -j DROP
                $IPTABLES -D FORWARD -i $PPP_IFACE -p tcp -m tcp --dport 445 -j DROP

                $IPTABLES -D FORWARD -i $PPP_IFACE -p udp -m udp --dport 135 -j DROP
                $IPTABLES -D FORWARD -i $PPP_IFACE -p udp -m udp --dport 137:139 -j DROP
                $IPTABLES -D FORWARD -i $PPP_IFACE -p udp -m udp --dport 445 -j DROP

                $IPTABLES -D FORWARD -o $PPP_IFACE -p tcp -m tcp --dport 135 -j DROP
                $IPTABLES -D FORWARD -o $PPP_IFACE -p tcp -m tcp --dport 137:139 -j DROP
                $IPTABLES -D FORWARD -o $PPP_IFACE -p tcp -m tcp --dport 445 -j DROP

                $IPTABLES -D FORWARD -o $PPP_IFACE -p udp -m udp --dport 135 -j DROP
                $IPTABLES -D FORWARD -o $PPP_IFACE -p udp -m udp --dport 137:139 -j DROP
                $IPTABLES -D FORWARD -o $PPP_IFACE -p udp -m udp --dport 445 -j DROP


        ;;


        *)
        echo "Usage {start|stop}"

        ;;

esac