How does the server perform port forwarding to enable communication between servers, and then access the target website (baidu.com)

How does the server perform port forwarding to enable communication between servers, and then access the target website (baidu.com)

Cause of the problem

If one of our servers is broken and cannot access the Internet, as a failed man, no, it should be a failed server, and I feel uncomfortable. If it was a vps purchased by myself, it would be a pity to throw it away, but it can't be used, and I feel very bad.

The solution is: use another overseas secure server, this secure server is a successful person, and then let this successful person act as a bridge, we call it an intermediate server, and our broken server is called a destination server.

We visit the successful people, and then the successful people map the port to the failed man, and finally let the failed man handle things, such as visiting Baidu, and then return the content. Return to the successful people first, and the successful people will give it back to us.

We access the intermediate server, then the intermediate server maps the port to the destination server, and finally let the destination server handle things, such as accessing Baidu.

required environment

Both vps need to install the x-ui panel, so only x-ui is needed.

Installing x-ui is very simple, the command is as follows:

apt install -y curl socat

bash <(curl -Ls https://raw.githubusercontent.com/vaxilu/x-ui/master/install.sh) 

Steps

You need two vps, you can try to play it yourself. It can be purchased through Tencent, Ali, etc., but it is more expensive. You can find some cheap ones online.

Suppose our intermediate server ip2 is 2.2.2.2, and the destination server ip1 is 1.1.1.1.

The current problem is: first of all, make sure that we can access ip2, but we cannot access ip1, nor can we access Baidu through ip1.

Our purpose: through the port mapping from ip1 to ip2, realize the machine --> ip2 --> ip1 --> baidu.com.

1. Destination server settings

The target server ip1 will create a node normally, assuming we have already created it and imported it into v2rayN.

At this point, we can see that our damaged server is 1.1.1.1, and the port we created is 100. Because the server is damaged, there is no network, and Baidu cannot be accessed.

Remember the ip and port number, you will need it later.

1.1.1.1 and 100

insert image description here

2. Intermediate server settings

That is, the server settings of ip2.

Open the x-ui panel and create a node as shown below.

Choose dokodemo-door as the protocol, and choose the port by yourself. This is the port to be mapped later, and traffic is forwarded through this port and turned to ip1.

For the target address and port number, just fill in the above. After the settings are complete, click Add.

Remember the ip of the intermediate server, which is 2.2.2.2, and port 2000. Will use it later.

insert image description here

At this point, the setting of the intermediate server has also been completed.

3. Modify the client

Modify the content of client v2rayN.

Now you need to go to v2rayN to modify the content, double-click the node just imported.

Modify the address and port number to that of the intermediate server.

Address changed from 1.1.1.1 to 2.2.2.2

Port number changed from 100 to 2000
insert image description here

At this point the client has also been set up. You can view the real delay and test.

Now you can go online through the client. You can visit Baidu happily. Check the ip at this time, and you can see that your ip is the ip of the failed man, that is, 1.1.1.1.

insert image description here

Summarize

Through this article, we can save the failed man.

By allowing a successful person to build a bridge, make port mapping, and shine on the failed man, you can access the Internet hierarchically (made up), and the failed man visits Baidu, and then returns the data.

Guess you like

Origin blog.csdn.net/qq_36693723/article/details/130650968