Foros del Web » Administración de Sistemas » Unix / Linux »

Iptables

Estas en el tema de Iptables en el foro de Unix / Linux en Foros del Web. HOLA, MUY BUENAS A TODOS ! antes de nada, quería agradecer a todos aquellos que hacen posible este foro y dar las gracias por recibirme ...
  #1 (permalink)  
Antiguo 19/02/2015, 20:20
Avatar de jaguar93  
Fecha de Ingreso: febrero-2015
Ubicación: MADRID
Mensajes: 1
Antigüedad: 9 años, 1 mes
Puntos: 0
Iptables

HOLA, MUY BUENAS A TODOS ! antes de nada, quería agradecer a todos aquellos que hacen posible este foro y dar las gracias por recibirme como uno mas.
Vamos al tema:
En primer lugar quiero hacer un script de iptables, firewall, con unas determinadas reglas, es mi primera vez en manejar iptables y ando un poco perdido con la sintaxis de iptables, algunas reglas sé manejarlas pero otras no.
tengo una maquina router debian en que haré todo el iptables, este router tiene:
192.168.4.25 eth0 > 192.168.4.0 red externa
10.10.10.1 eth1 > 10.10.10.0 red interna
10.10.20.1 eth2 > 10.10.20.0/24 red DMZ con un servidor web y un servidor ftp

Se pide lo siguiente:
• Politica por defecto la que se quiera.
• Red externa:
o Impedir tráfico con destino a la red interna
o Impedir tráfico con destino al servidor FTP (DMZ)
o Permitir tráfico desde la red externa al servidor web (DMZ)
o Traducir direcciones externas a internas en el acceso al servidor web
• Red interna:
o Impedir tráfico con destino al servidor web (DMZ)
iptables -A OUTPUT -d 10.20.10.1 -j DROP

o Permitir tráfico con destino al servidor FTP (DMZ)
iptables -A OUTPUT -d 10.20.10.2 -j ACCEPT

o Permitir tráfico a la red externa
o Traducir direcciones internas a externas en el acceso al exterior
• Red DMZ:
o Impedir tráfico con destino a la red interna.
• localhost (Debian Router):
o Permitir conexión VPN desde un cliente al localhost
  #2 (permalink)  
Antiguo 20/02/2015, 03:00
Avatar de barna_rasta  
Fecha de Ingreso: agosto-2003
Mensajes: 214
Antigüedad: 20 años, 8 meses
Puntos: 11
Respuesta: Iptables

Buenos dias jaguar93,
tirale una miradita a este link, esta muy bien trabajado.

http://www.pello.info/filez/firewall/iptables.html
  #3 (permalink)  
Antiguo 20/02/2015, 07:34
Avatar de lauser
Moderator Unix/Linux
 
Fecha de Ingreso: julio-2013
Ubicación: Odessa (Ukrania)
Mensajes: 3.278
Antigüedad: 10 años, 8 meses
Puntos: 401
Respuesta: Iptables

Revisa el enlace de barna_rasta... de todas formas te pongo un ejemplo:
Código :
Ver original
  1. #!/bin/sh
  2. ##NOTAS:
  3. ##eth2 ES LA INTERFAZ CONTECTADA AL ROUTER Y eth1 A LA LAN
  4.  
  5. #Activacion de el reenvio
  6. echo 1 > /proc/sys/net/ipv4/ip_forward
  7.  
  8. #FLUSH de reglas
  9. iptables -F
  10. iptables -X
  11. iptables -t nat -F
  12.  
  13. #Establecemos politica por defecto
  14. iptables -P INPUT ACCEPT
  15. iptables -P OUTPUT ACCEPT
  16. iptables -P FORWARD ACCEPT
  17. iptables -t nat -P PREROUTING ACCEPT
  18. iptables -t nat -P POSTROUTING ACCEPT
  19.  
  20. #acceso localhost
  21. /sbin/iptables -A INPUT -i lo -j ACCEPT
  22.  
  23. #Redirecciona puertos de forma local. ( en el mismo equipo )
  24. #iptables -t nat -A PREROUTING -i eth2 -p tcp --dport 80 -j REDIRECT --to 192.168.2.x:9050
  25.  
  26. # Se aplica la mascara 192.168.1.x a los paquetes que tengan red de origen 192.168.2.0/24 y que tengan salida por eth2
  27. iptables -t nat -A POSTROUTING -s 192.168.2.0/24 -o eth2 -j SNAT --to 192.168.1.x
  28.  
  29. # PREROUTING de puertos para llegar hasta servidores internos de forma remota.
  30. iptables -t nat -A PREROUTING -p tcp --dport 80 -i eth2 -j DNAT --to 192.168.2.x
  31. iptables -t nat -A PREROUTING -p udp --dport 80 -i eth2 -j DNAT --to 192.168.2.x
  32. iptables -t nat -A PREROUTING -p tcp --dport 9050 -i eth2 -j DNAT --to 192.168.2.x
  33. iptables -t nat -A PREROUTING -p tcp --dport 22 -i eth2 -j DNAT --to 192.168.2.x
  34. iptables -t nat -A PREROUTING -p tcp --dport 5900 -i eth2 -j DNAT --to 192.168.2.x
  35.  
  36. #IP's CON ACCESO
  37. iptables -t filter -A FORWARD -s 192.168.2.x -p ALL -j ACCEPT
  38. iptables -t filter -A FORWARD -s 192.168.2.x -p ALL -j ACCEPT
  39.  
  40. #IP's EXTRAS
  41. iptables -t filter -A FORWARD -s 192.168.2.5 -p ALL -j ACCEPT
  42. iptables -t filter -A FORWARD -s 192.168.2.21 -p ALL -j ACCEPT
  43. iptables -t filter -A FORWARD -s 192.168.2.31 -p ALL -j ACCEPT
  44.  
  45. #SERVIDORES
  46. iptables -t filter -A FORWARD -s 192.168.2.x -p ALL -j ACCEPT
  47. iptables -t filter -A FORWARD -s 192.168.2.x -p ALL -j ACCEPT
  48.  
  49. #TELEFONOS
  50. iptables -t filter -A FORWARD -s 192.168.2.x -p ALL -j ACCEPT
  51. iptables -t filter -A FORWARD -s 192.168.2.x -p ALL -j ACCEPT
  52. iptables -t filter -A FORWARD -s 192.168.2.x -p ALL -j ACCEPT
  53.  
  54. # Permite Web
  55. iptables -t filter -A FORWARD -d x.x.x.x -p ALL -j ACCEPT
  56.  
  57. # Permite a una ip interna navegar a un sitio bloqueado para el resto
  58. iptables -t filter -A FORWARD -s 192.168.2.27 -d login.live.com -p ALL -j ACCEPT
  59.  
  60. # Permite Google y Deniega Gmail y Youtube
  61. iptables -t filter -A FORWARD -d 74.125.224.52 -p ALL -j ACCEPT
  62. iptables -t filter -A FORWARD -d 74.125.224.51 -p ALL -j ACCEPT
  63. iptables -t filter -A FORWARD -d 74.125.224.50 -p ALL -j ACCEPT
  64. iptables -t filter -A FORWARD -d 74.125.224.49 -p ALL -j ACCEPT
  65. iptables -t filter -A FORWARD -d 74.125.224.48 -p ALL -j ACCEPT
  66. iptables -t filter -A FORWARD -d 74.125.224.0/24 -p ALL -j REJECT
  67. iptables -t filter -A FORWARD -d 74.125.239.0/24 -p ALL -j REJECT
  68.  
  69. # Bloque FACEBOOK
  70. iptables -t filter -A FORWARD -d 69.171.0.0/16 -p ALL -j REJECT
  71. iptables -t filter -A FORWARD -d 69.171.228.0/24 -p ALL -j REJECT
  72. iptables -t filter -A FORWARD -d 69.171.224.0/24 -p ALL -j REJECT
  73. iptables -t filter -A FORWARD -d 69.171.229.11 -p ALL -j REJECT
  74. iptables -t filter -A FORWARD -d 69.171.242.11 -p ALL -j REJECT
  75. iptables -t filter -A FORWARD -d 66.220.149.11 -p ALL -j REJECT
  76. iptables -t filter -A FORWARD -d 66.220.158.11 -p ALL -j REJECT
  77. iptables -t filter -A FORWARD -d 66.220.147.44 -p ALL -j REJECT
  78.  
  79. # Bloqueo Hotmail
  80. iptables -t filter -A FORWARD -d 65.55.72.0/24 -p ALL -j REJECT
  81.  
  82. # Bloqueo MSN Live Messenger
  83. iptables -t filter -A FORWARD -d 65.55.60.123 -p ALL -j REJECT
  84. iptables -t filter -A FORWARD -d 65.54.239.211 -p ALL -j REJECT
  85. iptables -t filter -A FORWARD -d 65.54.186.0/24 -p ALL -j REJECT
  86. iptables -t filter -A FORWARD -d 65.54.165.0/24 -p ALL -j REJECT
  87. iptables -t filter -A FORWARD -d 65.54.227.242 -p ALL -j REJECT
  88. iptables -t filter -A FORWARD -d 64.4.45.62 -p ALL -j REJECT
  89. iptables -t filter -A FORWARD -d 64.4.56.183 -p ALL -j REJECT
  90. iptables -t filter -A FORWARD -d 64.4.56.199 -p ALL -j REJECT
  91.  
  92. # Bloqueo Fotolog
  93. iptables -t filter -A FORWARD -d 63.171.185.196 -p ALL -j REJECT
  94. iptables -t filter -A FORWARD -d 63.166.124.68 -p ALL -j REJECT
  95. iptables -t filter -A FORWARD -d 207.109.73.99 -p ALL -j REJECT
  96. iptables -t filter -A FORWARD -d 207.109.73.106 -p ALL -j REJECT
  97.  
  98. # Bloqueo elblogdelnarco
  99. iptables -t filter -A FORWARD -d 64.202.189.170 -p ALL -j REJECT
  100.  
  101. #   BLOQUE WEB BASED MESSENGER
  102. iptables -t filter -A FORWARD -d 38.99.72.233 -p ALL -j REJECT
  103. iptables -t filter -A FORWARD -d 38.99.72.232 -p ALL -j REJECT
  104. iptables -t filter -A FORWARD -d 74.63.220.238 -p ALL -j REJECT
  105. iptables -t filter -A FORWARD -d 64.13.161.61 -p ALL -j REJECT
  106. iptables -t filter -A FORWARD -d 74.114.28.110 -p ALL -j REJECT
  107. iptables -t filter -A FORWARD -d 208.81.191.110 -p ALL -j REJECT
  108. iptables -t filter -A FORWARD -d 208.109.186.152 -p ALL -j REJECT
  109. iptables -t filter -A FORWARD -d 99.192.249.209 -p ALL -j REJECT
  110. iptables -t filter -A FORWARD -d 85.17.78.163 -p ALL -j REJECT
  111. iptables -t filter -A FORWARD -d 74.208.12.174 -p ALL -j REJECT
  112. iptables -t filter -A FORWARD -d 173.45.74.55 -p ALL -j REJECT
  113. iptables -t filter -A FORWARD -d 66.135.39.98 -p ALL -j REJECT
  114. iptables -t filter -A FORWARD -d 82.98.86.167 -p ALL -j REJECT
  115. iptables -t filter -A FORWARD -d 174.142.232.238 -p ALL -j REJECT
  116. iptables -t filter -A FORWARD -d 74.86.15.130 -p ALL -j REJECT
  117. iptables -t filter -A FORWARD -d 205.186.183.218 -p ALL -j REJECT
  118. iptables -t filter -A FORWARD -d 72.233.64.227 -p ALL -j REJECT
  119. iptables -t filter -A FORWARD -d 75.103.119.199 -p ALL -j REJECT
  120. iptables -t filter -A FORWARD -d 68.180.190.124 -p ALL -j REJECT
  121. iptables -t filter -A FORWARD -d 74.86.129.114 -p ALL -j REJECT
  122.  
  123. # Bloque Chatroom
  124. iptables -t filter -A FORWARD -d 74.207.248.124 -p ALL -j REJECT
  125. iptables -t filter -A FORWARD -d 204.62.114.37 -p ALL -j REJECT
  126. iptables -t filter -A FORWARD -d 72.249.29.17 -p ALL -j REJECT
  127. iptables -t filter -A FORWARD -d 91.121.36.253 -p ALL -j REJECT
  128. iptables -t filter -A FORWARD -d 63.150.3.212 -p ALL -j REJECT
  129. iptables -t filter -A FORWARD -d 74.201.112.85 -p ALL -j REJECT
  130. iptables -t filter -A FORWARD -d 74.201.113.175 -p ALL -j REJECT
  131. iptables -t filter -A FORWARD -d 74.201.154.149 -p ALL -j REJECT
  132. iptables -t filter -A FORWARD -d 188.40.80.245 -p ALL -j REJECT
  133. iptables -t filter -A FORWARD -d 184.173.90.186 -p ALL -j REJECT
  134. iptables -t filter -A FORWARD -d 50.23.244.0/24 -p ALL -j REJECT
  135. iptables -t filter -A FORWARD -d 50.23.245.0/24 -p ALL -j REJECT
  136.  
  137. # Bloquear Puertos MSN
  138. iptables -t filter -A FORWARD -d 0/0 -p tcp --dport 1863 -j REJECT
  139. iptables -t filter -A FORWARD -d 0/0 -p udp --dport 1863 -j REJECT
  140. iptables -t filter -A FORWARD -d 0/0 -p tcp --dport 6891:6900 -j REJECT
  141.  
  142. echo "EJECUTA iptables -L -n PARA COMPROBAR LAS REGLAS"
  143. echo ""
__________________
Los usuarios que te responden, lo hacen altruistamente y sin ánimo de lucro con el único fin de ayudarte. Se paciente y agradecido.
-SOLOLINUX-

Etiquetas: ip, iptables
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 21:53.