Hay mil maneras de redirigir puertos. Pero esta es la forma más a bajo nivel que podemos hacer la redirección.
Ejemplo:
# setup_iptables # setup iptables for redirection of CIFS and FTP echo 1 > /proc/sys/net/ipv4/ip_forward modprobe iptable_nat iptables -F iptables -t nat -F iptables -P INPUT ACCEPT iptables -P FORWARD ACCEPT iptables -P OUTPUT ACCEPT iptables -t nat -A PREROUTING -p tcp --dport 445 -j REDIRECT --to-ports 1445 iptables -t nat -A PREROUTING -p tcp --dport 139 -j REDIRECT --to-ports 1139 iptables -t nat -A PREROUTING -p udp --dport 137 -j REDIRECT --to-ports 1137 iptables -t nat -A PREROUTING -p udp --dport 138 -j REDIRECT --to-ports 1138 iptables -t nat -A PREROUTING -p tcp --dport 21 -j REDIRECT --to-ports 1121 iptables -t nat -A OUTPUT -p tcp -d 127.0.0.1 --dport 445 -j REDIRECT --to-port 1445 iptables -t nat -A OUTPUT -p tcp -d 172.0.0.1 --dport 21 -j REDIRECT --to-port 1121 iptables -t nat -A OUTPUT -p tcp -d 127.0.0.1 --dport 139 -j REDIRECT --to-port 1139 iptables -t nat -A OUTPUT -p udp -d 127.0.0.1 --dport 137 -j REDIRECT --to-port 1137 iptables -t nat -A OUTPUT -p udp -d 127.0.0.1 --dport 138 -j REDIRECT --to-port 1138