Iptables and SSH implement Destination Address Translation

Source: Internet
Author: User

Deploy the Virtual Machine vmware workstation for Linux on a certain machine (centos 5.8) and deploy multiple XP systems. The company does not have many IP addresses in the 192.168.1.0/24 network segment, we hope to provide a dedicated network segment 192.168.2.0/24 to the virtual machine. We recommend that you access 1.0 of the Virtual Machine 2.0 normally in the 3389 network segment.


1. Ignore installation of virtual machines


2. Set the Virtual Machine Nic to the bridging mode, the virtual machine Nic to the 192.168.2.0 segment, and the gateway 192.168.2.1

Add eth0: 0 on the physical machine, and set the IP address to 192.168.2.1/24.

Ifconfig eth0: 0 192.168.2.1/24 up


You can also set the Virtual Machine Nic to Nat mode and the IP address of vmnet8 on the physical machine to 192.168.2.1/24.


3. Use iptables's target address translation (DNAT)

1) Enable kernel forwarding Parameters

Vim/etc/sysctl. conf

Modify

Net. ipv4.ip _ forward = 0

Is

Net. ipv4.ip _ forward = 1

2)

Iptables-T nat-I prerouting-I eth0-D 192.168.1.230-P TCP -- dport 33891-J DNAT -- to-destination 192.168.2.2: 3389


Access 192.168.1.230: 33891 is equivalent to access 192.168.2.2: 3389

So far...


You can also use the SSH Tunnel

For example, xshell

Add the following rules to the shell connecting to 192.168.1.230:

Type: Local (outgoing)

Source HOST: localhost

Listening port: 33891

Target address: 192.168.2.2

Target Port: 3389


Accessing localhost: 33891 is equivalent to accessing 192.168.2.2: 3389

This method can achieve Internet access, and I personally think it is safer (publish 22 of 192.168.1.230)

You can also directly create a tunnel by Using SSH commands.


This article is from the "red stone" blog, please be sure to keep this source http://heishi317.blog.51cto.com/4301036/1530793

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.