[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Curiosità su Iptables



Ciao a tutti della lista....
Avrei una curiosità riguardo a delle regole di iptables che ho letto su un 
manuale:
iptables -P INPUT DROP
iptables -P FORWARD DROP
iptables -P OUTPUT ACCEPT
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
A prima vista mi sono sembrate delle buone regole "ovviamente per le mie 
conoscenze" nel impostare il drop sulle catene di input e forward, l'accept 
sull'output e caricare il modulo state per effettuare il tracciamento delle 
connessioni..
L'unica cosa è che applicando tali regole mi trovavo con il wm completamente 
bloccato.....
Ho risolto il problema aggiungendo la regola:
iptables -A INPUT -s 127.0.0.1 -j ACCEPT
pensando che le regole precedenti non mi permettessero le connessioni 
locali...
Secondo il vostro parere, queste regole, sono sufficientemente buone per un 
utilizzo desktop?Oppure nel caso non lo fossero, come potrei modificarle?
Colgo l'occasione per postarvi degli script da me fatti per gestire alcuni 
parametri della rete...spero che vi possano essere d'aiuto:

1)firewall
#!/bin/bash
ROOT_UID=0
E_NONROOT=67
if [[ "$UID" -ne "$ROOT_UID" ]];then
zenity --error --text="You should be root to execute this script"
exit $E_NONROOT
fi
iptables -P INPUT DROP
iptables -P FORWARD DROP
iptables -P OUTPUT ACCEPT
iptables -A INPUT -s 127.0.0.1 -j ACCEPT
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT

2)netcustom(richiede zenity)
#!/bin/bash
#script per la gestione temporanea dei parametri principali di rete
opt=""
tmb=""
iht=""
ilt=""
it=""
ROOT_UID=0
E_NONROOT=67
if [[ "$UID" -ne "$ROOT_UID" ]];then
zenity --error --text="You should be root to execute this script"
exit $E_NONROOT
fi
function tcp_max_backlog(){
tmb=$(zenity --entry --text="Set new value for the TcpMaxBacklog 
(default=1024)")
echo ${tmb} > /proc/sys/net/ipv4/tcp_max_syn_backlog
return
}
function ipfrag_high_thresh(){
iht=$(zenity --entry --text="Set new value for the IpfragHighThreshold 
(default=262144)")
echo ${iht} > /proc/sys/net/ipv4/ipfrag_high_thresh
return
}
function ipfrag_low_thresh(){
ilt=$(zenity --entry --text="Set new value for the IpfragLowThreshold 
(default=196608)")
echo ${ilt} > /proc/sys/net/ipv4/ipfrag_low_thresh
return
}
function ipfrag_time(){
it=$(zenity --entry --text="Set new value for the IpfragTime (default=30)")
echo ${it} > /proc/sys/net/ipv4/ipfrag_time
return
}
function rp_filter(){
for a in /proc/sys/net/ipv4/conf/*/rp_filter; do
    echo 1 > $a
    done
return
}
function get_options(){
opt=$(zenity --width=400 --height=600 --list --checklist --separator="" --text="Opzioni" --column=Scelta --column=Opzioni --column=Lettera_Operazione 
0 enable_icmp_echo_ignore_all a 1 disable_icmp_echo_ignore_broadcasts b 2 
enable_icmp_errors_use_inbound_ifaddr c 3 
disable_icmp_ignore_bogus_error_responses d 4 enable_ip_forward e 5 
enable_tcp_ecn f 6 enable_tcp_syncookies g 7 change_tcp_max_syn_backlog h 8 
change_ipfrag_high_thresh i 9 change_ipfrag_low_thresh l 10 
change_ipfrag_time m 11 disable_accept_redirects n 12 
enable_accept_source_route o 13 enable_log_martians p 14 enable_mc_forwarding 
q 15 enable_rp_filter r 16 disable_secure_redirects s 17 
disable_send_redirects t 18 enable_iptables_firewall 
u --hide-column=3 --print-column=3)
return
}
get_options

if [[ $(echo $opt | grep "a") ]];then echo 1 
> /proc/sys/net/ipv4/icmp_echo_ignore_all ; fi
if [[ $(echo $opt | grep "b") ]];then echo 0 
> /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts ; fi
if [[ $(echo $opt | grep "c") ]];then echo 1 
> /proc/sys/net/ipv4/icmp_errors_use_inbound_ifaddr ; fi
if [[ $(echo $opt | grep "d") ]];then echo 0 
> /proc/sys/net/ipv4icmp_ignore_bogus_error_responses ; fi
if [[ $(echo $opt | grep "e") ]];then echo 1 > /proc/sys/net/ipv4/ip_forward ; 
fi
if [[ $(echo $opt | grep "f") ]];then echo 1 > /proc/sys/net/ipv4/tcp_ecn ; fi
if [[ $(echo $opt | grep "g") ]];then echo 1 
> /proc/sys/net/ipv4/tcp_syncookies ; fi
if [[ $(echo $opt | grep "h") ]];then tcp_max_backlog ; fi
if [[ $(echo $opt | grep "i") ]];then ipfrag_high_thresh ; fi
if [[ $(echo $opt | grep "l") ]];then ipfrag_low_thresh ; fi
if [[ $(echo $opt | grep "m") ]];then ipfrag_time ; fi
if [[ $(echo $opt | grep "n") ]];then echo 0 
> /proc/sys/net/ipv4/conf/all/accept_redirects ; fi
if [[ $(echo $opt | grep "o") ]];then echo 1 
> /proc/sys/net/ipv4/conf/all/accept_source_route ; fi
if [[ $(echo $opt | grep "p") ]];then echo 1 
> /proc/sys/net/ipv4/conf/all/log_martians ; fi
if [[ $(echo $opt | grep "q") ]];then echo 1 
> /proc/sys/net/ipv4/conf/all/mc_forwarding ; fi
if [[ $(echo $opt | grep "r") ]];then rp_filter ; fi
if [[ $(echo $opt | grep "s") ]];then echo 0 
> /proc/sys/net/ipv4/conf/all/secure_redirects ; fi
if [[ $(echo $opt | grep "t") ]];then echo 0 
> /proc/sys/net/ipv4/conf/all/send_redirects ; fi
if [[ $(echo $opt | grep "u") ]];then firewall ; fi


Ciao a tutti e grazie in anticipo

Attachment: signature.asc
Description: This is a digitally signed message part.


Reply to: