Home >Operation and Maintenance >Linux Operation and Maintenance >Detailed graphic and text steps for Linux to access intranet services through port forwarding
You can use port mapping to access services on the intranet ECS under the user name through the cloud server ECS with a public network. Other have not purchased public network bandwidth. There are many port mapping solutions, such as SSH Tunnel and rinetd under Linux, portmap under Windows, etc. This article briefly introduces rinetd and the configuration method of ssh tunnel.
Note: The relevant configurations and instructions in this article are only used as examples and operation guidelines. Alibaba Cloud is not responsible for the related operation results and resulting problems.
If it is an Ubuntu system, you can directly use the following instructionsInstallation:
apt-get install rinetd -y
The source code installation and configuration method is introduced below. :
1. Download and decompress the rinetd package:
wget http://www.boutell.com/rinetd/http/rinetd.tar.gz&&tar -xvf rinetd.tar.gz&&cd rinetd
2. Modify the compilation configuration:
sed -i ‘s/65536/65535/g’ rinetd.c# 修改端口范围,否则会报错
3. Compile and install:
mkdir /usr/man&&make&&make install
4. Create Configuration file:
cat >>/etc/rinetd.conf <>/etc/rc.local # allow 192.168.2. # deny 192.168.1. # bindadress bindport connectaddress connectport0.0.0.0 3306 example.rds.aliyuncs.com 3306logfile /var/log/rinetd.logendecho rinetd >>/etc/rc.local
|
5. Use:
After rinetd is started, you can already connect to the example rds database in intranet mode through the 3306 port of the cloud server. Except for this scenario, other intranet port forwarding configurations are similar. However, since the FTP protocol port is random, forwarding cannot be achieved through this method.
In addition, a certain IP or IP segment can be allowed/denied in the configuration file, thereby improving the security of the intranet port.
Establish an SSH tunnel between putty and the ECS with a public IP, and then use local port forwarding to implement intranet ECS on the customer PC terminal Direct access to RDS provides customers with great convenience for remote management.
The data flow direction is as follows:
The customer PC terminal can log in to the ECS on the public network via ssh server.
An ECS server on the public network can access other intranet ECS servers through the intranet.
An ECS server with a public network can access RDS through the intranet (the intranet IP of ECS is in the whitelist of RDS).
1. Use putty on the client and fill in the IP and ssh port of the public ECS
2. Set up SSH Tunnel: Source Port is the local listening port of the PC, Destination fill in the intranet address and port of the intranet ECS server. Then click Add, a port forwarding record will be generated, and then click Open will open the SSH connection:
3. In In the pop-up window, enter normal SSH to log in to the ECS server with a public IP:
4. At this time, use the netstat –na command on the client PC terminal and you should see a Local monitoring of port 22 of 127.0.0.1:
5. By connecting to this local port, you can connect to the ECS server on the intranet:
6. This method is also applicable to Windows systems (in order not to conflict with the port of the client PC terminal, port 33389 is used as the local listening port)
7. RDS on the intranet can also be implemented:
8. Yes It is very convenient to directly use the database client program on the client PC terminal to connect to the database in RDS.
In addition, this function in SecureCRT is called Port forwarding , and the same function can be achieved after similar configuration.
The above is the detailed content of Detailed graphic and text steps for Linux to access intranet services through port forwarding. For more information, please follow other related articles on the PHP Chinese website!