NPS 内网穿透搭建教程(博主亲测整理)

作者:nctcpc 发表于:2025-11-14


NPS

GitHub stars GitHub forks Release GitHub All Releases

在 GitHub 点击右上角 ⭐ Star 以支持我在空闲时间继续开发


NPS 是一款轻量级高性能功能强大内网穿透代理服务器

  • 多协议支持:原生支持 TCP 与 UDP 流量转发,可承载任意上层协议(SSH、RDP、数据库、游戏联机、内网 DNS、音视频流等)。

  • 域名转发:内置完整的 HTTP/HTTPS 反向代理能力,可通过自定义域名与证书,将公网请求安全透明地转发到内网 Web 服务,适用于线上灰度发布、微信/小程序调试、Webhook 回调等场景。

  • 代理模式丰富:内置 HTTP 代理Socks5 代理,实现类似 VPN 的访问体验;还提供私密代理、P2P 连接,无需将端口暴露在公网环境下。

  • 高效 P2P 直连:支持 TCP/UDP 端到端映射、透明代理和 Socks5 直连;打洞成功时流量不走服务器,打洞失败 TCP 端口 可自动回落到私密代理。

  • Web 管理界面:可视化控制台实时展示隧道状态、流量统计与访问日志,支持多用户、多隧道与细粒度访问控制。

  • 多连接协议:支持通过 TCP、KCP、TLS、QUIC、WS、WSS 协议连接服务器,适应各种不同环境需求。



运行环境:Android | OpenWrt | Linux | Windows | 

Docker 部署

Docker 服务端部署

docker pull duan2001/nps
docker run -d --restart=always --name nps --net=host -v $(pwd)/conf:/conf -v /etc/localtime:/etc/localtime:ro duan2001/nps

Docker客户端部署

docker pull duan2001/npc
docker run -d --restart=always --name npc --net=host duan2001/npc -server=xxx:123,yyy:456 -vkey=key1,key2 -type=tls,tcp -log=off


Linux 部署

Linux 服务端部署

# 安装(默认配置路径:/etc/nps/;二进制文件路径:/usr/bin/)
wget -qO- https://fastly.jsdelivr.net/gh/djylb/nps@master/install.sh | sudo sh -s nps
nps install
nps start|stop|restart|uninstall

# 更新
nps update && nps restart

Linux客户端部署

wget -qO- https://fastly.jsdelivr.net/gh/djylb/nps@master/install.sh | sudo sh -s npc
/usr/bin/npc install -server=xxx:123,yyy:456 -vkey=xxx,yyy -type=tls -log=off
npc start|stop|restart|uninstall

# 更新
npc update && npc restart


Windows 部署

Windows 服务端部署

Windows 7 用户请使用 old 结尾版本 64 / 32

.\nps.exe install
.\nps.exe start|stop|restart|uninstall

# 更新
.\nps.exe stop
.\nps-update.exe update
.\nps.exe start

Windows 客户端部署

Windows 7 用户请使用 old 结尾版本 64 / 32

.\npc.exe install -server="xxx:123,yyy:456" -vkey="xxx,yyy" -type="tls,tcp" -log="off"
.\npc.exe start|stop|restart|uninstall

# 更新
.\npc.exe stop
.\npc-update.exe update
.\npc.exe start


提示: 客户端支持同时连接多个服务器,示例:
npc -server=xxx:123,yyy:456,zzz:789 -vkey=key1,key2,key3 -type=tcp,tls
这里 xxx:123 使用 tcp, yyy:456 和 zzz:789 使用tls

如需连接旧版本服务器请添加 -proto_version=0

Linux系统要注册为服务后台开机自动运行,要不然关闭运行窗口会停止转发,导致远程无法访问。

Windows可以开机自动运行,一句话不能让它停止运行。

版权声明

本文仅代表作者观点,不代表京强博客立场。
本文系作者授权百度百家发表,未经许可,不得转载。

分享:

扫一扫在手机阅读、分享本文

请发表您的评论

您是本站第3名访客 今日有0篇新文章/评论