Buenas gente, acá les dejo un mini script para redireccionar puertos a otra ip. Para que funcione primero tiene que hacer:
sysctl net.ipv4.ip_forward=1
Acá va el script:
3 | iptables -t nat -A PREROUTING -p tcp --dport $1 -j DNAT --to-destination $3:$1 |
4 | iptables -A FORWARD -p tcp -d $3 --dport $1 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT |
5 | iptables -t nat -A PREROUTING -p udp --dport $1 -j DNAT --to-destination $3:$1 |
6 | iptables -A FORWARD -p udp -d $3 --dport $1 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT |
7 | iptables -t nat -A PREROUTING -p udp --dport $2 -j DNAT --to-destination $3:$2 |
8 | iptables -A FORWARD -p udp -d $3 --dport $2 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT |
Tags: bash script, firewall, forward, iptables, linux, prerouting, redireccion
This entry was posted on Friday, August 29th, 2014 at 11:02 am and is filed under Scripting, Servidores Linux. You can follow any responses to this entry through the RSS 2.0 feed.
Both comments and pings are currently closed.