一款轻量级、高性能、功能强大的内网穿透代理服务器。支持tcp、udp、socks5、http等几乎所有流量转发,可用来访问内网网站、本地支付接口调试、ssh访问、远程桌面,内网dns解析、内网socks5代理等等……,并带有功能强大的web管理端。
首先说明一下安装方式分为以下三种:
- 安装包安装
下载对应的系统版本即可,服务端和客户端是单独的
- 源码安装
1 2 3 4 5 6 7 |
#安装源码 go get -u ehang.io/nps #服务端编译 go build cmd/nps/nps.go #客户端编译 go build cmd/npc/npc.go |
请根据自己情况选择
服务端(Server)部署
这里我是用的是直接下载*.tar.gz安装包的方法
- 下载
1 2 3 4 5 6 7 |
[root@10-9-146-177 ~]# wget https://github.com/ehang-io/nps/releases/download/v0.26.8/linux_amd64_server.tar.gz --2020-06-30 11:34:59-- https://github.com/ehang-io/nps/releases/download/v0.26.8/linux_amd64_server.tar.gz Resolving github.com (github.com)... 52.74.223.119 ...... 100%[================================================================================================================================>] 6,160,618 1.14MB/s in 6.2s 2020-06-30 11:35:07 (971 KB/s) - ‘linux_amd64_server.tar.gz’ saved [6160618/6160618] |
- 解压
1 2 3 4 5 6 7 |
[root@10-9-146-177 ~]# mkdir /.nps && tar -zxvf linux_amd64_server.tar.gz /.nps/ conf/nps.conf conf/tasks.json conf/clients.json conf/hosts.json ...... |
- 安装
1 2 |
[root@10-9-146-177 .nps]# ./nps install |
- 编辑配置文件
1 2 |
[root@10-9-146-177 .nps]# vi /etc/nps/conf/nps.conf |
- 重载配置文件
1 2 |
[root@10-9-146-177 .nps]# nps reload |
以下是配置文件说明[3]
- /conf/nps.conf
名称 | 含义 |
---|---|
web_port | web管理端口 |
web_password | web界面管理密码 |
web_username | web界面管理账号 |
web_base_url | web管理主路径,用于将web管理置于代理子路径后面 |
bridge_port | 服务端客户端通信端口 |
https_proxy_port | 域名代理https代理监听端口 |
http_proxy_port | 域名代理http代理监听端口 |
auth_key | web api密钥 |
bridge_type | 客户端与服务端连接方式kcp或tcp |
public_vkey | 客户端以配置文件模式启动时的密钥,设置为空表示关闭客户端配置文件连接模式 |
ip_limit | 是否限制ip访问,true或false或忽略 |
flow_store_interval | 服务端流量数据持久化间隔,单位分钟,忽略表示不持久化 |
log_level | 日志输出级别 |
auth_crypt_key | 获取服务端authKey时的aes加密密钥,16位 |
p2p_ip | 服务端Ip,使用p2p模式必填 |
p2p_port | p2p模式开启的udp端口 |
pprof_ip | debug pprof 服务端ip |
pprof_port | debug pprof 端口 |
disconnect_timeout | 客户端连接超时,单位 5s,默认值 60,即 300s = 5mins |
服务端WEB UI的使用
安装完成之后你就可以使用 http://IP:8080
打开登录页面
默认用户名: admin
默认密码: 123
点击 客户端>新增
客户端(Client)映射端口
- 首先你要知道安装方式有两种
- 无配置文件模式
- 使用配置文件模式
Linux[1]
下载解压后进入该目录
- 注册:sudo ./npc install 其他参数(例如-server=xx -vkey=xx或者-config=xxx)
- 启动:sudo npc start
- 停止:sudo npc stop
- 如果需要更换命令内容需要先卸载./npc uninstall
,再重新注册
例子:
我现在要将ssh的22端口映射到公网
- 照着“服务端WEB UI的使用”添加客户端,并记住你的客户端ID
- 安装注册服务
1 2 |
[root@npc_client .npc]# ./npc install -server=106.75.37.144:8024 -vkey=lenovo_y560 -type=tcp |
在客户端配置中可以找到客户端命令,只需要稍做修改加一个install就行了
如果一切都没问题你可以看到连接状态变为了在线
3. 然后依次点击TCP隧道>添加完善信息
如果一切都没问题你可以看到客户端状态为在线
这时候你只需要使用ssh工具连接 服务端IP:8022
就可以访问了
如果不通,请检查服务器端口是否开放。
Windows[2]
使用管理员身份运行cmd进入到解压后的client目录
- 注册:npc.exe install 其他参数(例如-server=xx -vkey=xx或者-config=xxx)
- 启动:npc.exe start
- 停止:npc.exe stop
- 如果需要更换命令内容需要先卸载npc.exe uninstall
,再重新注册
windows的配置方法同理不再赘述
更多请到github找到该项目查看
文章评论(0)