13
头图

Intranet penetration, that is, NAT penetration, a term for network connection. The computer nodes of the external network and the internal network need to be connected and communicated, and the mapped port can enable the computer on the external network to find the computer on the internal network and improve the download speed.

Application scenarios of intranet penetration

web application development

Publish some web demos developed to the Internet, or remote debugging API interfaces (such as: WeChat public account, development of enterprise accounts)

Access to intranet applications

Applications and databases deployed on the company's intranet require remote access, connection debugging, etc. when personnel travel or go out temporarily.

Remote control of hardware devices

IoT device development and debugging

Today, I will introduce you to a more powerful artifact: serveo

The cool thing is that it doesn't need to download and install any software, just one command! , and more importantly it's completely free!

Serveo overview

Serveo is a free intranet penetration service, Serveo can expose local computers to the Internet, officially called an excellent alternative to Ngrok.

The biggest advantage of serveo is that it can be used directly without installation, registration , and SSH tunneling.

How Serveo Works

The Serveo SSH server is just remote port forwarding, when users connect to Serveo, they get a public URL that anyone can use to connect to the localhost server.

Project address: https://serveo.net

Installation Notes

No installation required, works out of the box.

server prerequisites

It needs to have SSH function and can connect to the Internet normally.

Serveo usage practice

Map the 3000 port of the local application (HTTP service) to the public network

Map the 3000 port of the local application to the public network

 # 如果要转发其它端口,只需替换端口为其它就可以了
$ ssh -R 80:localhost:3000 serveo.net
Hi there
Forwarding HTTP traffic from https://heryum.serveo.net
Press g to start a GUI session and ctrl-c to quit.

The first time you use it, you will be prompted to establish an SSH session, please enter yes to confirm.

After the session is established successfully, it will randomly generate a second-level domain name of xx.serveo.net. You can use the browser to access the randomly generated secondary domain name heryum.serveo.net to access the service on port 3000 of the local computer.

You can also not use this randomly generated domain name. You can customize a second-level domain name that you are used to. It is also possible. The specific operation steps are as follows:

 $ ssh -R mingongge:80:localhost:3000 serveo.net
Hi there
Forwarding HTTP traffic from https://mingongge.serveo.net
Press g to start a GUI session and ctrl-c to quit.
...

# 这个自定义二级域名可以简写,也可以写完整的,如:
$ ssh -R mingongge.serveo.net:80:localhost:8080 serveo.net
2. Penetrate the local port 22 into the public network

Remote access to the local ssh service is actually very simple, just use the following command.

 # 名称为自定义的,这里设置为 mingongge
$ ssh -R mingongge:22:localhost:22 serveo.net
Hi there
Forwarding SSH traffic from alias "mingongge"
Press g to start a GUI session and ctrl-c to quit.
...

After the connection is successful, you can then access the SSH of this intranet computer from the public network.

 $ ssh -J serveo.net user_name@mingongge
Hi there
user_name@mingongge's password:
Last login: Sun 29 May 23:08:12 2022 from 127.0.0.1
...

The -J option is used in OpenSSH 7.3 and above, if your SSH client version is lower, you can use ProxyCommand instead.

 $ ssh -o ProxyCommand="ssh -W mingongge:22 serveo.net" user_name@mingongge

Note : If you cannot access the Serveo service through port 22, the official reserved port 443, the specific changes are as follows:

 $ ssh -p 443 -R 80:localhost:3000 serveo.net
Windows system use

Win10 comes with OpenSSH by default. For other Windows systems, you need to go to the Github of OpenSSH to download and install. The specific installation methods are all above, which will not be introduced here.

If your Win10 system cmd does not recognize the ssh command, it may be that this function is not enabled in your system, and you need to manually configure it to enable it.

The steps to enable are as follows

Settings---Apply, Optional Features---Add optional features

Click the "Add Features" button, see "OpenSSH Server" in the list of optional features, select it, and click "Install"

After the installation is successful, you can run the ssh command in the cmd command prompt window.


民工哥
26.4k 声望56.7k 粉丝

10多年IT职场老司机的经验分享,坚持自学一路从技术小白成长为互联网企业信息技术部门的负责人。2019/2020/2021年度 思否Top Writer