• NPS 内网穿透配置


    一直用FRP,配置简单,使用简单,比较稳定,但有时候也有抽风的事件发生,用NPS做个备用。

    1、下载,因为我是linux环境,下载了linux对应的server和client,已编译好,直接运行即可

    https://github.com/ehang-io/nps/releases

    https://github.com/ehang-io/nps/releases/download/v0.26.9/linux_amd64_client.tar.gz

    https://github.com/ehang-io/nps/releases/download/v0.26.9/linux_amd64_server.tar.gz

    2、部署

    公网服务器部署server、内网服务器部署client

    2.1、服务器配置

    解压后,直接修改配置文件,没用的删了,其它别动:

    bridge 是服务端类型、地址、监听端口,把端口改成自己的就行。
    public_vkey是客户端连接服务端认证用的,但是此处修改不生效,不知道为啥,不用管就行
    web区块,这儿是服务端web访问的配置,看这配就行,官方说端口可以和bridge里一致,但实际测试发现不行,要两个不同的端口,其它都没用,默认就好
    appname = nps
    #Boot mode(dev|pro)
    runmode = dev
    
    ##bridge
    bridge_type=tcp
    bridge_port=8888
    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=/opt/nps/nps.log
    
    #web
    web_host=www.baidu.com
    web_username=admin
    web_password=666
    web_port = 8889
    web_ip=0.0.0.0
    web_base_url= /nps
    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 =1234567887654321
    
    #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=true
    
    #pprof debug options
    #pprof_ip=0.0.0.0
    #pprof_port=9999
    
    #client disconnect timeout
    disconnect_timeout=60

    2.2、客户端配置

    除了 server_addr 和服务端  bridge  配置一致外,其它不用动,把配置文件的其余部分删了,配置也不起作用,这个版本测试发现必须从网页上配

    [common]
    server_addr=www.baidu.com:8888
    conn_type=tcp
    vkey=123
    auto_reconnection=true
    max_conn=1000
    flow_limit=1000
    rate_limit=1000
    crypt=true
    compress=true
    disconnect_timeout=60

    2.3、启动服务端

    ./nps

    2.4、服务端配置客户端访问

    登录服务端管理地址:www.baidu.com:8888 用配置的用户名密码登录(admin:666)

    在客户端这儿新增就行:

     然后可以对每个客户端配置隧道。

    客户端连接用服务端给出的命令就行,点网页上每个客户端前面的+就能看到。

    2.5、启动客户端

    ./npc -server=www.baidu.com:8888 vkey=8rehr93fwurfj04j -type=tcp

    3、防止进程奔溃

    在nps和npc同目录下创建start.sh,内容如下:

    cd $(dirname $0)
    pid=$(pgrep npc)
    if [ -z "$pid" ]; then
        nohup ./npc -server=www.baidu.com:8888 vkey=8rehr93fwurfj04j -type=tcp >/dev/null 2>&1 &
    fi

    要记得:chmod a+x start.sh

    要记得:*/10 * * * * root bash /opt/nps/start.sh

     
  • 相关阅读:
    SharePoint:扩展DVWP 第11部分:在工作流中使用更多的表单字段
    Guava学习笔记:Google Guava 类库简介
    每天一个linux命令(59):rcp命令
    每天一个linux命令(60):scp命令
    【转载】程序员要勇于说不
    深入理解Java:内省(Introspector)
    Guava学习笔记:Optional优雅的使用null
    深入理解Java:注解(Annotation)基本概念
    深入理解Java:SimpleDateFormat安全的时间格式化
    每天一个linux命令(58):telnet命令
  • 原文地址:https://www.cnblogs.com/dwj192/p/14015349.html
Copyright © 2020-2023  润新知