Configure a fixed TCP address for remote access to the Raspberry Pi from the public network

Today we will introduce to you how to set up cpolar to build a permanent fixed TCP address for Raspberry Pi's SSH.

If you have read our previous article introduction, you will easily find that the key to allowing the public Internet to access the Raspberry Pi through SSH is the data tunnel opened by cpolar, so you want to make the Raspberry Pi stable at any time Access, you must set up cpolar. Specifically:

1. Log in to the cpolar official website to upgrade the package

At the beginning of cpolar's design, users' needs for stable data tunnels were considered. Therefore, cpolar can fix a certain (or multiple) data tunnels by upgrading the service package type for the convenience of customers. Just log in to cpolar official website. Enter the "dashboard" under your own account, and you can easily upgrade the package.

2. Set the TCP address that needs to be reserved

In this step, we need to click the "Reserve" button on the left side of the page under the cpolar dashboard page. After entering the "Reserved" interface, click the "Reserved TCP" address option.

img

Here, select China VIP for "Region", and fill in "Description" according to the actual situation to distinguish different SSH. After filling in the content, you can click the "Reserve" button on the right to let cpolar generate a fixed TCP address to achieve the purpose of using the tunnel for a long time.

img

Then we need to bind the TCP address reserved by cpolar to the local SSH port, that is, enter the command line:

cpolar tcp -remote-addr=1.tcp.vip.cpolar.cn:20046 22

At this time, modify the configuration file of cpolar in the Raspberry Pi, and let cpolar remember the modification we made. Enter the "nano /usr/local/etc/cpolar/cpolar.yml" command in the Raspberry Pi to open the cpolar configuration file.

Enter "remote_addr=1.tcp.vip.cpolar.cn:20046" in it, and the content shown in the following picture will appear, which means the modification is successful.

img

It should be noted that the remote_addr parameter in the configuration file is an underscore, while the -remote-addr used in the command line is an underscore, and the two should not be confused. After entering the correct command line, you can save and exit.

In order to confirm that the configuration modification made is correct, we should conduct a test, that is, enter "cpolar start ssh" on the cpolar interface to start the data tunnel separately:

img

If the above display appears, it means that cpolar has correctly started the reserved data tunnel. Then we save and exit, restart cpolar (enter "sudo systemctl restart cpolar"), and then connect to SSH with a fixed public Internet address "ssh [email protected] -p 20046", at this time the user can pass SSH , using the fixed TCP address of cpolar to operate. Of course, in actual operation, the port number assigned to each person is different, so the customer needs to change the port number to the actually assigned port number when entering the command line, so as to avoid failure to connect.

During the operation, the port number assigned to each person is different, so the customer needs to change the port number to the actually assigned port number when entering the command line, so as to avoid failure to connect.

As can be seen from the above introduction, the operation of reserving a fixed TCP port for Raspberry Pi's SSH is not complicated, there is only one point to pay attention to. You can try it yourself and let your Raspberry Pi have a fixed TCP address. If you have any questions about the use of cpolar, welcome to communicate with us, and we will provide you with the best possible help.

Reprinted from the cpolar pole cloud article: Configuring a fixed TCP address for remote access to the Raspberry Pi from the public network

Guess you like

Origin blog.csdn.net/zxb_1222/article/details/131958464
Recommended