abiazon
(usa Red Hat)
Enviado em 24/08/2022 - 13:29h
pessoal, resolvi insistir um pouco mais com o cenário que eu possuo e agora tenho a seguinte situação: 2 interfaces de rede
Interface 1 Internet
enp0s3 (link)
Interface 2 Rede Interna
enp0s4 192.168.0.0/24
enp0s4:1 192.168.11.0/24 (virtual)
--------Arquivo DHCP:
INTERFACES="enp0s4:1";
option domain-name "oel6.com";
#SERVIDOR DNS PARA AS ESTACOES
option domain-name-servers 192.168.11.1, 8.8.8.8;
#Tipo de atualizacao do DNS
ddns-update-style none;
db-time-format local;
authoritative;
log-facility local7;
default-lease-time 21600;
max-lease-time 7200;
subnet 192.168.11.0 netmask 255.255.255.0 {
range 192.168.11.2 192.168.11.51;
option subnet-mask 255.255.255.0;
option routers 192.168.11.1;
option time-offset -10800;
}
--------route
route
Tabela de Roteamento IP do Kernel
Destino Roteador MáscaraGen. Opções Métrica Ref Uso Iface
default 200.?.?.? 0.0.0.0 UG 0 0 0 enp0s3
link-local * 255.255.0.0 U 1002 0 0 enp0s3
link-local * 255.255.0.0 U 1003 0 0 enp0s4
192.168.0.0 * 255.255.255.0 U 0 0 0 enp0s4
192.168.0.0 * 255.255.0.0 U 0 0 0 enp0s4 --nao sei onde esta definida esta rota
192.168.11.0 * 255.255.255.0 U 0 0 0 enp0s4
200.?.?.? * 255.255.255.240 U 0 0 0 enp0s3
O problema é que as estações com ip Fixo pingam as estações com ip fornecidos por dhcp, porém as estações com ip fornecidos com dhcp nao pingam as estações com ip fixo. E pra piorar a situação as impressoras de rede com ip fixo são pingadas pelos equipamentos com ip fornecidos por dhcp.
Equipamentos com IP Fixo possuem a seguinte cofiguração
IP: 192.168.0.100
Mascara: 255.255.255.0
Gateway: 192.168.0.80 (ip do servidor placa enp0s4)
DNS: 8.8.8.8, 8.8.4.4
Não acrescentei nenhuma regra ao firewall nem rotas.
---firewall
#carregar modulos
modprobe iptable_nat
modprobe ip_conntrack
modprobe ip_conntrack_ftp
modprobe ip_nat_ftp
modprobe ipt_LOG
modprobe ipt_string
INTERNET(){
iptables -t nat -A POSTROUTING -o enp0s3 -j MASQUERADE
}
LIMPAR(){
#limpar regras
iptables -F INPUT
iptables -F OUTPUT
iptables -F FORWARD
iptables -F
iptables -t nat -F
iptables -t mangle -F
iptables -X
iptables -t nat -X
iptables -t mangle -X
iptables -Z
iptables -t nat -Z
iptables -t mangle -Z
}
start() {
#limpando regras
LIMPAR
echo "Iniciando Firewall"
###politica padrao
iptables -P INPUT DROP
iptables -P FORWARD DROP
iptables -P OUTPUT ACCEPT
#compartilhando a internet
INTERNET
#Politicas de segurança
echo "Implementação de politicas de segurança"
#impede falsear pacote
echo 0 > /proc/sys/net/ipv4/conf/all/accept_source_route
#Pedido de descobrimento de rotas de roteamento
echo 0 > /proc/sys/net/ipv4/conf/all/accept_redirects
#Risco de DoS
echo 1 > /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts
#So inicia a conexao quando recebe a confirmacao, diminuindo a banda gasta
echo 1 > /proc/sys/net/ipv4/tcp_syncookies
#Protecao contra spoof de IP
echo 1 > /proc/sys/net/ipv4/conf/default/rp_filter
###INPUT
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -m state --state INVALID -j DROP
#libera loopback e interface interna
iptables -A INPUT -i lo -j ACCEPT
iptables -A INPUT -i enp0s4 -j ACCEPT
#liberar ssh interno
iptables -A INPUT -p tcp -i enp0s4 --dport 22 -j ACCEPT
#libera Oracle
iptables -A INPUT -i enp0s4 -p tcp --dport 1521 -j ACCEPT
iptables -A INPUT -i enp0s4 -p tcp --dport 1158 -j ACCEPT
iptables -A INPUT -i enp0s4 -p tcp --dport 5500 -j ACCEPT
iptables -A INPUT -i enp0s4 -p tcp --dport 3128 -j ACCEPT
iptables -A INPUT -i enp0s4 -p udp --dport 53 -j ACCEPT
#Liberando o Samba
iptables -A INPUT -i enp0s4 -p tcp --dport 135 -j ACCEPT
iptables -A INPUT -i enp0s4 -p tcp --dport 137 -j ACCEPT
iptables -A INPUT -i enp0s4 -p tcp --dport 138 -j ACCEPT
iptables -A INPUT -i enp0s4 -p tcp --dport 445 -j ACCEPT
iptables -A INPUT -i enp0s4 -p tcp --dport 139 -j ACCEPT
iptables -A INPUT -i enp0s4 -p tcp --dport 901 -j ACCEPT
iptables -A INPUT -i enp0s4 -p tcp --dport 631 -j ACCEPT
iptables -A INPUT -i enp0s4 -p udp --dport 631 -j ACCEPT
iptables -A INPUT -i enp0s4 -p tcp --dport 389 -j ACCEPT
iptables -A INPUT -i enp0s4 -p tcp --dport 528 -j ACCEPT
iptables -A INPUT -i enp0s4 -p tcp --dport 151 -j ACCEPT
###forward
iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -i lo -j ACCEPT
iptables -A FORWARD -p icmp -j ACCEPT
#permite whatsapp
iptables -A FORWARD -p udp --dport 3478 -j ACCEPT # WhatsApp
iptables -A FORWARD -p tcp --dport 5222 -j ACCEPT # WhatsApp
iptables -A FORWARD -p tcp --dport 5223 -j ACCEPT # WhatsApp
#permite passagem de pacotes para TS
iptables -A FORWARD -i enp0s3 -p tcp --dport 3385 -j ACCEPT
iptables -A FORWARD -i enp0s3 -p tcp --dport 3389 -j ACCEPT
iptables -A FORWARD -i enp0s3 -p tcp --dport 3382 -j ACCEPT
iptables -A FORWARD -i enp0s3 -p tcp --dport 3381 -j ACCEPT
#permite passagem de pacotes para o software hfs(htp File Server)
iptables -A FORWARD -i enp0s3 -p tcp --dport 280 -j ACCEPT
iptables -A FORWARD -i enp0s4 -p tcp --dport 25 -j ACCEPT
iptables -A FORWARD -i enp0s4 -p tcp --dport 465 -j ACCEPT
iptables -A FORWARD -i enp0s4 -p udp --dport 53 -j ACCEPT
iptables -A FORWARD -i enp0s4 -p tcp --dport 110 -j ACCEPT
iptables -A FORWARD -i enp0s4 -p tcp --dport 995 -j ACCEPT
iptables -A FORWARD -i enp0s4 -p tcp --dport 587 -j ACCEPT
### Liberando FTP porta 2121
iptables -A FORWARD -p tcp -i enp0s4 --dport 1024:65000 -m conntrack --ctstate NEW,ESTABLISHED,RELATED -j ACCEPT
#FTP Externo
iptables -A FORWARD -p tcp -i enp0s4 -o enp0s3 -m multiport --dport 20,21 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -p tcp -o enp0s4 -i enp0s3 -m multiport --dport 20,21 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
#RECEITA FEDERAL
iptables -A FORWARD -p tcp --dport 3456 -j ACCEPT
iptables -A FORWARD -p udp --dport 3456 -j ACCEPT
#CAT 4.0
iptables -A FORWARD -i enp0s4 -d 200.152.32.148 -p tcp --dport 5017 -j ACCEPT
iptables -A FORWARD -s 200.152.32.148 -i enp0s4 -p tcp --dport 5017 -j ACCEPT
iptables -A FORWARD -i enp0s4 -d 200.152.32.148 -p tcp --dport 5022 -j ACCEPT
iptables -A FORWARD -s 200.152.32.148 -i enp0s4 -p tcp --dport 5022 -j ACCEPT
iptables -A FORWARD -i enp0s4 -p tcp -m multiport --dport 5017,5022 -j ACCEPT
#condominio boleto on-line
iptables -A FORWARD -p tcp --dport 90 -j ACCEPT
# transmissao Conectividade Social
iptables -A FORWARD -p tcp --dport 2361 -j ACCEPT
# Transmissao RAIS
iptables -A FORWARD -p tcp --dport 3007 -j ACCEPT
###PREROUTING
#liberar sites para nao passar pelo squid
for i in $(cat /etc/init.d/sites_noproxy)
do
iptables -t nat -A PREROUTING -s 192.168.0.0/24 -d $i -p tcp --dport 80 -j ACCEPT
done
#proxy transparente
iptables -t nat -A PREROUTING -s 192.168.0.0/24 -p tcp --dport 80 -j REDIRECT --to-port 3128
#testes http porta 80 e 443
iptables -A INPUT -i enp0s4 -p tcp --dport 80 -j ACCEPT
iptables -A INPUT -i enp0s4 -p tcp --dport 443 -j ACCEPT
iptables -A FORWARD -i enp0s4 -p tcp --dport 80 -j ACCEPT
iptables -A FORWARD -i enp0s4 -p tcp --dport 443 -j ACCEPT
#redirecionamentos
#terminal service
iptables -t nat -A PREROUTING -i enp0s3 -p tcp --dport 3385 -j DNAT --to 192.168.0.101:3385
iptables -t nat -A PREROUTING -i enp0s3 -p tcp --dport 3389 -j DNAT --to 192.168.0.205:3389
iptables -t nat -A PREROUTING -i enp0s3 -p tcp --dport 3382 -j DNAT --to 192.168.0.2
iptables -t nat -A PREROUTING -i enp0s3 -p tcp --dport 3381 -j DNAT --to 192.168.0.120:3381
iptables -t nat -A PREROUTING -p tcp --dport 2122 -j DNAT --to 192.168.0.202:21
iptables -t nat -A PREROUTING -p tcp --dport 20 -j DNAT --to 192.168.0.202:20
#software HFS
iptables -t nat -A PREROUTING -i enp0s3 -p tcp --dport 280 -j DNAT --to 192.168.0.101:280
iptables -t nat -A PREROUTING -p tcp --dport 280 -j DNAT --to 192.168.0.101:280
}