Ubuntu 14.04 Port Mapping

Ubuntu 14.04 Port Mapping

Original JavyZheng Last post on 2015-12-10 15:58:43 Reads 6730 collection
launched
Ubuntu 14.04 Port Mapping

Ubuntu 1404 port mapping
BACKGROUND
method of
a non-permanent
permanent
BACKGROUND

A cluster, only one public IP, external network clients need to access services within the network a machine is running, then the need to achieve through port forwarding.

Assuming you configure

Machine1: external network IP: 113.30.150.75 card: em0, network IP: 192.168.0.1 card: em1
Machine6: Intranet IP: 192.168.0.6

demand

To access the services provided by the 192.168.0.6:9000 access 113.30.150.75:19000, coming 113.30.150.75:19000 mapped to 192.168.0.6:9000

method

Non-permanent

Machine1 above:

The sudo echo. 1 $> / proc / SYS / NET / IPv4 / ip_forward
$ the sudo iptables -t NAT -A the PREROUTING -p TCP -s 0/0 -d 113.30.150.75 19000 --dport -j DNAT --to 192.168.0.6 : 9000
$ -A the sudo iptables -t NAT TCP --dport the POSTROUTING -d 192.168.0.6 -p 9000 -o -j EM1 the SNAT --to 192.168.0.1
. 1
2
. 3
thus can, but if Machine1 restarted, the configuration will lost. If you want to restart Machine1, still retains mapping.

permanent

Machine1 above:

Sudo vim /etc/rc.local $
1
at the end of the file, add the following lines, note that without the sudo,

. 1 echo> / proc / SYS / NET / IPv4 / ip_forward
iptables -t NAT -A the PREROUTING -p TCP -s 0/0 -d 113.30.150.75 19000 --dport -j DNAT --to 192.168.0.6:9000
iptables - -A -d 192.168.0.6 the POSTROUTING NAT T -p 9000 -o EM1 -j TCP --dport the SNAT --to 192.168.0.1
. 1
2
. 3
to.
----------------
Disclaimer: This article is CSDN blogger "JavyZheng 'original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement. .
Original link: https: //blog.csdn.net/javyzheng/article/details/50209035

Guess you like

Origin www.cnblogs.com/xiexun/p/12453618.html