[Linuxtrent] Re: account senza internet

  • From: Renato Conotter <conotter@xxxxxxxxx>
  • To: linuxtrent@xxxxxxxxxxxxx
  • Date: Sat, 3 May 2008 20:48:37 +0200

Alle sabato 3 maggio 2008, necro ha scritto:
> On Sat, May 03, 2008 at 10:26:53AM +0200, Giuseppe Briotti wrote:
...
> iptables -A OUTPUT -d ! $rete_lan -m owner --uid-owner $username -j DROP
>
> tipicamente un
> iptables -A OUTPUT -d ! 192.168.0.0/16 -m owner --uid-owner $username -j
> DROP
> dovrebbe andar bene per il 90% delle piccole reti casalinghe
il diaolin mi diede per lo stesso problema questo scriptino da far partire 
all'avvio.
sostituisci pippo col/coi nomi utente da bloccare.
#!/bin/sh
#
modprobe ipt_owner
#device in uscita
#DEVICE=eth0
ETH=eth0
#lista degli utenti da bloccare
OWNERS="pippo"
LOCKFILE=/var/lock/LCK..rc.owner

extract_id(){
        USER=$1
        echo $USER
        cat /etc/passwd | awk -F: '{if (/^$USER:/) print $3}'
}

case $1 in
    start)
            if [ -f ${LOCKFILE} ]
            then
            echo "Already started: please execute $0 stop"
            exit 0
            fi

            echo "Maschero OUTPUT degli utenti"
            for owner in ${OWNERS}
            do
            # estraggo id utente
            extract_id ${owner}
            #blocco output su eth0 come utente $owner
            iptables -A OUTPUT -o $ETH -m owner --uid-owner $owner -j DROP
            done
            touch ${LOCKFILE}
            ;;

    stop)
            echo "Tolgo blocco OUTPUT dagli utenti"
            for owner in ${OWNERS}
            do
            iptables -D OUTPUT -o $ETH -m owner --uid-owner $owner -j DROP
            done
            rm -f ${LOCKFILE}
            ;;
    *)
            echo "Usage: $0 start/stop"
            ;;
esac
ciao Renato
-- 
Linux Registered User #213435
Powered by: Debian Testing
-- 
Per iscriversi  (o disiscriversi), basta spedire un  messaggio con OGGETTO
"subscribe" (o "unsubscribe") a mailto:linuxtrent-request@xxxxxxxxxxxxx


Other related posts: