Machine 1: There is an intranet IP, an external network IP
Intranet: eth0:192.168.10.10
External network: eth1:10.10.10.10
Machine 2: The same network segment as the Machine 1 intranet, no external network IP
Intranet: eth0:192.168.10.11
Machine 1 To do routers, mapping machine 2, so that the machine 2 can surf the Internet, from the external network to connect the machine 2
Step One:
Configuring the Gateway for Machine 2 to machine 1
Step Two:
Machine 1: Add forwarding function
Vi/etc/sysctl.conf
Net.ipv4.ip_forward=1
Sysctl-p
Step Three:
Use machine 2 to access the external network, on machine 1 with iptables
Iptables-t nat-a postrouting-s 192.168.10.11/24-o em1-j Masquerade
The outer network can be connected to the Machine 2. With NAT mapping on machine 1
Iptables-t nat-a prerouting-d 10.10.10.10-p tcp--dport 11122-j DNAT--to-destination 192.168.10.11:22
Iptables-t nat-a prerouting-d 10.10.10.10-p tcp--dport 18080-j DNAT--to-destination 192.168.10.11:8080
Iptables-t nat-a prerouting-d 10.10.10.10-p tcp--dport 180-j DNAT--to-destination 192.168.10.11:80
This article is from the "Quest" blog, please be sure to keep this source http://chenxy.blog.51cto.com/729966/1677910
Linux servers do the routing, mapping the same network segment machine