title: 70.搭建nps内网穿透 CreateTime: 2021-06-11 16:00:00 UpdateTime: 2021-06-11 16:00:00 CategoryName: web --- --- title: "70.搭建nps内网穿透" date: 2021-06-11T16:00:00+08:00 draft: false tags: ["web"] categories: ["web"] author: "springrain" --- ## 1. 准备要求 nps-server: https://github.com/ehang-io/nps/releases/download/v0.26.10/linux_amd64_server.tar.gz nps-client: https://github.com/ehang-io/nps/releases/download/v0.26.10/linux_amd64_client.tar.gz 服务端安装到公网服务器,客户端安装到内网电脑上,在nps配置好,通过公网服务器的IP:端口,把请求转发到内网的电脑上. ## 2. 在公网服务器安装服务端 ```shell ## 下载服务端 curl https://github.com/ehang-io/nps/releases/download/v0.26.10/linux_amd64_server.tar.gz tar -zxvf linux_amd64_server.tar.gz ## 修改服务端配置 vi ./conf/nps.conf ## 代理的http协议端口 #http_proxy_port=7070 #https_proxy_port=8443 ## nps客户端连接服务端的端口 bridge_port=8024 ## nps自带的web管理界面的账号密码和端口 #web_username=admin #web_password=123 #web_port = 8080 ## 启动服务端 ./nps #后台运行,建议设置开机启动 #nohup /root/nps & ``` ## 3.配置服务端 访问设置的服务器 web_port(8080) 端口,设置中文 ![设置中文](/public/70/1.png) 添加客户端,客户端就是内网电脑. ![添加客户端](/public/70/2.png) 记录客户端的 唯一验证密钥. ![添加客户端](/public/70/3.png) 添加TCP隧道,给内网电脑设置穿透的端口.一个客户端可以映射多个隧道端口. ![添加客户端](/public/70/4.png) ## 4.npc客户端连接NPS服务端 ```shell curl https://github.com/ehang-io/nps/releases/download/v0.26.10/linux_amd64_client.tar.gz tar -zxvf linux_amd64_client.tar.gz #./npc -server=公网服务器IP:bridge_port -vkey=web界面中显示的唯一验证密钥 ./npc -server=88.88.88.88:8024 -vkey=dsdfsdfsdf #后台运行,建议设置开机启动 #nohup /root/npc -server=88.88.88.88:8024 -vkey=dsdfsdfsdf & ```