Setting port forwarding using iptables in CentOS system

  
                  Forward 3389 port of local interface IP 61.144.14.72 to 3389 of 116.6.73.229 (mainly access to port 3389 of 61.144.14.72, it will jump to 3389 of 116.6.73.229) [Step] 1. The first thing to do is /The etc/sysctl.conf configuration file for net.ipv4.ip_forward = 1 defaults to 0 which allows iptalbes FORWARD. 2, service iptables
stop Turn off the firewall 3, reconfigure the rules iptables -t nat -A PREROUTING --dst 61.144.14.72 -p tcp --dport 3389 -j DNAT --to-destination 116.6.73.229: 3389iptables -t nat -A POSTROUTING --dst 116.6.73.229 -p tcp --dport 3389 -j SNAT --to-source 61.144.14.72service iptables save Save the current rules to /etc/sysconfig/iptables if you have this file Very familiar with directly modifying the content here is also equivalent to the command line mode input rules. 5, start the iptables service, service iptables start can be written into the script, the device starts automatically run; # vi /etc/rc.local#!/bin/sh## This script will be executed *after* all the other init scripts.# You can put your own initialization stuff in here if you don't# want to do the full Sys V style init stuff.touch /var/lock/subsys/localsh /root/myshipin.log--------- -------------------------------------------------- ----------vi myshipin.log#!/bin/sh## This script will be executed *after* all the other init scripts.# You can put your own initialization stuff in here if you don' t# want to do the full Sys V style init stuff.iptables -F -t nat iptables -t nat -A PREROUTING --dst 61.144.14.72 -p tcp --dport 3389 -j DNAT --to-destination 116.6.73.229 :3389iptables -t nat -A POSTROUTING --dst 116.6.73.229 -p tcp --dport 3389 -j SNAT --to-source 61.144.14.72~----------------- -----------------------------------------------TCPiptables -t Nat -A PREROUTING --dst 61.144.14.87 -p tcp --dport 9304 -j DNAT --to -destination 10.94.143.204:9304iptables -t nat -A POSTROUTING --dst 10.94.143.204 -p tcp --dport 9304 -j SNAT --to-source 61.144.14.87UDPiptables -t nat -A PREROUTING --dst 61.144.14.87 -p udp --dport 9305 -j DNAT --to-destination 10.94.143.204:9305iptables -t nat -A POSTROUTING --dst 10.94.143.204 -p udp --dport 9305 -j SNAT --to-source 61.144.14.87
Copyright © Windows knowledge All Rights Reserved