Enviado em 18/01/2018 - 11:13h
[UPDATE1] Fiz uma pesquisa mais minuciosa e consegui fazer se enxergar com a seguinte regra:iptables -A FORWARD -s 172.16.8.0/24 -d 192.168.100.0/24 -j ACCEPT
iptables -A FORWARD -d 172.16.8.0/24 -s 192.168.100.0/24 -j ACCEPT
iptables -A FORWARD -s 192.168.100.0/24 -d 172.16.8.0/24 -j ACCEPT
iptables -A FORWARD -d 192.168.100.0/24 -s 172.16.8.0/24 -j ACCEPT
eth0: 172.16.8.254/24
eth1: 10.0.0.0/8 > ppp1 (internet)
eth2: 192.168.100.247/24
route add -net 192.168.100.0 netmask 255.255.255.0 dev eth0
route add -net 172.16.8.0 netmask 255.255.255.0 dev eth2
iptables -I FORWARD -i eth0 -o eth1 -j ACCEPT
iptables -I FORWARD -i eth1 -o eth0 -j ACCEPT
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
iptables -t nat -A POSTROUTING -o eth1 -j MASQUERADE
iptables -I FORWARD -s 172.16.8.0 -d 192.168.100.0 -j ACCEPT
iptables -I FORWARD -s 192.168.100.0 -d 172.16.8.0 -j ACCEPT
iptables -I FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
#!/bin/sh
#
### BEGIN INIT INFO
# Provides: firewall
# Required-Start: $local_fs $remote_fs $network $syslog
# Required-Stop: $local_fs $remote_fs $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start firewall at boot time
# Description: Enable service provided by firewall.
### END INIT INFO
iniciar(){
# IP do servidor SQUID
SQUID_SERVER="172.16.8.254"
# Interface que se conecta com a internet
INTERNET="ppp0"
# Interface da rede local
LAN_IN="eth0"
# Interface da rede Rocket M5
ROCKET="eth2"
# Porta do SQUID
SQUID_PORT="3128"
# LIMPAR FIREWALL
iptables -F
iptables -X
iptables -X -t filter
iptables -F -t filter
iptables -t nat -F
iptables -t nat -X
iptables -t mangle -F
iptables -t mangle -X
# CARREGAR MÓDULOS PARA NAT E SUPORTE PARA IP CONTRACK
modprobe ip_conntrack
modprobe ip_conntrack_ftp
modprobe iptable_nat
modprobe tun
modprobe ipt_string
# COMPARTILHAMENTO DE INTERNET.
echo 1 > /proc/sys/net/ipv4/ip_forward
echo 1 > /proc/sys/net/ipv4/tcp_syncookies
# DEFINIR POLITICAS DE ACESSO
iptables -P INPUT DROP
iptables -P OUTPUT ACCEPT
# ACESSO ILIMITADO AO LOOPBACK
iptables -A INPUT -i lo -j ACCEPT
iptables -A OUTPUT -o lo -j ACCEPT
# LIBERAÇÃO DE PORTAS
iptables -A INPUT -p tcp --dport 22 -j ACCEPT
iptables -A INPUT -p tcp --dport 80 -j ACCEPT
iptables -A INPUT -p tcp --dport 1723 -j ACCEPT
iptables -A INPUT -p tcp --dport 3000 -j ACCEPT
iptables -A INPUT -p tcp --dport 3128 -j ACCEPT
# PERMITIR UDP, DNS E FTP PASSIVO
iptables -A INPUT -i $INTERNET -m state --state ESTABLISHED,RELATED -j ACCEPT
# DEFINIR ESTE SISTEMA COMO O ROTEADOR PADRÃO PARA O RESTO DA LAN
iptables --table nat --append POSTROUTING --out-interface $INTERNET -j MASQUERADE
iptables --append FORWARD --in-interface $LAN_IN -j ACCEPT
# ACESSO ILIMITADO PELA LAN
iptables -A INPUT -i $LAN_IN -j ACCEPT
iptables -A OUTPUT -o $LAN_IN -j ACCEPT
# NAT PARA A PORTA 80 SOLICITADA PELA LAN PARA A PORTA DO SQUID 3128 ($SQUID_PORT) PROXY TRANSPARENTE
iptables -t nat -I PREROUTING -p tcp -i $LAN_IN --dport 80 -j REDIRECT --to-port 3128
# REJEITAR O RESTO E CRIAR LOG
iptables -A INPUT -j LOG
iptables -A INPUT -j DROP
echo "Firewall Habilitado"
}
parar(){
iptables -F
iptables -X
iptables -X -t filter
iptables -F -t filter
iptables -t nat -F
iptables -t nat -X
iptables -t mangle -F
iptables -t mangle -X
echo "Firewall desabilidatado"
}
case "$1" in
"start") iniciar ;;
"stop") parar ;;
"restart") parar; iniciar ;;
*) echo "Use os parâmetros start, stop ou restart"
esac