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

Re: Firewall com 2 placas na mesma rede.



Quoting Miguel Da Silva - Centro de Matemática <mdasilva@fing.edu.uy>:

Vou colocar novamente o endereço do diagrama para quem consultar a lista mais tarde poder ver do que estamos falando...

http://www.cmat.edu.uy/~mdasilva/img/diagrama_red_cmat.jpg


Caro Miguel,

Confesso que nunca tentei isso, mas creio ser plenamente possível, bastando apenas redirecionar o fluxo para 192.168.42.1 para eth0, o fluxo para 192.168.42.0/24 para eth1 e o fluxo padrão para eth0 com roteador 192.168.42.1.

    Vamos ver se isso funciona:

1. Apague todas as rotas:

# route -n
Tabela de Roteamento IP do Kernel
Destino         Roteador        MáscaraGen.    Opções Métrica Ref   Uso Iface
192.168.42.0    0.0.0.0         255.255.255.0   U     0      0        0 eth0
0.0.0.0         192.168.42.1    0.0.0.0         UG    0      0        0 eth0

# route del default gw 192.168.42.1

# route del -net 192.168.42.0 netmask 255.255.255.0

# route -n
Tabela de Roteamento IP do Kernel
Destino         Roteador        MáscaraGen.    Opções Métrica Ref   Uso Iface

2. Definir novas rotas:

# route add default gw 192.168.42.1 eth0
# route add -net 192.168.42.0 netmask 255.255.255.0 eth1
# route add 192.168.42.1 eth0
# ping 192.168.42.1 # roteador
# ping 192.168.42.2 # placa ligada ao roteador
# ping 192.168.42.3 # placa ligada a rede administrada
# ping 192.168.42.(4-254) # algumas máquinas da rede administrada

3. Funcionando tudo acima, vamos ao firewall:

# 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 DROP
# for i in /proc/sys/net/ipv4/conf/*/rp_filter; do echo 1 >$i; done
# echo 1 >/proc/sys/net/ipv4/ip_forward
# iptables -A INPUT -i lo -j ACCEPT
# iptables -A INPUT -s 192.168.42.0/24 -i eth1 -j ACCEPT
# iptables -A FORWARD -d 192.168.42.0/24 -i eth0 -o eth1 -j ACCEPT
# iptables -A FORWARD -s 192.168.42.0/24 -i eth1 -o eth0 -j ACCEPT
# iptables -A INPUT -p icmp -m limit --limit 1/s -j ACCEPT
# iptables -A INPUT -m state --state ! ESTABLISHED,RELATED -j DROP
# iptables -A INPUT -j ACCEPT
# iptables -t nat -A POSTROUTING -s 192.168.42.0/24 -o eth0 -j SNAT --to 192.168.42.2

4. Conta para a gente o resultado!

--
Atenciosamente,

                Junior Polegato

                Um peregrino de problemas; Um pergaminho de soluções!
                Página Profissional: http://www.juniorpolegato.com.br



Reply to: