Echo 1>/proc/sys/NET/IPv4/ip_forward
First, you should do the net. ipv4.ip _ forward = 1 in the/etc/sysctl. conf configuration file. The default value is 0, which allows iptalbes forward.
After the modification is complete, run the following command to make the parameter take effect:
/Sbin/sysctl-P
Forward port 3389 of the Local interface IP address 61.144.14.72 to port 3389 of 116.6.73.229.
(Access port 3389 of 61.144.14.72 to jump to 3389 of 116.6.73.229)
[STEP]
1. First, we should do the net. ipv4.ip _ forward = 1 in the/etc/sysctl. conf configuration file, which defaults to 0 to allow iptalbes forward.
2. Disable the firewall using service iptables stop
3. reconfigure rules
Iptables-T Nat-A prerouting -- DST 61.144.14.72-p tcp -- dport 3389-j dnat -- to-destination 116.6.73.229: 3389
Iptables-T Nat-A postrouting -- DST 116.6.73.229-p tcp -- dport 3389-j snat -- to-source 61.144.14.72
Service iptables save
Save the current rule to/etc/sysconfig/iptables
If you are familiar with this file, directly modifying the content here is also equivalent to the command line Input rules.
5. Start the iptables service and service iptables start
You can write a script to enable the device to run automatically;
# 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/local
SH/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: 3389
Iptables-T Nat-A postrouting -- DST 116.6.73.229-p tcp -- dport 3389-j snat -- to-source 61.144.14.72
~
----------------------------------------------------------------
TCP
Iptables-T Nat-A prerouting -- DST 61.144.14.87-p tcp -- dport 9304-j dnat -- to-destination 10.94.143.204: 9304
Iptables-T Nat-A postrouting -- DST 10.94.143.204-p tcp -- dport 9304-j snat -- to-source 61.144.14.87
UDP
Iptables-T Nat-A prerouting -- DST 61.144.14.87-p udp -- dport 9305-j dnat -- to-destination 10.94.143.204: 9305
Iptables-T Nat-A postrouting -- DST 10.94.143.204-p udp -- dport 9305-j snat -- to-source 61.144.14.87
Use iptables in centos to set port forwarding