informatica:linux:cortafuegos:iptables_basico
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| informatica:linux:cortafuegos:iptables_basico [2008/12/02 13:51] – 194.179.83.89 | informatica:linux:cortafuegos:iptables_basico [2015/04/13 20:19] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 32: | Line 32: | ||
| #!/bin/bash | #!/bin/bash | ||
| - | | + | |
| # Guión para administrar las reglas de iptables | # Guión para administrar las reglas de iptables | ||
| # Siempre 1º permitir 2º denegar | # Siempre 1º permitir 2º denegar | ||
| - | | + | |
| ###################### | ###################### | ||
| - | | + | |
| - | | + | |
| - | | + | ORIGEN1="194.179.83.89" |
| - | | + | |
| + | | ||
| + | ORIGEN4=" | ||
| + | ORIGEN5=" | ||
| + | |||
| + | INTERFAZ=" | ||
| #################### | #################### | ||
| - | | + | |
| # Elimino las reglas anteriores | # Elimino las reglas anteriores | ||
| iptables -F | iptables -F | ||
| Line 48: | Line 54: | ||
| iptables -t mangle -F | iptables -t mangle -F | ||
| iptables -X | iptables -X | ||
| - | | + | |
| - | # Asegurarme que puedo conectarme via ssh desde el curro | + | # Asegurarme que puedo conectarme via ssh desde distintas maquinas |
| - | | + | iptables -A INPUT -s $ORIGEN1 |
| - | | + | |
| # Por aquí debería abrir servicios, por ejemplo: | # Por aquí debería abrir servicios, por ejemplo: | ||
| - | | + | |
| - | # | + | # HTTP/ |
| - | | + | iptables -A INPUT -i $INTERFAZ |
| - | | + | |
| + | |||
| + | # Mlnet | ||
| + | iptables -A INPUT -i $INTERFAZ -p tcp --dport 4080 -j ACCEPT | ||
| + | iptables -A INPUT -i $INTERFAZ -p udp --dport 4080 -j ACCEPT | ||
| + | |||
| + | # FTP | ||
| + | iptables -A INPUT -i $INTERFAZ -p tcp --dport 21 -j ACCEPT | ||
| + | iptables -A INPUT -i $INTERFAZ -p udp --dport 21 -j ACCEPT | ||
| + | |||
| + | # DNS (resolver) | ||
| + | iptables -A INPUT -i $INTERFAZ -p udp --sport 53 -j ACCEPT | ||
| + | |||
| + | ###################### | ||
| + | |||
| + | IF=ppp0 | ||
| + | IPTABLES=/ | ||
| + | MLDONKEY_HOST=192.168.1.2 | ||
| + | EDONKEY_PORT=4662 | ||
| + | KAD_PORT=8443 | ||
| + | OVERNET_PORT=5865 | ||
| + | BITTORRENT_PORT=6882 | ||
| + | OPENNAP_PORT=9999 | ||
| + | |||
| + | ## MLDonkey acting as Edonkey2000 client | ||
| + | $IPTABLES -I FORWARD -p tcp --dport $EDONKEY_PORT -j ACCEPT | ||
| + | $IPTABLES -I FORWARD -p udp --dport $(($EDONKEY_PORT + 4)) -j ACCEPT | ||
| + | $IPTABLES -t nat -I PREROUTING -i $IF -p tcp --dport $EDONKEY_PORT -j DNAT --to-destination $MLDONKEY_HOST | ||
| + | $IPTABLES -t nat -I PREROUTING -i $IF -p udp --dport $(($EDONKEY_PORT + 4)) -j DNAT --to-destination $MLDONKEY_HOST | ||
| + | |||
| + | ## MLDonkey acting as Kad client | ||
| + | $IPTABLES -I FORWARD -p tcp --dport $KAD_PORT -j ACCEPT | ||
| + | $IPTABLES -I FORWARD -p udp --dport $KAD_PORT -j ACCEPT | ||
| + | $IPTABLES -t nat -I PREROUTING -i $IF -p tcp --dport $KAD_PORT -j DNAT --to-destination $MLDONKEY_HOST | ||
| + | $IPTABLES -t nat -I PREROUTING -i $IF -p udp --dport $KAD_PORT -j DNAT --to-destination $MLDONKEY_HOST | ||
| + | |||
| + | ## MLDonkey acting as Overnet client | ||
| + | $IPTABLES -I FORWARD -p tcp --dport $OVERNET_PORT -j ACCEPT | ||
| + | $IPTABLES -I FORWARD -p udp --dport $OVERNET_PORT -j ACCEPT | ||
| + | $IPTABLES -t nat -I PREROUTING -i $IF -p tcp --dport $OVERNET_PORT -j DNAT --to-destination $MLDONKEY_HOST | ||
| + | $IPTABLES -t nat -I PREROUTING -i $IF -p udp --dport $OVERNET_PORT -j DNAT --to-destination $MLDONKEY_HOST | ||
| + | |||
| + | ## MLDonkey acting as BitTorrent client | ||
| + | $IPTABLES -I FORWARD -p tcp --dport $BITTORRENT_PORT -j ACCEPT | ||
| + | $IPTABLES -t nat -I PREROUTING -i $IF -p tcp --dport $BITTORRENT_PORT -j DNAT --to-destination $MLDONKEY_HOST | ||
| + | |||
| + | ## MLDonkey acting as OpenNap client | ||
| + | $IPTABLES -I FORWARD -p tcp --dport $OPENNAP_PORT -j ACCEPT | ||
| + | $IPTABLES -t nat -I PREROUTING -i $IF -p tcp --dport $OPENNAP_PORT -j DNAT --to-destination $MLDONKEY_HOST | ||
| + | |||
| + | ##################### | ||
| # Rechazar todos los demás paquetes entrantes | # Rechazar todos los demás paquetes entrantes | ||
| - | | + | iptables -A INPUT -j REJECT |
| - | | + | iptables -A FORWARD -j REJECT |
| 3. Utilidades: | 3. Utilidades: | ||
informatica/linux/cortafuegos/iptables_basico.1228225916.txt.gz · Last modified: (external edit)
