Enviado em 21/04/2017 - 03:32h
Este firewall é tão grotesco que pensei umas dez vezes entes de mostrá-lo e umas vinte antes de solicitar auxílio.fw() {
echo "0" | tee /proc/sys/net/ipv4/ip_forward > /dev/null
echo "1" | tee /proc/sys/net/ipv4/conf/*/rp_filter > /dev/null
echo "0" | tee /proc/sys/net/ipv4/icmp_echo_ignore_all > /dev/null
echo "1" | tee /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts > /dev/null
echo "1" | tee /proc/sys/net/ipv6/conf/*/disable_ipv6 > /dev/null
iptables -A INPUT -i lo -j ACCEPT
# iptables -A INPUT --dport 21,22,25,80,135,137,139,443,3306 -m iprange --src-range 192.168.0.0-192.168.255.255 -j LOG --log-prefix "@P:-> "
# iptables -A INPUT --dport 21,22,25,80,135,137,139,443,3306 -m iprange --src-range 192.168.0.0-192.168.255.255 -j DROP
iptables -A INPUT -s 127.0.0.10 -j LOG --log-prefix "@@s-> "
iptables -A INPUT -s 127.0.0.10 -j DROP
iptables -A INPUT -d 127.0.0.10 -j LOG --log-prefix "@@d-> "
iptables -A INPUT -d 127.0.0.10 -j DROP
iptables -A OUTPUT -s 127.0.0.10 -j LOG --log-prefix "@@s-> "
iptables -A OUTPUT -s 127.0.0.10 -j DROP
iptables -A OUTPUT -d 127.0.0.10 -j LOG --log-prefix "@@d-> "
iptables -A OUTPUT -d 127.0.0.10 -j DROP
iptables -A INPUT -p tcp --syn -j LOG --log-prefix "syn -> "
iptables -A INPUT -p tcp --syn -j DROP
iptables -A INPUT -p udp --dport 0:1023 -j DROP
iptables -A INPUT -s 239.255.255.250/255.255.255.0 -j LOG --log-prefix "M$ -> "
iptables -A INPUT -s 239.255.255.250/255.255.255.0 -j DROP
# iptables -A INPUT -s 192.168.2.47/255.255.255.0 -p tcp --dport 445 -j DROP
iptables -A INPUT -s 192.168.14.252/255.255.255.240 -j LOG --log-prefix "s--> "
iptables -A INPUT -s 192.168.14.252/255.255.255.240 -j DROP
iptables -A INPUT -p udp -s 0/0 -i eth0 --dport 33435:33525 -j LOG --log-prefix "udp -> "
iptables -A INPUT -p udp -s 0/0 -i eth0 --dport 33435:33525 -j DROP
iptables -A INPUT -i eth0 -p tcp --dport :32000 -j DROP
iptables -A INPUT -i eth0 -p udp --dport :32000 -j DROP
iptables -A INPUT -p icmp --icmp-type echo-request -j DROP
iptables -A INPUT -i eth0 -p tcp --sport 6000:6255 -j DROP
iptables -A INPUT -i eth0 -p tcp --dport 6000:6255 -j DROP
iptables -A FORWARD -p tcp --tcp-flags ALL SYN -j DROP
iptables -A FORWARD -p tcp --tcp-flags ALL SYN,ACK -j LOG --log-prefix "SYN/ACK-> "
iptables -A FORWARD -p tcp --tcp-flags ALL SYN,ACK -j DROP
# iptables -A OUTPUT -p tcp --dport 80 ! -s 127.0.0.1 -j -log-prefix "P80 -> "
# iptables -A OUTPUT -p tcp --dport 80 ! -s 127.0.0.1 -j DROP
# iptables -A OUTPUT -p tcp --dport 3306 ! -s 127.0.0.1 -j -log-prefix "P3306 -> "
# iptables -A OUTPUT -p tcp --dport 3306 ! -s 127.0.0.1 -j DROP
# bloqueia conexoes de dentro pra fora:
# for i in 21 22 23 80 86 139 443 445 631 901 3306 5190; do
# iptables -A OUTPUT -p tcp --dport "$i" -j DROP
# done;
# log
# iptables -A FORWARD -m limit --limit 3/minute --limit-burst 3 -j LOG
}