📦 nps 内网穿透工具部署与使用手册(适用于 Debian 12 + Windows 客户端)
✅ 一、服务端部署(Debian 12)
1. 下载并解压 nps 服务端
wget https://github.com/ehang-io/nps/releases/download/v0.26.10/linux_amd64_server.tar.gz tar -zxvf linux_amd64_server.tar.gz cd nps
2. 安装为系统服务
sudo ./nps install
安装后配置文件在
/etc/nps/nps.conf
,日志在/var/log/nps.log
3. 启动服务
sudo ./nps start
🔧 二、检查端口占用(重要)
检查 80、443、8080、8024 是否被占用:
sudo ss -tuln | grep -E ':80|:443|:8080|:8024'
若被占用(如 nginx 占用 80):
解决方案 1:修改 nps 配置文件
sudo nano /etc/nps/nps.conf
修改端口如下:
http_proxy_port=18080 https_proxy_port=18443 web_port=8080 bridge_port=8031
解决方案 2:保留 nginx,用其反代 nps
🌐 三、登录 Web 管理后台
浏览器访问:
http://<你的服务器IP>:8080
默认账号密码:
admin / 123
登录后建议在右上角修改密码,或手动编辑
/etc/nps/nps.conf
中的:
web_username=你的账号 web_password=你的密码
🧩 四、客户端配置与连接(Windows)
1. 下载 npc
客户端(windows_amd64_client.zip)
解压后保留 npc.exe
2. 正确配置 npc.conf
[common] server_addr=<你的服务器IP>:8031 vkey=123 conn_type=tcp crypt=true compress=true [tcp_ssh] mode=tcp target_addr=127.0.0.1:22 server_port=10022
3. 启动客户端
npc.exe -config=./npc.conf
📈 五、验证是否运行成功
服务端查看运行状态
ps aux | grep nps sudo ss -tuln | grep 8031 sudo cat /var/log/nps.log
客户端成功日志(关键句):
Successful connection with server <你的服务器IP>:8031
❗ 六、常见错误与解决方案
错误日志 问题原因 解决方式 bind: address already in use
端口被占用(如 80 被 nginx 用了) 修改 nps.conf
,避开冲突端口 connectex: No connection could be made...
客户端连接的是 127.0.0.1:8024,而不是远程服务器 修改 npc.conf
的 server_addr=你的公网IP:端口
getaddrinfow: The specified class was not found
配置中的 server_addr=...
后面带了中文注释,导致识别失败 注释必须放在新行,不能和 =
同行 strconv.Atoi: parsing "": invalid syntax
某个服务配置缺少必填字段,如 server_port
或 target_addr
检查配置段落,添加缺失项 Only one usage of each socket address
UDP 或 TCP 端口重复绑定 改用不冲突的本地端口;关闭残留进程
✅ 七、使用建议
- ✅ 尽量只配置当前用到的服务(如 TCP、HTTP、socks5)
- ✅ 每次修改配置后 重新启动 nps 或 npc
- ✅ 用
ss
或netstat
确认端口状态 - ✅ 把注释放在配置项下方的新一行,避免格式错误