+ Responder ao Tópico



  1. #1
    thiagog
    Visitante

    Padrão regra IPTABLES (bloqueios)

    ola a todos,
    tenho uma rede normal com 03 SEGMENTOS que encontram-se assim:

    [internet]-------[FW-iptables]------------(dmz-100.100.100.0/16)
    |__________(lan-172.16.0.0/16)

    na DMZ estao servidores de Terminal Service, SMTP, pop3, imap etc
    todos tem NAT 1:1 declarados e CADA IP VALIDO tem um ALIAS na interface eth0 (sendo eth0:0, eth0:1, eth0:2 e assim por diante)

    01. como faco para liberar soh as portas necessarias e bloquear as outras e logar as tentativas de acesso?

    02. e por que nao consigo filtrar por interface do TIPO ALIAS ? ethx:y ?

    Ex: em uma das regras abaixo eu preciso liberar apenas SMTP e POP3 e o resto irei negar e logar (onde tem o srvmail )

    minhas regras

    #!/bin/bash

    #limpando tabelas
    iptables -F &&
    iptables -X &&
    iptables -t nat -F &&
    iptables -t nat -X &&

    #variaveis de ambiente

    int_ext="200.200.200.162"
    int_dmz="100.100.100.30"
    int_interna="172.16.0.1"

    #Libera o loopback
    iptables -A OUTPUT -p tcp --syn -s 127.0.0.1/255.0.0.0 -j ACCEPT

    #liberando acesso interno da rede

    #iptables -A FORWARD -s 200.254.254.251 -d 200.200.200.162/32 -p tcp --dport 4899 -j ACCEPT

    #iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
    #iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT

    #iptables -A FORWARD -p tcp --dport 80 -s 0/0 -i eth0 -o eth1 -j ACCEPT
    #iptables -A FORWARD -p tcp --dport 10000 -s 0/0 -i eth0 -o eth1 -j ACCEPT

    #iptables -A INPUT -j ACCEPT &&
    #iptables -A OUTPUT -j ACCEPT &&
    #iptables -A FORWARD -j ACCEPT &&

    #iptables -A INPUT -p tcp --syn -s 172.16.0.0/255.255.0.0 -j ACCEPT &&
    #iptables -A OUTPUT -p tcp --syn -s 172.16.0.0/255.255.0.0 -j ACCEPT &&
    #iptables -A FORWARD -p tcp --syn -s 172.16.0.0/255.255.0.0 -j ACCEPT &&

    #nat 1:1

    #iptables -t nat -A PREROUTING -s 172.16.0.10/32 -i eth2 -d 0/0 -p tcp --dport 80 -j DNAT --to 172.16.0.4:3128

    #iptables -t nat -A PREROUTING -p tcp -d 200.200.200.165 -i eth2 -j DNAT --to 100.100.100.50
    #iptables -t nat -A PREROUTING -p tcp -d 200.200.200.165 -i eth2 -j DNAT --to 100.100.100.50

    #iptables -t nat -A PREROUTING -d $srvmail -p tcp --dport 11000 -j DNAT --to $srvmail_int:10000

    #iptables -A PREROUTING -t nat -d 200.200.200.163 -j DNAT --to 100.100.100.2
    #iptables -A POSTROUTING -t nat -s 100.100.100.2 -j SNAT --to 200.200.200.163

    iptables -A PREROUTING -t nat -d 200.200.200.163 -j DNAT --to 100.100.100.50
    iptables -A POSTROUTING -t nat -s 100.100.100.50 -j SNAT --to 200.200.200.163

    iptables -A PREROUTING -t nat -d 200.200.200.167 -j DNAT --to 100.100.100.46
    iptables -A POSTROUTING -t nat -s 100.100.100.46 -j SNAT --to 200.200.200.167

    iptables -A PREROUTING -t nat -d 200.200.200.168 -j DNAT --to 100.100.100.47
    iptables -A POSTROUTING -t nat -s 100.100.100.47 -j SNAT --to 200.200.200.168

    #iptables -A PREROUTING -t nat -d 200.200.200.165 -j DNAT --to 100.100.100.10
    #iptables -A POSTROUTING -t nat -s 100.100.100.10 -j SNAT --to 200.200.200.165

    iptables -A PREROUTING -t nat -d 200.200.200.165 -j DNAT --to 100.100.100.50
    #iptables -A POSTROUTING -t nat -s 100.100.100.50 -j SNAT --to 200.200.200.165

    #iptables -A PREROUTING -t nat -d 200.200.200.172 -j DNAT --to 100.100.100.35
    #iptables -A POSTROUTING -t nat -s 100.100.100.35 -j SNAT --to 200.200.200.172

    #compartilhando a web na rede interna
    iptables -t nat -A POSTROUTING -s 172.16.0.0/255.255.0.0 -o eth0 -j MASQUERADE &&
    iptables -t nat -A POSTROUTING -s 100.100.0.0/255.255.0.0 -o eth0 -j MASQUERADE &&
    echo 1 > /proc/sys/net/ipv4/ip_forward &&

    # Protecao contra port scanners ocultos
    #iptables -A INPUT -p tcp --tcp-flags SYN,ACK,FIN,RST RST -m limit --limit 1/s -j ACCEPT

    # Bloqueando tracertroute
    #iptables -A INPUT -p udp -s 0/0 -i eth1 --dport 33435:33525 -j DROP

    #Protecoes contra ataques
    #iptables -A INPUT -m state --state INVALID -j DROP

    #Configura aliases
    /etc/sysconfig/aliases.sh &&
    #termina
    echo "Iptables Pronto"

    Obrigado,

  2. #2
    thiagog
    Visitante

    Padrão help...

    alguem pode dar uma força ai .... ?
    valeus, :? :toim:

  3. #3
    charadaa
    Visitante

    Padrão regra IPTABLES (bloqueios)

    para logar as tentativas de acesso aconselho você a usar o snort agora realmente o iptables não trabalha com as interfaces virtuais, declare as regras com ips ao inves de interfaces tire o -i de suas regras