hugo.andrade
(usa Red Hat)
Enviado em 15/08/2009 - 09:17h
Bom dia,
Estou tendo problemas para fazer o redirecinamento da porta do terminal server.
Tudo que já tentei nao funciona. Creio que seja alguma coisa no meu script que ta barrando. Como sou iniciante em iptables gostaria da ajuda de vcs.
Segue meu sript abaixo:
#!/bin/bash
/sbin/modprobe ip_tables
/sbin/modprobe ip_conntrack
/sbin/modprobe iptable_filter
/sbin/modprobe iptable_mangle
/sbin/modprobe iptable_nat
/sbin/modprobe ipt_LOG
/sbin/modprobe ipt_limit
/sbin/modprobe ipt_state
/sbin/modprobe ipt_REDIRECT
/sbin/modprobe ipt_owner
/sbin/modprobe ipt_REJECT
/sbin/modprobe ipt_MASQUERADE
/sbin/modprobe ip_conntrack_ftp
/sbin/modprobe ip_nat_ftp
iptables -X
iptables -Z
iptables -F INPUT
iptables -F OUTPUT
iptables -F FORWARD
iptables -F -t nat
iptables -F -t mangle
# Politicas padrao #
iptables -t filter -P INPUT DROP
iptables -t filter -P OUTPUT ACCEPT
iptables -t filter -P FORWARD DROP
iptables -t nat -P PREROUTING ACCEPT
iptables -t nat -P OUTPUT ACCEPT
iptables -t nat -P POSTROUTING ACCEPT
iptables -t mangle -P PREROUTING ACCEPT
iptables -t mangle -P OUTPUT ACCEPT
# Manter conexoes jah estabelecidas para nao parar
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A OUTPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
# Aceita todo o trafego vindo do loopback e indo pro loopback
iptables -t filter -A INPUT -i lo -j ACCEPT
iptables -A INPUT -p icmp --icmp-type echo-request -m limit --limit 20/m -j ACCEPT
iptables -A FORWARD -p icmp --icmp-type echo-request -m limit --limit 20/m -j ACCEPT
iptables -A INPUT -p tcp --tcp-flags SYN,ACK,FIN,RST RST -m limit --limit 20/m -j ACCEPT
iptables -A INPUT -p udp -s 0/0 -i eth0 --dport 33435:33525 -j REJECT
iptables -A INPUT -m state --state INVALID -j REJECT
iptables -A INPUT -i eth0 -p tcp --dport 22 -j ACCEPT
iptables -A INPUT -i eth0 -p tcp --dport 21 -j ACCEPT
iptables -A INPUT -i eth1 -p tcp --dport 22 -j ACCEPT
iptables -A INPUT -i eth1 -p tcp --dport 3128 -j ACCEPT
iptables -A INPUT -i eth1 -p tcp --dport 80 -j ACCEPT
iptables -A INPUT -i eth1 -p tcp --dport 21 -j ACCEPT
iptables -A INPUT -i eth1 -p tcp --dport 3000 -j ACCEPT
iptables -A INPUT -p tcp --dport 42307 -j ACCEPT
iptables -A INPUT -p udp --dport 4757 -j ACCEPT
#MAQUINAS QUE PASSAM PRO FORA DO FIREWALL
iptables -A FORWARD -p tcp -s 131.195.2.201 -j ACCEPT #SERVER-01
iptables -A INPUT -p tcp -s 131.195.2.201 -j ACCEPT #SERVER-01
#Bloqueio MSN
iptables -A FORWARD -s 131.195.2.0/24 -p tcp --dport 1863 -j REJECT
iptables -A FORWARD -s 131.195.2.0/24 -p tcp --dport 5190 -j REJECT
iptables -A FORWARD -i eth0 -p tcp --dport 2222 -j ACCEPT
iptables -A FORWARD -i eth0 -p tcp --dport 22 -j ACCEPT
iptables -A FORWARD -i eth0 -p tcp --dport 110 -j ACCEPT
iptables -A FORWARD -i eth0 -p tcp --dport 995 -j ACCEPT
iptables -A FORWARD -i eth0 -p tcp --dport 25 -j ACCEPT
iptables -A FORWARD -i eth0 -p tcp --dport 465 -j ACCEPT
iptables -A FORWARD -i eth0 -p tcp --dport 2121 -j ACCEPT
iptables -A FORWARD -i eth0 -p udp --dport 21 -j ACCEPT
iptables -A FORWARD -i eth0 -p udp --dport 20 -j ACCEPT
iptables -A FORWARD -i eth0 -p tcp --dport 53 -j ACCEPT
iptables -A FORWARD -i eth0 -p udp --dport 53 -j ACCEPT
iptables -A FORWARD -i eth1 -p tcp --dport 2222 -j ACCEPT
iptables -A FORWARD -i eth1 -p tcp --dport 22 -j ACCEPT
iptables -A FORWARD -i eth1 -p tcp --dport 110 -j ACCEPT
iptables -A FORWARD -i eth1 -p tcp --dport 995 -j ACCEPT
iptables -A FORWARD -i eth1 -p tcp --dport 25 -j ACCEPT
iptables -A FORWARD -i eth1 -p tcp --dport 465 -j ACCEPT
iptables -A FORWARD -i eth1 -p tcp --dport 2121 -j ACCEPT
iptables -A FORWARD -i eth1 -p udp --dport 21 -j ACCEPT
iptables -A FORWARD -i eth1 -p udp --dport 20 -j ACCEPT
iptables -A FORWARD -i eth1 -p tcp --dport 53 -j ACCEPT
iptables -A FORWARD -i eth1 -p udp --dport 53 -j ACCEPT
#REGRAS CONTABILIDADE
#DCTF
iptables -A FORWARD -p tcp --dport 3456 -j ACCEPT
#DPI
iptables -A FORWARD -p tcp --dport 24001 -j ACCEPT
#TED
iptables -A INPUT -p tcp --dport 8017 -j ACCEPT
iptables -A FORWARD -p tcp --dport 8017 -j ACCEPT
#SEFIP
iptables -A FORWARD -p tcp --dport 2004 -j ACCEPT
iptables -A INPUT -p tcp --dport 2631 -j ACCEPT
iptables -A FORWARD -p tcp --dport 2631 -j ACCEPT
iptables -A FORWARD -p tcp --dport 1494 -j ACCEPT
iptables -A FORWARD -p tcp --dport 5017 -j ACCEPT
iptables -A FORWARD -p tcp -i eth1 --dport 9090 -j ACCEPT
#CONETIVIDADE SOCIAL
iptables -t nat -A PREROUTING -s 131.195.2.52 -d 0.0.0.0/0 -j ACCEPT #CONTABIL4
iptables -t nat -A PREROUTING -s 131.195.2.28 -d 0.0.0.0/0 -j ACCEPT #PESSOAL1
iptables -t nat -A PREROUTING -i eth1 -p tcp -d ! 200.201.174.0/24 --dport 80 -j REDIRECT --to-port 3128
#TERMINAL SERVER
iptables -A INPUT -p tcp --dport 3389 -j ACCEPT
iptables -A FORWARD -p tcp --dport 3389 -j ACCEPT
# Mascaramento de rede para acesso externo #
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
iptables -t nat -A PREROUTING -i eth1 -p tcp --dport 80 -j REDIRECT --to-port 3128
iptables -t nat -A PREROUTING -i eth1 -p tcp --dport 8080 -j REDIRECT --to-port 3128
#Bloqueia todo o resto
iptables -A INPUT -p tcp --syn -j DROP
iptables -A INPUT -p tcp -j DROP
iptables -A INPUT -p udp -j DROP