简介
以前一直使用的FRP作为内网穿透工具,使用效果也不错,但是唯一的缺点是每次新开放端口都需要登录到各个内网机器去配置。在研究软路由固件时候看到有NPS的选项,才发现使用NPS内网穿透可以在web服务端统一配置新开接口,下面记录一下搭建NPS服务端的过程。
1.下载并解压
下载地址为:https://github.com/ehang-io/nps/releases1
tar -zxvf linux_amd64_server.tar.gz
2.执行install
1 | ./nps install |
3.编辑配置文件
1 | vim /etc/nps/conf/nps.conf |
修改如下内容为自己的:1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85appname = nps
#Boot mode(dev|pro)
runmode = dev
#HTTP(S) proxy port, no startup if empty
http_proxy_ip=0.0.0.0
http_proxy_port=80
https_proxy_port=443
https_just_proxy=true
#default https certificate setting
https_default_cert_file=conf/server.pem
https_default_key_file=conf/server.key
##bridge
bridge_type=tcp
bridge_port=3024
bridge_ip=0.0.0.0
# Public password, which clients can use to connect to the server
# After the connection, the server will be able to open relevant ports and parse related domain names according to its own configuration file.
public_vkey=123
#Traffic data persistence interval(minute)
#Ignorance means no persistence
#flow_store_interval=1
# log level LevelEmergency->0 LevelAlert->1 LevelCritical->2 LevelError->3 LevelWarning->4 LevelNotice->5 LevelInformational->6 LevelDebug->7
log_level=7
#log_path=nps.log
#Whether to restrict IP access, true or false or ignore
#ip_limit=true
#p2p
#p2p_ip=127.0.0.1
#p2p_port=6000
#web
web_host=a.o.com
web_username=admin
web_password=123
web_port = 8080
web_ip=0.0.0.0
web_base_url=
web_open_ssl=false
web_cert_file=conf/server.pem
web_key_file=conf/server.key
# if web under proxy use sub path. like http://host/nps need this.
#web_base_url=/nps
#Web API unauthenticated IP address(the len of auth_crypt_key must be 16)
#Remove comments if needed
#auth_key=test
auth_crypt_key =1234567812345678
#allow_ports=9001-9009,10001,11000-12000
#Web management multi-user login
allow_user_login=false
allow_user_register=false
allow_user_change_username=false
#extension
allow_flow_limit=false
allow_rate_limit=false
allow_tunnel_num_limit=false
allow_local_proxy=false
allow_connection_num_limit=false
allow_multi_ip=false
system_info_display=false
#cache
http_cache=false
http_cache_length=100
#get origin ip
http_add_origin_header=false
#pprof debug options
#pprof_ip=0.0.0.0
#pprof_port=9999
#client disconnect timeout
disconnect_timeout=60
4.启动
1 | ./nps start |
5.加入开机启动项
- 编辑
1
vim /etc/systemd/system/nps.service
按下 i
进入编辑模式,复制以下内容并粘贴到文件中1
2
3
4
5
6
7
8
9
10
11
12[Unit]
Description=nps server
[Service]
User=root
WorkingDirectory=/nps/
LimitNOFILE=4096
PIDFile=/var/run/nps/server.pid
ExecStart=/nps/nps
Restart=on-failure
StartLimitInterval=600
[Install]
WantedBy=multi-user.target
然后按 Esc,接着输入 wq
保存。
接着输入以下命令:
1
systemctl daemon-reload
服务就创建成功了,接下来启动服务:
1
systemctl start nps
将服务设置为开机启动
1
systemctl enable nps
+如果要停止运行客户端,只需要输入1
systemctl stop nps
- 如果要禁止开机启动,输入
1
systemctl disable nps
6.登录管理页面,配置客户端和Tcp隧道
7.在客户端输入相关参数进行连接
后续新开端口只需在管理端操作即可,这里不再赘述!
本文链接: https://www.xiajunyi.com/pages/p101.html
版权声明:本作品采用知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议进行许可。转载请注明出处!