Linux servers do the routing, mapping the same network segment machine

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.