hugovlmota
(usa CentOS)
Enviado em 05/12/2007 - 16:11h
Boa tarde galera,
Sou novato em linux e estou com um problema clássico.
Não consigo liberar os programas da CEF.
Estou postando aqui a minha regra de firewall completa, pois assim acho que ficará mais fácil vocês me ajudarem.
Obrigado a todos.
#eth1=placa externa
#eth0=placa interna
#=============limpa regras====================
iptables -F
iptables -X
iptables -X -t nat
iptables -F -t mangle
iptables -X -t mangle
#============carrega modulos====================
modprobe iptable_nat
modprobe ip_conntrack
modprobe ip_conntrack_ftp
modprobe ip_nat_ftp
modprobe ipt_LOG
modprobe ipt_REJECT
modprobe ipt_MASQUERADE
modprobe ipt_multiport
#========conectividade social================
iptables -t nat -I PREROUTING -p tcp -d 200.201.0.0/16 -j ACCEPT
iptables -I FORWARD -p tcp -d 200.201.0.0/16 -j ACCEPT
iptables -t nat -A PREROUTING -i eth0 -p tcp -d ! 200.201.0.0/16 --dport 80 -j REDIRECT --to-port 3128
#======cat prota 5017/sitengra prota 8017(cafe.dataprev.gov.br=200.152.32.148)===
iptables -t nat -A POSTROUTING -d 200.152.32.148 -o eth1 -j MASQUERADE
iptables -t nat -A POSTROUTING -d cafe.dataprev.gov.br -o eth1 -j MASQUERADE
#===========habilita forward===============
echo "1" > /proc/sys/net/ipv4/ip_forward
#=============proxy transparente============
iptables -t nat -A PREROUTING -p tcp -i eth0 --dport 80 -j REDIRECT --to-port 3128
iptables -t nat -A PREROUTING -p tcp -i eth0 --dport 8080 -j REDIRECT --to-port 3128
#==================masquerade================
iptables -t nat -A POSTROUTING -s 192.168.1.0/24 -j MASQUERADE
#============filtros de ip 29082007============
echo 0 > /proc/sys/net/ipv4/conf/all/rp_filter
echo 0 > /proc/sys/net/ipv4/conf/eth0/rp_filter
echo 0 > /proc/sys/net/ipv4/conf/eth1/rp_filter
#========protecao contra atques 29082007=========================
echo 1 > /proc/sys/net/ipv4/tcp_syncookies
echo 1 > /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts
echo 1 > /proc/sys/net/ipv4/icmp_ignore_bogus_error_responses
echo 1 > /proc/sys/net/ipv4/icmp_echo_ignore_all
iptables -A INPUT -p tcp -i eth1 --dport 1524 -j DROP
iptables -A INPUT -p tcp -i eth1 --dport 27665 -j DROP
iptables -A INPUT -p tcp -i eth1 --dport 27444 -j DROP
iptables -A INPUT -p tcp -i eth1 --dport 31335 -j DROP
iptables -A FORWARD -p tcp --syn -m limit --limit 5/s -j ACCEPT
iptables -A FORWARD -p icmp --icmp-type echo-request -m limit --limit 2/s -j ACCEPT
iptables -A FORWARD -p tcp -m limit --limit 5/s -j ACCEPT
iptables -A FORWARD -p tcp --tcp-flags SYN,ACK,FIN,RST RST -m limit --limit 5/s -j ACCEPT
iptables -A INPUT -p tcp --dport 21 -j LOG --log-prefix "FTP"
iptables -A INPUT -p tcp --dport 23 -j LOG --log-prefix "TELNET"
iptables -A INPUT -p tcp --dport 22 -j LOG --log-prefix "SSH"
iptables -A INPUT -p tcp --dport 137:139 -j LOG --log-prefix "NETBEUI"
iptables -A INPUT -p tcp --dport 5042 -j LOG --log-prefix "Wincrash"
iptables -A INPUT -p tcp --dport 12345 -j LOG --log-prefix "BackOrifice"
#================libera loopback=================
iptables -A OUTPUT -p tcp --syn -s 127.0.0.1/255.0.0.0 -j ACCEPT
#==========conexao fora->dentro==============
iptables -A INPUT -p tcp --dport 443 -j ACCEPT
iptables -A INPUT -p tcp --dport 563 -j ACCEPT
iptables -A INPUT -p tcp --dport 20 -j ACCEPT
iptables -A INPUT -p tcp --dport 21 -j ACCEPT
iptables -A INPUT -p tcp --dport 22 -j ACCEPT
iptables -A INPUT -p tcp --dport 25 -j ACCEPT
iptables -A INPUT -p tcp --dport 110 -j ACCEPT
iptables -A INPUT -p tcp --dport 80 -j ACCEPT
iptables -A INPUT -p tcp --dport 86 -j ACCEPT
iptables -A INPUT -p tcp --dport 5190 -j ACCEPT
iptables -A INPUT -p tcp --dport 1863 -j ACCEPT
iptables -A INPUT -p tcp --dport 5800 -j ACCEPT
iptables -A INPUT -p tcp --dport 5900 -j ACCEPT
#=======conexao dentro->fora=====================
iptables -A OUTPUT -p tcp --dport 80 -j ACCEPT
iptables -A OUTPUT -p tcp --dport 22 -j ACCEPT
iptables -A OUTPUT -p tcp --dport 20 -j ACCEPT
iptables -A OUTPUT -p tcp --dport 86 -j ACCEPT
iptables -A OUTPUT -p tcp --dport 5190 -j ACCEPT
iptables -A OUTPUT -p tcp --dport 1863 -j ACCEPT
iptables -A OUTPUT -p tcp --dport 25 -j ACCEPT
iptables -A OUTPUT -p tcp --dport 110 -j ACCEPT
iptables -A OUTPUT -p tcp --dport 443 -j ACCEPT
iptables -A OUTPUT -p tcp --dport 563 -j ACCEPT
iptables -A OUTPUT -p tcp --dport 5800 -j ACCEPT
iptables -A OUTPUT -p tcp --dport 5900 -j ACCEPT
#==========correio eletronico================
iptables -A FORWARD -p tcp -s 192.168.1.0/24 -d 201.7.95.96 --dport 53 -j ACCEPT
iptables -A FORWARD -p tcp -s 201.7.95.96 --sport 53 -d 192.168.1.0/24 -j ACCEPT
iptables -A FORWARD -p tcp -s 192.168.1.0/24 --dport 25 -j ACCEPT
iptables -A FORWARD -p tcp -s 192.168.1.0/24 --dport 110 -j ACCEPT
iptables -A FORWARD -p tcp --sport 25 -j ACCEPT
iptables -A FORWARD -p tcp --sport 110 -j ACCEPT
#======tedsef=====================================
iptables -A FORWARD -s 192.168.1.0/24 -d 200.199.34.41 -p tcp -j ACCEPT
#=============libera https=================
iptables -A FORWARD -p tcp --dport 443 -j ACCEPT
iptables -A FORWARD -p tcp --dport 563 -j ACCEPT
#========ts windows server 2003 : 3389====
iptables -A FORWARD -i eth1 -p tcp --dport 3389 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -i eth1 -p udp --dport 3389 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
iptables -t nat -A PREROUTING -p tcp -i eth1 --dport 3389 -j DNAT --to 192.168.1.3:3389
iptables -t nat -A PREROUTING -p udp -i eth1 --dport 3389 -j DNAT --to 192.168.1.3:3389
#==============Libera Acesso P10 na porta 1234
iptables -A FORWARD -i eth1 -p tcp --dport 1234 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -i eth1 -p udp --dport 1234 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
iptables -t nat -A PREROUTING -p tcp -i eth1 --dport 1234 -j DNAT --to 192.168.1.3:1234
iptables -t nat -A PREROUTING -p udp -i eth1 --dport 1234 -j DNAT --to 192.168.1.3:1234
#=====Libera Acesso DBAccess na porta 7890
iptables -A FORWARD -i eth1 -p tcp --dport 7890 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -i eth1 -p udp --dport 7890 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
iptables -t nat -A PREROUTING -p tcp -i eth1 --dport 7890 -j DNAT --to 192.168.1.3:7890
iptables -t nat -A PREROUTING -p udp -i eth1 --dport 7890 -j DNAT --to 192.168.1.3:7890
#============vnc 5800, 59000=================
iptables -A FORWARD -i eth1 -p tcp --dport 5800:5900 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -i eth1 -p udp --dport 5800:5900 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
iptables -t nat -A PREROUTING -p tcp -i eth1 --dport 5800:5900 -j DNAT --to 192.168.1.1:5800-5900
iptables -t nat -A PREROUTING -p tcp -i eth1 --dport 5800:5900 -j DNAT --to 192.168.1.1:5800-5900
#=================Libera vis.cameras
iptables -A FORWARD -i eth1 -p tcp --dport 1999 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -i eth1 -p udp --dport 1999 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
iptables -t nat -A PREROUTING -p tcp -i eth1 --dport 1999 -j DNAT --to 192.168.1.253:1999
iptables -t nat -A PREROUTING -p udp -i eth1 --dport 1999 -j DNAT --to 192.168.1.253:1999
#==============dropa o resto============
iptables -A FORWARD -s 192.168.1.0/24 -p tcp -j DROP
iptables -A FORWARD -i eth1 -p tcp -j DROP