ericktorres
(usa )
Enviado em 08/08/2016 - 15:02h
Buckminster escreveu:
Posta aqui todo o script.
PATH=/sbin:/usr/sbin:/bin:/usr/bin
#
ifconfig eth0 192.168.1.1 netmask 255.255.255.240
ifconfig eth0:0 192.168.1.33 netmask 255.255.255.240
ifconfig eth0:1 192.168.1.49 netmask 255.255.255.240
ifconfig eth0:2 192.168.1.65 netmask 255.255.255.240
ifconfig eth0:3 192.168.1.81 netmask 255.255.255.240
ifconfig eth0:4 192.168.1.97 netmask 255.255.255.240
ifconfig eth0:5 192.168.1.113 netmask 255.255.255.240
ifconfig eth0:6 192.168.1.129 netmask 255.255.255.240
ifconfig eth0:7 192.168.1.145 netmask 255.255.255.248
ifconfig eth0:8 192.168.1.153 netmask 255.255.255.248
ifconfig eth0:9 192.168.1.161 netmask 255.255.255.248
ifconfig eth0:10 192.168.1.169 netmask 255.255.255.248
ifconfig eth0:11 192.168.1.177 netmask 255.255.255.248
ifconfig eth0:12 192.168.1.185 netmask 255.255.255.248
ifconfig eth0:13 192.168.1.193 netmask 255.255.255.248
ifconfig eth0:14 192.168.1.201 netmask 255.255.255.248
ifconfig eth0:15 192.168.1.209 netmask 255.255.255.248
ifconfig eth0:16 192.168.1.217 netmask 255.255.255.248
ifconfig eth0:17 192.168.1.225 netmask 255.255.255.224
ifconfig eth0:18 192.168.10.1 netmask 255.255.255.224
ifconfig eth0:19 192.168.10.33 netmask 255.255.255.224
ifconfig eth0:20 192.168.10.65 netmask 255.255.255.192
ifconfig eth0:21 192.168.10.129 netmask 255.255.255.128
ifconfig eth0:22 192.168.30.1 netmask 255.255.255.0
#
#Desvio
iptables -t nat -N PROXY
iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j PROXY
iptables -t nat -A PROXY -d XXXXXXX -j RETURN
iptables -t nat -A PREROUTING -i eth0 -s 192.168.1.0/24 -d XXXXXXX -p tcp --dport 80 -j ACCEPT
#Gerar Logs IPTABLES
#iptables -A INPUT -j LOG
#iptables -A FORWARD -j LOG
#
iptables -P INPUT DROP
iptables -P OUTPUT DROP
iptables -P FORWARD DROP
#
iptables -A INPUT -i lo -j ACCEPT
iptables -A FORWARD -i lo -j ACCEPT
#
iptables -A INPUT -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
iptables -A OUTPUT -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
#iptables -A FORWARD -p icmp --icmp-type echo-request -m limit --limit 1/s -j ACCEPT
#iptables -A FORWARD -p icmp --icmp-type echo-request -j DROP
#
# echo 'Visualizador de Trafego - INAV (Abertura de portas)'
# iptables -A INPUT -p tcp --dport 5000 -j ACCEPT
# iptables -A OUTPUT -p tcp --sport 5000 -j ACCEPT
#
iptables -A INPUT -p tcp --dport 23002 -j ACCEPT
iptables -t nat -I PREROUTING -d XXXXXX -p tcp -m tcp --dport 23002 -j DNAT --to-destination 192.168.1.9:23002
iptables -t nat -I POSTROUTING -d 192.168.1.9 -s 0/0 -p tcp --dport 23002 -j SNAT --to XXXX
#
#
#Desvio TI
iptables -t nat -A PREROUTING -s 192.168.1.110 -j ACCEPT
iptables -t nat -A PREROUTING -p tcp --dport 80 -s 192.168.1.110 -j RETURN
iptables -A FORWARD -s 192.168.1.110 -j ACCEPT
iptables -t nat -A PREROUTING -s 192.168.1.34 -j ACCEPT
iptables -t nat -A PREROUTING -p tcp --dport 80 -s 192.168.1.34 -j RETURN
iptables -A FORWARD -s 192.168.1.34 -j ACCEPT
#iptables -t nat -A PREROUTING -s 192.168.1.146 -j ACCEPT
#iptables -t nat -A PREROUTING -p tcp --dport 80 -s 192.168.1.46 -j RETURN
#iptables -A FORWARD -s 192.168.1.146 -j ACCEPT
#
#Abertura de porta e Redirecionamento
iptables -t nat -A PREROUTING -s 192.168.1.11 -j ACCEPT
iptables -t nat -A PREROUTING -p tcp --dport 6036 -j DNAT --to-destination 192.168.1.11:6036
iptables -A FORWARD -s 192.168.1.11 -p tcp --dport 6036 -j ACCEPT
iptables -t nat -A PREROUTING -d XXXXXX -p tcp -m tcp --dport 6036 -j DNAT --to-destination 192.168.1.11:6036
iptables -t nat -A PREROUTING -p tcp --dport 3000 -j DNAT --to-destination 192.168.1.11:3000
iptables -A FORWARD -s 192.168.1.11 -p tcp --dport 3000 -j ACCEPT
iptables -t nat -A PREROUTING -d XXXXXX -p tcp -m tcp --dport 3000 -j DNAT --to-destination 192.168.1.11:3000
iptables -t nat -A PREROUTING -p tcp --dport 3006 -j DNAT --to-destination 192.168.1.11:3006
iptables -A FORWARD -s 192.168.1.11 -p tcp --dport 3006 -j ACCEPT
iptables -t nat -A PREROUTING -d XXXXX -p tcp -m tcp --dport 3006 -j DNAT --to-destination 192.168.1.11:3006
#NAGIOS
iptables -t nat -A PREROUTING -s 192.168.1.37 -j ACCEPT
iptables -t nat -A PREROUTING -p tcp --dport 5224 -j DNAT --to-destination 192.168.1.37:80
iptables -A FORWARD -s 192.168.1.37 -p tcp --dport 80 -j ACCEPT
iptables -t nat -A PREROUTING -d XXXXX -p tcp -m tcp --dport 5224 -j DNAT --to-destination 192.168.1.37:80
#
iptables -t nat -A PREROUTING -s 192.168.1.39 -j ACCEPT
iptables -t nat -A PREROUTING -p tcp --dport 5225 -j DNAT --to-destination 192.168.1.39:80
iptables -A FORWARD -s 192.168.1.39 -p tcp --dport 80 -j ACCEPT
iptables -t nat -A PREROUTING -d XXXXX -p tcp -m tcp --dport 5225 -j DNAT --to-destination 192.168.1.39:80
#
#Owncloud
#
#iptables -t nat -A PREROUTING -s 192.168.1.36 -j ACCEPT
#iptables -t nat -A PREROUTING -p tcp --dport 9001 -j DNAT --to-destination 192.168.1.36:80
#iptables -A FORWARD -s 192.168.1.36 -p tcp --dport 80 -j ACCEPT
#iptables -t nat -A PREROUTING -d XXXX -p tcp -m tcp --dport 9001 -j DNAT --to-destination 192.168.1.36:80
#
#Desvio squid
#iptables -t nat -A PREROUTING -s 192.168.1.36 -j ACCEPT
#iptables -t nat -A PREROUTING -p tcp --dport 80 -s 192.168.1.36 -j RETURN
#iptables -A FORWARD -s 192.168.1.36 -j ACCEPT
#iptables -t nat -A PREROUTING -s 192.168.1.36 -j ACCEPT
#iptables -t nat -A PREROUTING -p tcp --dport 80 -s 192.168.1.36 -j RETURN
#iptables -A FORWARD -s 192.168.1.36 -j ACCEPT
#Acesso as redes internas
route del -host 192.168.30.12 reject
iptables -A INPUT -d 192.168.1.0/255.255.255.224 -j ACCEPT
iptables -A INPUT -d 192.168.1.32/255.255.255.240 -j ACCEPT
iptables -A INPUT -d 192.168.1.48/255.255.255.240 -j ACCEPT
iptables -A INPUT -d 192.168.1.64/255.255.255.240 -j ACCEPT
iptables -A INPUT -d 192.168.1.80/255.255.255.240 -j ACCEPT
iptables -A INPUT -d 192.168.1.96/255.255.255.240 -j ACCEPT
iptables -A INPUT -d 192.168.1.112/255.255.255.240 -j ACCEPT
iptables -A INPUT -d 192.168.1.128/255.255.255.240 -j ACCEPT
iptables -A INPUT -d 192.168.1.144/255.255.255.248 -j ACCEPT
iptables -A INPUT -d 192.168.1.152/255.255.255.248 -j ACCEPT
iptables -A INPUT -d 192.168.1.160/255.255.255.248 -j ACCEPT
iptables -A INPUT -d 192.168.1.168/255.255.255.248 -j ACCEPT
iptables -A INPUT -d 192.168.1.176/255.255.255.248 -j ACCEPT
iptables -A INPUT -d 192.168.1.184/255.255.255.248 -j ACCEPT
iptables -A INPUT -d 192.168.1.192/255.255.255.248 -j ACCEPT
iptables -A INPUT -d 192.168.1.200/255.255.255.248 -j ACCEPT
iptables -A FORWARD -d 192.168.1.0/255.255.255.224 -j ACCEPT
iptables -A FORWARD -d 192.168.1.32/255.255.255.240 -j ACCEPT
iptables -A FORWARD -d 192.168.1.48/255.255.255.240 -j ACCEPT
iptables -A FORWARD -d 192.168.1.64/255.255.255.240 -j ACCEPT
iptables -A FORWARD -d 192.168.1.80/255.255.255.240 -j ACCEPT
iptables -A FORWARD -d 192.168.1.96/255.255.255.240 -j ACCEPT
iptables -A FORWARD -d 192.168.1.112/255.255.255.240 -j ACCEPT
iptables -A FORWARD -d 192.168.1.128/255.255.255.240 -j ACCEPT
iptables -A FORWARD -d 192.168.1.144/255.255.255.248 -j ACCEPT
iptables -A FORWARD -d 192.168.1.152/255.255.255.248 -j ACCEPT
iptables -A FORWARD -d 192.168.1.160/255.255.255.248 -j ACCEPT
iptables -A FORWARD -d 192.168.1.168/255.255.255.248 -j ACCEPT
iptables -A FORWARD -d 192.168.1.176/255.255.255.248 -j ACCEPT
iptables -A FORWARD -d 192.168.1.184/255.255.255.248 -j ACCEPT
iptables -A FORWARD -d 192.168.1.192/255.255.255.248 -j ACCEPT
iptables -A FORWARD -d 192.168.1.200/255.255.255.248 -j ACCEPT
#
#Acesso
iptables -A FORWARD -d 192.168.10.0/255.255.255.224 -j ACCEPT
#
#Acesso ao BD do sistema de ponto'
iptables -A FORWARD -p tcp --dport 3050 -j ACCEPT
#
#Liberar acesso da rede interna para a externa'
#FTP'
modprobe ip_nat_ftp
modprobe ip_conntrack_ftp
iptables -A INPUT -p tcp --dport 21 -j ACCEPT
iptables -A FORWARD -p tcp --dport 21 -j ACCEPT
#
#SSH'
iptables -A INPUT -p tcp -i eth+ --dport 22 -j ACCEPT
#
#SMTP'
iptables -A INPUT -p tcp -i eth+ --dport 587 -j ACCEPT
iptables -A FORWARD -p tcp -i eth+ --dport 587 -j ACCEPT
#
#DNS'
iptables -A INPUT -p tcp -i eth+ --dport 53 -j ACCEPT
iptables -A FORWARD -p tcp -i eth+ --dport 53 -j ACCEPT
iptables -A INPUT -p udp -i eth+ --dport 53 -j ACCEPT
iptables -A FORWARD -p udp -i eth+ --dport 53 -j ACCEPT
#
#POP3'
iptables -A INPUT -p tcp -i eth+ --dport 110 -j ACCEPT
iptables -A FORWARD -p tcp -i eth+ --dport 110 -j ACCEPT
#
#Rsync'
iptables -A INPUT -p tcp -i eth+ --dport 873 -j ACCEPT
iptables -A FORWARD -p tcp -i eth+ --dport 873 -j ACCEPT
#
#Openfire'
iptables -A INPUT -p tcp -i eth+ --dport 5222 -j ACCEPT
iptables -A FORWARD -p tcp -i eth+ --dport 5222 -j ACCEPT
#
#Proxy'
iptables -A INPUT -p tcp -i eth0 --dport 3128 -j ACCEPT
#
#VNC'
iptables -A INPUT -p tcp --dport 5900 -j ACCEPT
iptables -A FORWARD -p tcp --dport 5900 -j ACCEPT
#
#NAT para servicos gerais'
#FTP'
iptables -t nat -A POSTROUTING -o ppp0 -p tcp --dport 21 -j MASQUERADE
iptables -t nat -A POSTROUTING -o ppp1 -p tcp --dport 21 -j MASQUERADE
#
#SMTP'
iptables -t nat -A POSTROUTING -o ppp0 -p tcp --dport 587 -j MASQUERADE
iptables -t nat -A POSTROUTING -o ppp1 -p tcp --dport 587 -j MASQUERADE
#
#POP3'
iptables -t nat -A POSTROUTING -o ppp0 -p tcp --dport 110 -j MASQUERADE
iptables -t nat -A POSTROUTING -o ppp1 -p tcp --dport 110 -j MASQUERADE
#Proxy Transparente'
iptables -t nat -A PREROUTING -p tcp -i eth0 --dport 80 -j REDIRECT --to-port 3128
#
#Reiniciando o apache'
#/etc/init.d/apache2 restart
#
#Broadcast/Multicast para DHCP'
route add -host 255.255.255.255 dev eth0
#
iptables -A FORWARD -m string --algo bm --string "terra.com" -j LOG --log-prefix "ATENÇÃO: BLOQUEIO"
iptables -A FORWARD -m string --algo bm --string "terra.com" -j DROP