Diferencias
Muestra las diferencias entre dos versiones de la página.
| Próxima revisión | Revisión previa | ||
|
iptables [2011/03/07 17:25] 10.12.14.50 creado |
iptables [2017/03/27 17:44] (actual) |
||
|---|---|---|---|
| Línea 1: | Línea 1: | ||
| + | **Configuración escrita:** | ||
| + | |||
| #!/bin/bash | #!/bin/bash | ||
| #Habilitamos siempre el forwarding | #Habilitamos siempre el forwarding | ||
| Línea 7: | Línea 9: | ||
| INETIFACE="eth0" | INETIFACE="eth0" | ||
| VPNIFACE="tun0" | VPNIFACE="tun0" | ||
| + | VPNALLIFACE="tun+" | ||
| DMZNET="10.12.13.0/24" | DMZNET="10.12.13.0/24" | ||
| LOCALNET="10.12.12.0/24" | LOCALNET="10.12.12.0/24" | ||
| + | VPNNET="10.12.14.0/24" | ||
| - | VPNALLIFACE="tun+" | ||
| case "$1" in | case "$1" in | ||
| Línea 43: | Línea 46: | ||
| # Permitimos los pings | # Permitimos los pings | ||
| iptables -A INPUT -p icmp -m state --state NEW -j ACCEPT | iptables -A INPUT -p icmp -m state --state NEW -j ACCEPT | ||
| - | + | ||
| - | #Abrimos en el INPUT el ssh desde cualquier interfaz | + | # Permitimos snmp para todos - cacty |
| - | iptables -A INPUT -p tcp --dport 22 -j ACCEPT | + | iptables -A INPUT -p snmp -m state --state NEW -j ACCEPT (DMZ) |
| + | |||
| + | #Abrimos en el INPUT el ssh desde cualquier red conocida | ||
| + | iptables -A INPUT -s 10.12.12.0/24 -i eth2 -p tcp --dport 22 -j ACCEPT | ||
| + | iptables -A INPUT -s 10.12.13.0/24 -i eth1 -p tcp --dport 22 -j ACCEPT | ||
| + | iptables -A INPUT -s 10.12.14.0/24 -i tun0 -p tcp --dport 22 -j ACCEPT | ||
| #Abrimos en el INPUT el openvpn desde cualquier interfaz | #Abrimos en el INPUT el openvpn desde cualquier interfaz | ||
| Línea 51: | Línea 59: | ||
| #Abrimos en el INPUT dns para las vpn, la dmz y localnet | #Abrimos en el INPUT dns para las vpn, la dmz y localnet | ||
| - | iptables -A INPUT -i $DMZIFACE -p udp --dport 53 -j ACCEPT | + | iptables -A INPUT -i eth1 -p udp --dport 53 -j ACCEPT |
| - | iptables -A INPUT -i $VPNALLIFACE -p udp --dport 53 -j ACCEPT | + | iptables -A INPUT -i tun0 -p udp --dport 53 -j ACCEPT |
| - | iptables -A INPUT -i $LOCALIFACE -p udp --dport 53 -j ACCEPT | + | iptables -A INPUT -i eth2 -p udp --dport 53 -j ACCEPT |
| - | #Abrimos en el INPUT dhcp para las dmz y localnet | + | #Abrimos en el INPUT dhcp para la localnet |
| - | iptables -A INPUT -i $DMZIFACE -p udp --dport 67 -j ACCEPT | + | iptables -A INPUT -i eth2 -p udp --dport 67 -j ACCEPT |
| - | iptables -A INPUT -i $LOCALIFACE -p udp --dport 67 -j ACCEPT | + | |
| + | #Abrimos en el INPUT ntp para any | ||
| + | iptables -A INPUT -p udp --dport 67 -j ACCEPT | ||
| ############################################ | ############################################ | ||
| Línea 65: | Línea 76: | ||
| # Permitimos los pings | # Permitimos los pings | ||
| iptables -A FORWARD -p icmp -m state --state NEW -j ACCEPT | iptables -A FORWARD -p icmp -m state --state NEW -j ACCEPT | ||
| + | |||
| ############################################ | ############################################ | ||
| Línea 70: | Línea 82: | ||
| ############################################ | ############################################ | ||
| - | #de la DMZ a Inet solo aceptamos web y ssh y enmascaramos. Aceptamos tb la salida de rsync desde backup | + | ##DMZ(eth1) --> Internet(eth0) |
| - | iptables -A FORWARD -i $DMZIFACE -o $INETIFACE -p tcp -m multiport --destination-ports www,ssh,https,sftp -m state --state NEW -j ACCEPT | + | #Tráfico desde DMZ a Internet por www,ssh/sftp,https enmascaramos. |
| - | iptables -A FORWARD -s srv-backup -i $DMZIFACE -p tcp --dport 873 -m state --state NEW -j ACCEPT | + | iptables -A FORWARD -i eth1 -o eth0 -p tcp -m multiport --destination-ports 80,22,443 -m state --state NEW -j ACCEPT |
| - | iptables -A FORWARD -s srv-backup -i $DMZIFACE -p tcp --dport 80 -m state --state NEW -j ACCEPT | + | |
| - | #abrimos el correo para srv-datos | + | #abrimos desde srv de DMZ (datos, web, backup)a internet para correo |
| - | iptables -A FORWARD -s srv-datos -i $DMZIFACE -o $INETIFACE -p tcp --dport 25 -m state --state NEW -j ACCEPT | + | #iptables -A FORWARD -i eth1 -o $INETIFACE --dport 25 -m state --state NEW -j ACCEPT |
| - | iptables -A FORWARD -s srv-datos -i $DMZIFACE -o $INETIFACE -p udp --dport 25 -m state --state NEW -j ACCEPT | + | iptables -A FORWARD -s 10.12.13.10 -i eth1 -o eth0 --dport 25 -m state --state NEW -j ACCEPT |
| - | iptables -A FORWARD -s srv-datos -i $DMZIFACE -o $INETIFACE -p tcp --dport 21 -m state --state NEW -j ACCEPT | + | iptables -A FORWARD -s 10.12.13.12 -i eth1 -o eth0 --dport 25 -m state --state NEW -j ACCEPT |
| - | iptables -A FORWARD -s srv-datos -i $DMZIFACE -o $INETIFACE -p udp --dport 21 -m state --state NEW -j ACCEPT | + | iptables -A FORWARD -s 10.12.13.11 -i eth1 -o eth0 --dport 25 -m state --state NEW -j ACCEPT |
| - | iptables -A FORWARD -s srv-datos -i $DMZIFACE -o $INETIFACE -p tcp --dport 3306 -m state --state NEW -j ACCEPT | + | |
| - | iptables -A FORWARD -s srv-datos -i $DMZIFACE -o $INETIFACE -p tcp --dport 161 -m state --state NEW -j ACCEPT | + | |
| - | #abrimos el correo para srv-web | + | #Acceso desde srv-datos a MySql para???? |
| - | iptables -A FORWARD -s srv-web -i $DMZIFACE -o $INETIFACE -p tcp --dport 25 -m state --state NEW -j ACCEPT | + | #iptables -A FORWARD -s 10.12.13.10 -i eth1 -o eth0 -p tcp --dport 3306 -m state --state NEW -j ACCEPT |
| - | iptables -A FORWARD -s srv-web -i $DMZIFACE -o $INETIFACE -p udp --dport 25 -m state --state NEW -j ACCEPT | + | |
| - | #abrimos para el servidor de fechas | + | #Conexión de srvweb a as400 de Salica puertos¿? |
| - | iptables -A FORWARD -s srv-web -i $DMZIFACE -o $INETIFACE -p udp --dport ntp -m state --state NEW -j ACCEPT | + | iptables -A FORWARD -s 10.12.13.12 -i eth1 -d 194.30.40.94 -o eth0 -m state --state NEW -j ACCEPT |
| - | #abrimos al as400 de salica | + | #Conexión de srvweb a ENBOR de ingesit puertos¿? |
| - | iptables -A FORWARD -s srv-web -d 194.30.40.94 -i $DMZIFACE -o $INETIFACE -m state --state NEW -j ACCEPT | + | iptables -A FORWARD -s 10.12.13.12 -i eth1 -d 212.81.222.114 -o eth0 -m state --state NEW -j ACCEPT |
| - | + | ||
| - | #abrimos al ENBOR de ingesit | + | |
| - | iptables -A FORWARD -s srv-web -d 212.81.222.114 -i $DMZIFACE -o $INETIFACE -m state --state NEW -j ACCEPT | + | |
| - | #abrimos al ENBOR de Basterra | + | #Conexión de srvweb a ENBOR de Basterra puertos¿? |
| - | iptables -A FORWARD -s srv-web -d 212.81.209.194 -i $DMZIFACE -o $INETIFACE -m state --state NEW -j ACCEPT | + | iptables -A FORWARD -s 10.12.13.12 -i eth1 -d 212.81.209.194 -o eth0 -m state --state NEW -j ACCEPT |
| + | |||
| + | #Conexión de srvweb y ???? a SQL SERVER de Gastrobaska puertos¿? | ||
| + | iptables -A FORWARD -s 10.12.13.12 -i eth1 -d 212.8.98.176 -o eth0 -m state --state NEW -j ACCEPT | ||
| + | #iptables -A FORWARD -s 10.12.12.70 -i eth2 -d 212.8.98.176 -o eth0 -m state --state NEW -j ACCEPT | ||
| + | |||
| + | ##DMZ --> Any | ||
| + | #Abrimos desde srv-backup a any (tb internet????) por servicios rsync | ||
| + | iptables -A FORWARD -s 10.12.13.11 -i eth1 -p tcp --dport 873 -m state --state NEW -j ACCEPT **** | ||
| + | |||
| + | #Enrutado y enmascaramiento de la DMZ hacia internet | ||
| + | iptables -t nat -A POSTROUTING -s $DMZNET -i eth1 -o eth0 -j MASQUERADE | ||
| - | #abrimos al SQL SERVER de Gastrobaska | ||
| - | iptables -A FORWARD -s srv-web -d 212.8.98.176 -i $DMZIFACE -o $INETIFACE -m state --state NEW -j ACCEPT | ||
| - | #iptables -A FORWARD -s 10.12.12.70 -d 212.8.98.176 -i $DMZIFACE -o $INETIFACE -m state --state NEW -j ACCEPT | ||
| - | |||
| - | #abrimos el correo para el servidor de backup | ||
| - | iptables -A FORWARD -s srv-backup -i $DMZIFACE -o $INETIFACE -p tcp --dport 25 -m state --state NEW -j ACCEPT | ||
| - | iptables -A FORWARD -s srv-backup -i $DMZIFACE -o $INETIFACE -p udp --dport 25 -m state --state NEW -j ACCEPT | ||
| - | |||
| - | iptables -t nat -A POSTROUTING -s $DMZNET -o $INETIFACE -j MASQUERADE | ||
| ############################################ | ############################################ | ||
| Línea 113: | Línea 120: | ||
| ############################################ | ############################################ | ||
| - | #de la red local podemos acceder a los servicios de samba, http, https y ssh de srv-datos. Y ftp | + | ##LOCAL --> DMZ |
| - | iptables -A FORWARD -i $LOCALIFACE -o $DMZIFACE -d srv-datos -p tcp -m multiport --destination-ports 999,www,ssh,https,139,445 -m state --state NEW -j ACCEPT | + | #Tráfico desde local a en DMZ (datos, web, backup) por servicios samba, http, https, ssh, netbios_tcp y 445 |
| - | iptables -A FORWARD -i $LOCALIFACE -o $DMZIFACE -d srv-datos -p udp -m multiport --destination-ports 137,138 -m state --state NEW -j ACCEPT | + | iptables -A FORWARD -i eth2 -d 10.12.13.10 -o eth1 -p tcp -m multiport --destination-ports 999,80,22,443,139,445 -m state --state NEW -j ACCEPT |
| - | iptables -A FORWARD -i $LOCALIFACE -o $DMZIFACE -d srv-datos -p tcp --dport 21 -m state --state NEW -j ACCEPT | + | iptables -A FORWARD -i eth2 -d 10.12.13.12 -o eth1 -p tcp -m multiport --destination-ports 999,80,22,443,139,445 -m state --state NEW -j ACCEPT |
| - | + | iptables -A FORWARD -i eth2 -d 10.12.13.11 -o eth1 -p tcp -m multiport --destination-ports 80,22,443 -m state --state NEW -j ACCEPT | |
| - | #de la red local podemos acceder a los servicios de samba, http, https y ssh de srv-web. Y ftp | + | |
| - | iptables -A FORWARD -i $LOCALIFACE -o $DMZIFACE -d srv-web -p tcp -m multiport --destination-ports 999,www,ssh,https,139,445 -m state --state NEW -j ACCEPT | + | |
| - | iptables -A FORWARD -i $LOCALIFACE -o $DMZIFACE -d srv-web -p udp -m multiport --destination-ports 137,138 -m state --state NEW -j ACCEPT | + | |
| - | iptables -A FORWARD -i $LOCALIFACE -o $DMZIFACE -d srv-web -p tcp --dport 21 -m state --state NEW -j ACCEPT | + | |
| - | iptables -A FORWARD -i $LOCALIFACE -o $DMZIFACE -d srv-web -p tcp --dport 20 -m state --state NEW -j ACCEPT | + | |
| - | #de la red local podemos acceder a toda la centralita | + | #habilitamos tráfico netbios_udp desde local a DMZ (datos, web, backup) |
| - | iptables -A FORWARD -i $LOCALIFACE -o $DMZIFACE -d centralita -m state --state NEW -j ACCEPT | + | iptables -A FORWARD -i eth2 -o eth1 -p udp -m multiport --destination-ports 137,138 -m state --state NEW -j ACCEPT |
| - | iptables -A FORWARD -o $LOCALIFACE -i $DMZIFACE -s centralita -m state --state NEW -j ACCEPT | + | iptables -A FORWARD -i eth2 -d 10.12.13.10 -o eth1 -p udp -m multiport --destination-ports 137,138 -m state --state NEW -j ACCEPT |
| + | iptables -A FORWARD -i eth2 -d 10.12.13.12 -o eth1 -p udp -m multiport --destination-ports 137,138 -m state --state NEW -j ACCEPT | ||
| - | #abrimos tambien el ldap | + | #habilitamos tráfico desde local a la centralita todo y todos?? |
| - | iptables -A FORWARD -i $LOCALIFACE -o $DMZIFACE -d srv-datos -p tcp --dport 389 -m state --state NEW -j ACCEPT | + | iptables -A FORWARD -i eth2 -d 10.12.13.100 -o eth1 -m state --state NEW -j ACCEPT |
| - | #abrimos tambien el mysql | + | iptables -A FORWARD -s 10.12.13.100 -i eth1 -o eth2 -m state --state NEW -j ACCEPT |
| - | iptables -A FORWARD -i $LOCALIFACE -o $DMZIFACE -d srv-datos -p tcp --dport 3306 -m state --state NEW -j ACCEPT | + | |
| - | iptables -A FORWARD -i $LOCALIFACE -o $DMZIFACE -d srv-web -p tcp --dport 3306 -m state --state NEW -j ACCEPT | + | |
| - | #de la red local podemos acceder a los servicios de ssh y https de srv-backup | + | |
| - | iptables -A FORWARD -i $LOCALIFACE -o $DMZIFACE -d srv-backup -p tcp -m multiport --destination-ports ssh,https,www -m state --state NEW -j ACCEPT | + | #abrimos desde local hacia srv-datos y srv-web el mysql |
| + | iptables -A FORWARD -i eth2 -d 10.12.13.10 -o eth1 -p tcp --dport 3306 -m state --state NEW -j ACCEPT | ||
| + | iptables -A FORWARD -i eth2 -d 10.12.13.12 -o eth1 -p tcp --dport 3306 -m state --state NEW -j ACCEPT | ||
| - | #dejamos todo el trafico a internet y lo enmascaramos | + | ##LOCAL --> INTERNET |
| - | #iptables -A FORWARD -i $LOCALIFACE -o $DMZIFACE -p tcp --dport 20 -m state --state NEW -j ACCEPT | + | #abrimos trafico desde local hacia internet |
| - | #iptables -A FORWARD -i $LOCALIFACE -o $DMZIFACE -p tcp --dport 21 -m state --state NEW -j ACCEPT | + | iptables -A FORWARD -i eth2 -o eth0 -p tcp -m state --state NEW -j ACCEPT |
| - | #iptables -A FORWARD -i $LOCALIFACE -o $INETIFACE -p tcp --dport 22 -m state --state NEW -j ACCEPT | + | |
| - | #iptables -A FORWARD -i $LOCALIFACE -o $INETIFACE -p tcp --dport 2222 -m state --state NEW -j ACCEPT | + | |
| - | #iptables -A FORWARD -i $LOCALIFACE -o $INETIFACE -p tcp --dport 8443 -m state --state NEW -j ACCEPT | + | |
| - | #iptables -A FORWARD -i $LOCALIFACE -o $INETIFACE -p tcp --dport 25 -m state --state NEW -j ACCEPT | + | |
| - | #iptables -A FORWARD -i $LOCALIFACE -o $INETIFACE -p tcp --dport 80 -m state --state NEW -j ACCEPT | + | |
| - | #iptables -A FORWARD -i $LOCALIFACE -o $INETIFACE -p tcp --dport 443 -m state --state NEW -j ACCEPT | + | |
| - | #iptables -A FORWARD -i $LOCALIFACE -o $INETIFACE -p tcp --dport 110 -m state --state NEW -j ACCEPT | + | |
| - | #iptables -A FORWARD -i $LOCALIFACE -o $INETIFACE -p tcp --dport 3306 -m state --state NEW -j ACCEPT | + | |
| - | iptables -A FORWARD -i $LOCALIFACE -o $INETIFACE -m state --state NEW -j ACCEPT | + | |
| - | iptables -t nat -A POSTROUTING -s $LOCALNET -o $INETIFACE -j MASQUERADE | + | |
| - | #dejamos todo el trafico hacia los tuneles | + | #enrutado y enmascaramiento |
| - | iptables -A FORWARD -i $LOCALIFACE -o $VPNALLIFACE -m state --state NEW -j ACCEPT | + | iptables -t nat -A POSTROUTING -s $LOCALNET -i eth2 -o eth0 -j MASQUERADE |
| + | |||
| + | #dejamos todo el trafico desde local hacia el tun0???? | ||
| + | #iptables -A FORWARD -i eth2 -o $VPNIFACE -m state --state NEW -j ACCEPT | ||
| ############################################ | ############################################ | ||
| Línea 158: | Línea 154: | ||
| ############################################ | ############################################ | ||
| - | #Trafico abierto entre tuneles | + | #Trafico abierto entre tuneles???? |
| - | iptables -A FORWARD -i $VPNALLIFACE -o $VPNALLIFACE -j ACCEPT | + | #iptables -A FORWARD -i $VPNALLIFACE -o $VPNALLIFACE -j ACCEPT |
| - | #de la VPN podemos acceder a los servicios de ssh y https de srv-backup | + | #VPN --> DMZ |
| - | iptables -A FORWARD -i $VPNALLIFACE -o $DMZIFACE -d srv-backup -p tcp -m multiport --destination-ports ssh,https -m state --state NEW -j ACCEPT | + | #Acceso desde VPN en DMZ (datos, web, backup) por servicios samba, http, https, ssh, netbios_tcp y 445 |
| - | + | iptables -A FORWARD -i $VPNALLIFACE -d 10.12.13.10 -o eth1 -p tcp -m multiport --destination-ports 999, 80, 22,443,139, 445 -m state --state NEW -j ACCEPT | |
| - | #de la VPN podemos acceder a los servicios de samba, http, https y ssh de srv-datos | + | iptables -A FORWARD -i $VPNALLIFACE -d 10.12.12.12 -o eth1 -p tcp -m multiport --destination-ports 999, 80, 22,443,139, 445 -m state --state NEW -j ACCEPT |
| - | iptables -A FORWARD -i $VPNALLIFACE -o $DMZIFACE -d srv-datos -p tcp -m multiport --destination-ports 999,www,ssh,https,139,445 -m state --state NEW -j ACCEPT | + | iptables -A FORWARD -i $VPNALLIFACE -d 10.12.13.11 -o eth1 -p tcp -m multiport --destination-ports 22,443,-m state --state NEW -j ACCEPT |
| - | iptables -A FORWARD -i $VPNALLIFACE -o $DMZIFACE -d srv-datos -p udp -m multiport --destination-ports 137,138 -m state --state NEW -j ACCEPT | + | |
| - | iptables -A FORWARD -i $VPNALLIFACE -o $DMZIFACE -d srv-web -p tcp -m multiport --destination-ports 999,www,ssh,https,139,445 -m state --state NEW -j ACCEPT | + | |
| - | iptables -A FORWARD -i $VPNALLIFACE -o $DMZIFACE -d srv-web -p udp -m multiport --destination-ports 137,138 -m state --state NEW -j ACCEPT | + | |
| + | #habilitamos tráfico netbios_udp desde VPN a DMZ (datos, web, backup) | ||
| + | iptables -A FORWARD -i $VPNALLIFACE -o eth1 -p udp -m multiport --destination-ports 137,138 -m state --state NEW -j ACCEPT | ||
| + | iptables -A FORWARD -i $VPNALLIFACE -d 10.12.13.10 -o eth1 -p udp -m multiport --destination-ports 137,138 -m state --state NEW -j ACCEPT | ||
| + | iptables -A FORWARD -i $VPNALLIFACE -d 10.12.13.12 -o eth1 -p udp -m multiport --destination-ports 137,138 -m state --state NEW -j ACCEPT | ||
| + | |||
| echo "iniciado" | echo "iniciado" | ||