zoukankan      html  css  js  c++  java
  • 公网访问内网实现(内网穿透)

    内网穿透是什么?

    内网穿透是把内网主机连接具有公网IP的设备,使得内网设备代理公网设备,易于 telnet、ssh、ftp等连接

    怎么实现内网穿透?

    frp采用c/s架构,

    内网穿透的工具有很多如

    花生壳

    net123

    ngrok

    frp

    花生壳和nat123属于服务商提供的穿透所以会收取费用(一月40-50 / 128Kb)

    ngrok 和 frp 属于需要手动配置搭建的程序

    frp github :https://github.com/fatedier/frp/blob/master/README_zh.md

     准备工作:

    下载地址: https://github.com/fatedier/frp/releases

    1、带有公网地址的 VPS(例如公网地址为 111.111.222.111 ):后边将会把内网的主机映射到这个 IP 地址

    2、内网主机(可联网)


    那该如何去做?

    这里演示内网windows下穿透成到公网linux主机的端口

    Linux端(server):

    修改frps.ini

    bind_port = 7000
    
    # 服务器端监听http请求的端口(由于80端口被nginx占用,因此指定其他端口)
    vhost_http_port = 81 
    
    # 服务器用以显示连接状态的站点端口,以下配置中可以通过访问IP:7500登录查看frp服务端状态等信息
    dashboard_port = 7500
    
    # dashboard对应的用户名/密码
    dashboard_user = use
    dashboard_pwd = pwd
    
    # 日志文件路径
    #log_file = /root/net-ct/frp/frps.log
    
    
    # 日志记录错误级别,分为:trace, debug, info, warn, erro
    #log_level = warn
    
    # 日志保存最大天数
    #log_max_days = 3
    
    # 客户端连接校验码(客户端需与之相同)
    privilege_token = token123
    
    # heartbeat configure, it's not recommended to modify the default value
    # the default value of heartbeat_timeout is 90
    # heartbeat_timeout = 90
    
    # only allow frpc to bind ports you list, if you set nothing, there won't be any limit
    # privilege_allow_ports = 2000-3000,3001,3003,4000-50000
    
    # pool_count in each proxy will change to max_pool_count if they exceed the maximum value
    max_pool_count = 5
    
    # max ports can be used for each client, default value is 0 means no limit
    max_ports_per_client = 0
    
    # authentication_timeout means the timeout interval (seconds) when the frpc connects frps
    # if authentication_timeout is zero, the time is not verified, default is 900s
    authentication_timeout = 900
    
    # 支持外部访问的域名(需要将域名解析到IP)
    #subdomain_host = frps.domain.com
    

    由于github上有中文解释且解释的比较全面所以这边就不复述了

    启动:./frps -c ./frps.ini

    windows端(client):

    配置frpc.ini

    [common]
    server_addr = 41.91.143.88 #服务器地址
    server_port = 7000 #服务器开放连接的端口
    privilege_token = token123 #服务器token
    auth_token = auth_token
    [RDP]
    type = tcp #使用tcp连接
    local_ip = 127.0.0.1 #本地地址
    local_port = 3389 #穿透到的本地端口(远程桌面端口)
    remote_port = 7001 #开发到公网连接的端口

    启动:frpc.exe -c frpc.ini

    即可

    来实验下吧

    mstsc下

    服务器地址:7001 就可以了

    转载自:http://www.forever121.cn/?p=253

  • 相关阅读:
    最短路径
    图解最小生成树
    图解最小生成树





    线索二叉树
    二叉树
  • 原文地址:https://www.cnblogs.com/flyxuxi/p/12958304.html
Copyright © 2011-2022 走看看