Before we start
In order to follow this guide, I assume you already have a VPS and facing an intranet situation which you can’t expose a port to the public. If you have extranets, DDNS is more suitable for you.
I will use a Ubuntu 18.04 machine for this guide. The command line will differ among different machine types. Make sure you fully aware of that. So, Let’s dive right in.
Install NPS
Use any of your favorable SSH clients to connect to the VPS, Then follow the command below:
## First create a folder for your nps service mkdir nps ## cd to that directory cd nps ## pull the nps file (in this guide, I will use amd64 version of nps, please choose the suitable one for your own machine) wget https://github.com/ehang-io/nps/releases/download/v0.26.6/linux_amd64_server.tar.gz ## untar the file tar -xvf linux_amd64_server.tar.gz ## see the relevant files ls ## install the nps sudo ./nps install ## navigate to the nps config file folder cd /etc/nps ## modify the config setting to suit your need nano conf/nps.conf ## start the nps sudo nps start ## access the dashboard Access server IP:web service port (default is 8080).
Login with username and password (default is admin/123, must be modified when officially used).
Connect a client
Create a client on the NPS portal. I will demonstrate how to connect to my home router and NAS in this example.
First, choose the client on the left panel, then choose a remark for your client. You can leave all the other fields blank, click Add when you finished.
Login to your router and input your server ip, port, and vkey, then connect to the NPS (It’s highly recommend to put this kind of service on your primary router).
Create a TCP profile to connect to your home router. In this example, I use server IP:9000 to access my home router address as 192.168.123.1:80.
Docker Way
You can also install NPS as Docker image, the docker way is describe below.
Install Docker on VPS
First, Use any of your favorable SSH clients to connect to the VPS, Then follow the command below:
The following command is used for CentOS only.
## this will update your system packages sudo yum update ## this will install the required dependencies sudo yum install yum-utils device-mapper-persistent-data lvm2 ## add the <a href="https://www.920.im/tag/docker/" title="查看更多关于Docker的文章" target="_blank">Docker</a> stable repository to your system: sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo ## install the latest version of <a href="https://www.920.im/tag/docker/" title="查看更多关于Docker的文章" target="_blank">Docker</a> CE sudo yum install docker-ce ## start the <a href="https://www.920.im/tag/docker/" title="查看更多关于Docker的文章" target="_blank">Docker</a> daemon and enable it to automatically start at boot time sudo systemctl start docker sudo systemctl enable docker ## verify that the <a href="https://www.920.im/tag/docker/" title="查看更多关于Docker的文章" target="_blank">Docker</a> service is running sudo systemctl status docker ## check the Docker version docker -v
Now, the Docker should be installed and running on your machine. But by default managing, Docker requires administrator privileges. If you want to run Docker commands as a non-root user without prepending sudo you need to add your user to the docker group which is created during the installation of the Docker CE package. You can do that by typing:
sudo usermod -aG docker $USER
Log out and log back in so that the group membership is refreshed. Then you should be able to run docker commands without sudo. Now, let’s test it by typing:
docker container run hello-world
If you get the message like below, you’re good to go:
Unable to find image ‘hello-world:latest’ locally
latest: Pulling from library/hello-world
9bb5a5d4561a: Pull complete
Digest: sha256:f5233545e43561214ca4891fd1157e1c3c563316ed8e237750d59bde73361e77
Status: Downloaded newer image for hello-world:latest
Hello from Docker!
This message shows that your installation appears to be working correctly.
Install NPS to the Docker
docker pull ffdfgdfg/nps
You can manage your Docker image better with GUI interface by using Portainer. This is optional, but I will install Portainer in this case.
docker volume create portainer_data docker run -d -p 8000:8000 -p 9000:9000 --name=portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer
Now, you can access Portainer dashboard by entering your VPS IP:9000, you will create an administrator account when you first login. Choose local to connect with your Docker. Then you can check the NPS image you just pulled by going to the images tab.
Modify the Conf file
Download the NPS conf folder here, then modify the nps.conf file.
web_username=admin
web_password=123
You can change your login information by changing the above parameter.
Once you’re done, you can upload the conf folder to your VPS directory.
Start NPS
docker run -d –name nps –net=host -v <your vps conf folder directory>:/conf ffdfgdfg/nps
Like in this tutorial, I upload the conf folder to the /home/centos folder, then <my vps conf folder directory> will be /home/centos/conf
Once the nps started, you can access the web panel by entering your VPS IP:8080.
Now, you can config and connect your client here.
中文教程由此开始
开始之前
为了参照此教程,我默认你已经有了一台VPS服务器并且面临内网环境,无法开放端口给外网访问。如果你有公网IP,DDNS更适合你。
在此教程中我使用Ubuntu 18.04系统为例。相关命令可能在不同系统上略有不同,请确保悉知这一点。那让我们正式开始。
安装NPS
使用你喜欢的任意SSH客户端连接VPS,之后参照以下命令
## 首选创建一个nps文件夹 mkdir nps ## cd到这个目录 cd nps ## 拉取nps镜像(在此教程中我拉取的是amd64架构,请根据你服务器实际架构选择,一般都是amd64) wget https://github.com/ehang-io/nps/releases/download/v0.26.6/linux_amd64_server.tar.gz ## 解压相关文件 tar -xvf linux_amd64_server.tar.gz ## 查看解压后的文件 ls ## 安装nps sudo ./nps install ## cd到nps配置文件夹 cd /etc/nps ## 按需修改nps的配置文件 nano conf/nps.conf ## 开启nps sudo nps start ## 登录nps后台 Access server IP:web service port (default is 8080).
使用用户名及密码登录,默认的用户是admin,密码是123.
连接客户端
在NPS后台创建一个客户端,我将演示如何连接到自己家中的路由器和NAS。
首选我们在左边选择客户端,做好备注名,点击添加(其余选择均可留空)
登录你的路由器后台,填入nps后台创建的客户端相关信息,即服务器ip,端口和密钥。(强烈建议将内网穿透等服务放置在自己的主路由上)
创建一个TCP配置去连接家中的路由器。此例中的设置将使用服务器ip:9000端口访问家用的内网路由器地址192.168.123.1:80端口