Giter Club home page Giter Club logo

bjdgyc / anylink Goto Github PK

View Code? Open in Web Editor NEW
1.5K 37.0 357.0 2.62 MB

AnyLink是一个企业级远程办公 ssl vpn 软件,可以支持多人同时在线使用。基于 openconnect 协议开发,并且借鉴了 ocserv 的开发思路,可以完全兼容 AnyConnect 客户端。

License: GNU Affero General Public License v3.0

Go 58.96% Shell 1.68% JavaScript 1.40% HTML 2.02% Vue 35.65% Dockerfile 0.30%
enterprise vpn anyconnect sslvpn ocserv openconnect openvpn

anylink's People

Contributors

0x0021 avatar 7357657 avatar aiminickwong avatar bjdgyc avatar denymz avatar dependabot[bot] avatar dimitripapadopoulos avatar imhun avatar itviewer avatar lanrenwo avatar potterli20 avatar shikaiguo avatar taoso avatar wsczx avatar xbclub avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

anylink's Issues

高危漏洞

绿盟扫描发现高危漏洞
报告
请问该漏洞可否修复

Anylink安装使用教程(tun模式)

Anylink安装使用教程

github地址:https://github.com/bjdgyc/anylink
gitee地址:https://gitee.com/bjdgyc/anylink

演示环境

基础环境说明

阿里云ECS,内网网段172.24.128.0/20,使用tun模式,自签证书,0.7.2版本

名称 公网IP 内网IP 系统
ECS01 47.108.53.88 172.24.135.36 centos7.5 最小安装
ECS02 172.24.135.37 centos7.5 最小安装

ps: ECS02只是用于测试使用,我在上面安装了一个nginx用于测试访问web是否正常

查看网卡名称

在要安装anylink的服务器上,查看内网ip地址所绑定的网卡名,本次演示环境网卡名称为eth0
image-20220102142915312

防火墙开放

anylink需要一个端口供客户端远程连接,这里选择默认的443,并且还需要一个端口用于访问web管理后台,这里也选择默认的8800,如果有需要请自行更换,因为云服务器默认关闭了selinux和firewalld,使用安全组,所以需要在安全组上开放内网网段和两个公网访问端口(443和8800)即可。

image-20220102125414968

如果你是本地机房也需要开放一个公网IP地址+端口供客户端远程连接,并且关闭selinux和firewalld

  1. 关闭selinux

    sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config # 永久关闭selinux(重启后生效)
    setenforce 0 # 临时关闭selinux(不需要重启,立即生效)
  2. 关闭firewalld

    systemctl stop firewalld # 临时关闭防火墙
    systemctl disable firewalld # 永久关闭防火墙

anylink 二进制包安装

安装和配置

  1. 下载anylink,本教程指定下载0.7.2版本,下载地址https://github.com/bjdgyc/anylink/releases/download/v0.7.2/anylink-deploy.tar.gz,用浏览器下载好后上传到服务器ECS01

  2. SSH到服务器ECS01,解压二进制包到/usr/local目录

    tar -xzvf anylink-deploy.tar.gz -C /usr/local/
  3. 进入anylink目录

    cd /usr/local/anylink-deploy
  4. 生成密码1q2w%3e4r的密文,请修改为你自己要设置的密码

    注意密码不能有$符号,会被当成变量,也可以用单引号包起来

    ./anylink tool -p 1q2w%3e4r

    image-20220102122211232

  5. 生成jwt密钥

    ./anylink tool -s

    image-20220102122347645

  6. 进入conf配置目录

    cd conf
  7. 拷贝配置文件模板

    cp server-sample.toml server.toml
  8. 打开配置文件

    vi server.toml
  9. 修改如下部分,其他保持不变:

    #示例配置信息
    
    #其他配置文件,可以使用绝对路径
    #或者相对于 anylink 二进制文件的路径
    
    #数据文件
    db_type = "sqlite3"
    db_source = "./conf/anylink.db"
    #证书文件 使用跟nginx一样的证书即可
    cert_file = "./conf/vpn_cert.pem"
    cert_key = "./conf/vpn_cert.key"
    files_path = "./conf/files"
    profile = "./conf/profile.xml"
    #日志目录,为空写入标准输出
    log_path = "./log" # 添加日志文件路径
    log_level = "info" # 修改日志等级为info
    pprof = false
    
    #系统名称
    issuer = "anylink vpn" # 修改系统名称
    #后台管理用户
    admin_user = "admin"
    #pass 1q2w%3e4r   你可以将明文密码写在这里,不建议
    admin_pass = "$2a$10$lvOe.X6VFL/.uf/pN4q8CezUVViovYh2zT9UdeReuscNBEZz.WATm" # 填入第4步生成的密文
    jwt_secret = "iYP8MCJ0nswI2p0bMN6wnkQ2aVJxS_tg5rNX8NVcitqj3OferWzUZXNX1OvV" # 填入第5步生成的jwt密钥
    
    
    #服务监听地址
    server_addr = ":443" # 客户端要连接的端口,如果有需要请自行修改,安全组记得开放该端口
    #开启 DTLS, 默认关闭
    server_dtls = false
    server_dtls_addr = ":4433"
    #后台服务监听地址
    admin_addr = ":8800" # 后台管理端口
    #开启tcp proxy protocol协议
    proxy_protocol = false
    
    link_mode = "tun"  # 网络模式,只演示该模式,其他模式请自行参考github
    
    #客户端分配的ip地址池
    ipv4_master = "eth0" # 网卡名,前面查看绑定内网的网卡名称
    ipv4_cidr = "192.168.10.0/24" # 如果没有和内网网段冲突就不要改了,这个是分配给客户端的ip地址池,并且后面配置nat也要与这个地址池保持一致
    ipv4_gateway = "192.168.10.1"
    ipv4_start = "192.168.10.100"
    ipv4_end = "192.168.10.200"
    
    #最大客户端数量
    max_client = 100
    #单个用户同时在线数量
    max_user_client = 3
    #IP租期(秒)
    ip_lease = 1209600
    
    #默认选择的组
    default_group = "one"
    
    #客户端失效检测时间(秒) dpd > keepalive
    cstp_keepalive = 20
    cstp_dpd = 30
    mobile_keepalive = 40
    mobile_dpd = 50
    #session过期时间,用于断线重连,0永不过期
    session_timeout = 3600
    auth_timeout = 0
    audit_interval = -1
  10. 创建日志文件目录,请修改为自己配置的日志路径,不创建会启动失败,如果没有打开日志输出,可以跳过

    mkdir /usr/local/anylink-deploy/log
  11. 打开profile.xml文件

    vi profile.xml

12. 修改如下配置 (这步可以不设置)

```shell
<HostName>anylink vpn</HostName> # 第30行,最好与server.toml配置文件中的系统名称保持一致,用于客户端区分
<HostAddress>47.108.53.88:443</HostAddress> # 第31行,客户端连接地址,域名加端口,或者IP加端口
```
![image-20220102151002435](https://user-images.githubusercontent.com/57223696/147929183-ac276ca6-5acd-4895-a477-2dd4df41342f.png)

生成自签证书

你可以购买证书或者使用免费的证书,这里使用自签证书,根证书和根私钥生成一次后,可以保留,给所有项目使用,就不用重复信任根证书了

  1. 创建配置文件,请修改为自己IP地址和域名

    cat > openssl.cnf << EOF
    # ca根证书配置
    [ ca ]
    subjectKeyIdentifier=hash
    authorityKeyIdentifier=keyid:always,issuer
    basicConstraints = critical,CA:true
    
    # HTTPS应用证书配置
    [ crt ]
    subjectKeyIdentifier = hash
    authorityKeyIdentifier=keyid:always,issuer
    basicConstraints = critical, CA:false
    keyUsage = critical, digitalSignature, cRLSign, keyEncipherment
    extendedKeyUsage = critical, serverAuth, clientAuth
    subjectAltName=@alt_names
    
    # SANs可以将一个证书给多个域名或IP使用
    # 访问的域名或IP必须包含在此,否则无效
    # 修改为你要保护的域名或者IP地址,支持通配符
    [alt_names]
    IP.1 = 47.108.53.88 # 公网IP地址
    DNS.1 = anylink.com # 访问的域名,没有域名可以删掉
    EOF
  2. 生成根私钥

    openssl genrsa -out root.key 4096
  3. 生成根证书请求文件

    C:所在国家 (Country),只能是两位字母缩写
    ST:所在省份(State)
    L:所在城市(Locality)
    O:所在组织(Organization)
    OU:所在部门(Organization Unit)
    CN:公用名,即域名(Common Name)

    openssl req -new -key root.key  -out root.csr -subj "/C=CN/ST=Sichuan/L=Chengdu/O=anylink/OU=anylink/CN=anylink.com"
  4. 生成根证书

    -req: 证书请求
    -extfile:扩展文件配置和-extensions参数使用
    -extensions:扩展配置
    -in:证书请求文件
    -out:证书输出文件
    -signkey:签名的私钥
    -days:有效期

    openssl x509 -req -extfile openssl.cnf -extensions ca -in root.csr -out root.crt -signkey root.key -CAcreateserial -days 3650
  5. 生成vpn的私钥

    openssl genrsa -out vpn_cert.key 4096
  6. 生成vpn证书的请求文件

    openssl req -new -key vpn_cert.key -out vpn_cert.csr -subj "/C=CN/ST=Sichuan/L=Chengdu/O=anylink/OU=anylink/CN=anylink"
  7. 签发vpn证书

    openssl x509 -req -extfile openssl.cnf -extensions crt -CA root.crt -CAkey root.key -CAserial vpn_cert.srl -CAcreateserial -in vpn_cert.csr -out vpn_cert.pem -days 3650
  8. 删除多余的中间文件,删除后,应该剩下root.crt、root.key、vpn_cert.pem、vpn_cert.key这4个文件

    rm -rf  root.csr vpn_cert.csr vpn_cert.srl openssl.cnf

    image-20220102150331116

  9. 拷贝根证书到files文件夹下,供客户端下载

    cp root.crt files/

配置NAT

  1. 开启服务器ipv4转发

    echo "net.ipv4.ip_forward=1" >> /etc/sysctl.conf
  2. 立即生效

    sysctl -p

    image-20220102152058065

  3. 设置nat,请替换网卡名称为前面查看的内网网卡名称,另外,如果server.toml文件里面客户端的IP地址池不是默认的192.168.10.0/24,也请修改为对应的IP地址池

    iptables -t nat -A POSTROUTING -s 192.168.10.0/24 -o eth0 -j MASQUERADE
  4. 查看设置是否生效

    iptables -nL -t nat

    image-20220102152553868

  5. 安装iptables-services,用于保存iptables配置,永久生效

    yum install -y iptables-services
  6. 设置开机自启

    systemctl enable iptables.service
  7. 保存当前iptables设置

    service iptables save

    image-20220102153108201

启动anylink

  1. 复制service文件到系统中

    cp /usr/local/anylink-deploy/systemd/anylink.service /usr/lib/systemd/system/
  2. 启动anylink

    systemctl start anylink
    systemctl enable anylink
  3. 查看启动状态

    systemctl status anylink

    image-20220102153647504

浏览器访问后台管理

  1. 访问地址公网IP+端口(默认8800),输入账号(admin)和 密码(1q2w%3e4r)点击登陆

    http://47.108.53.88:8800

    image-20220102154059782

  2. 添加邮箱配置,这里用QQ邮箱演示,其他邮箱请自行百度,另外密码是不是QQ密码,是授权码,不清楚也请百度

    image-20220102163309846

  3. 设置邮件内容

    image-20220102160006909

  4. 添加用户组

    image-20220102154608086

  5. 再添加一个测试组,来测试一下访问权限

image-20220102154804702

  1. 添加用户zhangsan

    image-20220102160552077

  2. 添加用户lisi

    建议所有用户使用统一的PIN码+OTP的方式登陆,这里为了演示,使用了不同的PIN码,PIN码是固定的,用户无法自行更改不要设置太复杂了哈

    image-20220102161022860

  3. 查看邮件

    image-20220102165500974
    image-20220102165545641

客户端使用

你可以将各种客户端安装包和使用教程放入/usr/local/anylink-deploy/conf/files目录下,然后在邮件里面写入下载地址供用户下载,邮件里面默认的info.txt文件也是对应该文件夹下的info.txt,客户端在压缩包里面,也可以去QQ群里下载,或者自行百度下载

压缩包文件:
FreeOTP.apk 安卓OTP软件安装包,ios请自行在应用商店下载,无法提供安装包
anyconnect-win-4.10.00093.msi win10 anyconnect安装包
anyconnect-macos-4.10.00093.dmg mac anyconnect安装包
anyconnect-4.9.06048.apk 安卓 anyconnect安装包
anyconnect-linux64-4.10.04065.tar.gz linux anyconnect安装包

手机安装OTP软件

此项是非必须的,如果开通用户时,禁用了OTP(一次性密码,每隔30秒更换一次动态密码),就不需要安装

  1. 下载安装包,点击安装即可
  2. 安装好后,点击右上角二维码,扫描邮件中的二维码,扫描好后,会多出一条配置,点一下就可以看6位的动态码

win10

安装客户端

  1. 安装客户端anyconnect,双击下载的安装包,点击Next按钮

    image-20220102170120159

  2. 选择我同意,在点击Next

    image-20220102170140233

  3. 点击Install

    image-20220102170202067

  4. 点击Finish

    image-20220102170233622

信任根证书

温馨提示:不要轻易信任一个未知来源的根证书,会有安全风险

  1. 浏览器下载根证书

    如果下载后,找不到文件,可能被防火墙或者其他安全软件删除了

    https://47.108.53.88:443/files/root.crt
  2. 双击证书安装

    image-20220102173201859

  3. 选择本地计算机

    image-20220102173230616

  4. 选择受信任的根证书颁发机构

    image-20220102173515199

  5. 点击完成

    image-20220102173546203

  6. 浏览器访问验证

    如果还是提示不安全,关掉浏览器,重新访问试试

    https://47.108.53.88:443/

    image-20220102173748186

连接

  1. 双击运行anyconnect,在启动项里有快捷方式

    默认安装路径C:\Program Files (x86)\Cisco\Cisco AnyConnect Secure Mobility Client

    image-20220102170803545

  2. 输入邮件收到的连接地址,点连接

    image-20220102174444625

  3. 输入用户和密码,PIN码是在创建用户的时候设置的,邮件上也有,后面6位670160是手机OTP软件上扫描二维码后的6位动态码,手速要快哈

    image-20220102174655433

  4. 这个提示可以在管理后台邮件内容那里修改哈

    image-20220102192332103

  5. 连接成功

    image-20220102175118813

  6. ping内网试试

    image-20220102175226668

  7. 浏览器访问ECS02上的nginx服务

    image-20220102180202220

  8. 断开连接,登录过一次后,客户端会保留上次的连接配置,配置名称对应profile.xml文件中的HostName,连接地址对应HostAddress,详见安装和配置的第12步,注意目前只能保存一个配置,不知道为什么

    image-20220102180802646

  9. 使用李四的账号登录,注意OTP软件,同一个邮箱同一个anylink服务端,只能保存一个账号的动态码,这里是我是将张三的动态码删除,再扫描李四的动态码,如果你实在需要一个anylink服务端使用同一个邮箱,你可以在后台将两个账号的OTP密钥设置成一样的

    image-20220102181538253

  10. ping测试,符合测试组的权限,只能访问ECS01(172.24.135.36)

    image-20220102182332672

另外你可以查看一下自己电脑的IP地址,会发现正是server.toml配置文件中IP地址池中的地址,并且在服务器上,也自动创建了一张网卡,网卡IP地址跟你电脑上的一样

image-20220102182736105

image-20220102182808347

mac

没有mac,图片网上截的,可能不清晰,也没有验证

安装客户端

  1. 双击下载的安装包,然后双击如下图标

    image-20220102184322442

  2. 然后点击继续按钮

    image-20220102184348126

  3. 再点击继续按钮

    image-20220102184413610

  4. 弹框处点击同意按钮

    image-20220102184439407

  5. 安装类型只选择 VPN 即可,然后点击继续

    image-20220102184454000

  6. 然后点击安装

    image-20220102184520617

  7. 验证账号密码,点击安装软件

    image-20220102184552544

  8. 成功安装后如图

    image-20220102184623179

信任根证书

温馨提示:不要轻易信任一个未知来源的根证书,会有安全风险

  1. 浏览器下载根证书

    https://47.108.53.88:443/files/root.crt
  2. 双击钥匙串访问,选择系统选项,点击加号,找到找到证书文件

    image-20220102184739877

  3. 选中证书文件,点击打开

    image-20220102184815764

  4. 双击导入的证书文件,将信任项修改为始终信任

    image-20220102184954768

  5. 点击证书文件的小三角,然后双击专用秘钥

    image-20220102185023029

  6. 修改访问控制项为允许所有程序访问

    image-20220102185042607

连接

参考win10吧

安卓

安装客户端

  1. 下载后点击安装就行了,部分手机可能会提示不安全,让你去应用商店下载或者自行百度解决

信任根证书

温馨提示:不要轻易信任一个未知来源的根证书,会有安全风险

另外也可以在设置里面去掉阻止不信任的服务器勾选,然后连接时选择导入并保存证书

  1. 浏览器下载根证书

    https://47.108.53.88:443/files/root.crt
  2. 点击证书安装

    image-20220102185950839

  3. 设置证书名称

    image-20220102190543312

连接

  1. 打开app,点击连接

    image-20220102190652517

  2. 添加连接

    image-20220102190728694

  3. 设置连接地址

    image-20220102190823427

  4. 点击连接

    image-20220102191100426

  5. 连接成功

    image-20220102191350469

    image-20220102191456782

linux

这里以centos7.5为演示,其它linux系统类似

安装客户端

  1. 下载安装包

  2. 创建目录

    mkdir /usr/local/anyconnect
  3. 解压到目录

    tar -xzvf anyconnect-linux64-4.10.04065.tar.gz --strip-components=1 -C /usr/local/anyconnect
  4. 进入安装目录

    cd /usr/local/anyconnect/vpn
  5. 开始安装

    ./vpn_install.sh

    image-20220102193208066

信任根证书

温馨提示:不要轻易信任一个未知来源的根证书,会有安全风险

  1. 下载根证书

    wget --no-check-certificate https://47.108.53.88:443/files/root.crt

    image-20220102193509392

  2. 移动根证书到受信任的证件夹下并重命名

    不同linux系统,信任根证书的路径可能不一样请自行百度

    cp root.crt /etc/pki/ca-trust/source/anchors/anylink-ca.crt
  3. 更新信任证书列表

    update-ca-trust
    

连接

  1. 连接vpn

    /usr/local/anyconnect/vpn/vpn connect 47.108.53.88:443

    image-20220102194351051

  2. 查看连接状态

    /usr/local/anyconnect/vpn/vpn -s stats

    image-20220102194508198

  3. ping测试

    image-20220102194713400

  4. 断开连接

    /usr/local/anyconnect/vpn/vpn -s disconnect 47.108.53.88:443

    image-20220102194825764

anylink 编译安装

编译安装需要golang >= 1.16nodejs >= 14.x环境

安装golang

  1. 下载golang,本教程指定下载1.17.5,更多版本请访问https://studygolang.com/dl

    wget https://dl.google.com/go/go1.17.5.linux-amd64.tar.gz
  2. 解压到目录

    tar -xzvf go1.17.5.linux-amd64.tar.gz -C /usr/local
  3. 打开环境变量文件

    vi /etc/profile
  4. 在末尾添加如下变量

    export GO_HOME=/usr/local/go
    export PATH=$PATH:${GO_HOME}/bin

    image-20220102202058063

  5. 立即生效

    source /etc/profile
  6. 查看版本

    go version

    image-20220102200529189

安装nodejs

  1. 下载nodejs,本教程指定下载16.13.1,更多版本请访问https://nodejs.org/zh-cn/

    wget https://nodejs.org/dist/v16.13.1/node-v16.13.1-linux-x64.tar.xz
  2. 创建安装目录

    mkdir /usr/local/nodejs
  3. 解压到目录

    tar -xvf node-v16.13.1-linux-x64.tar.xz --strip-components=1 -C /usr/local/nodejs/
  4. 打开环境变量文件

    vi /etc/profile
  5. 末尾修改为如下

    export GO_HOME=/usr/local/go
    export NODEJS_HOME=/usr/local/nodejs
    export PATH=$PATH:${GO_HOME}/bin:${NODEJS_HOME}/bin

    image-20220102202238445

  6. 立即生效

    source /etc/profile
  7. 查看版本

    node -v

    image-20220102202341211

编译anylnk

  1. 下载源码包https://codeload.github.com/bjdgyc/anylink/tar.gz/refs/tags/v0.7.2,本教程指定下载0.7.2,下载好了上传到服务器

  2. 解压包

    tar -xzvf anylink-0.7.2.tar.gz
  3. 进入目录

    cd anylink-0.7.2
  4. 编译

    sh build.sh
  5. 编译好后,将部署文件移动到/usr/local目录下

    mv anylink-deploy /usr/local
  6. 剩下的步骤请参考二进制包安装了

性能优化问题

感谢anylink这么棒的项目!
最近在使用中,发现链接速度大部分时间在30-40Mbps, 偶尔60Mbps,请问怎么做能提高性能呢? 测试过程中服务器是1G带宽,1核心,最高CPU占用50%。

建议变更密码登陆方式和增加查询审计日志条件

1、建议PIN码直接改为密码,如果管理员给用户开启了OTP认证,只有用户和密码登陆成功后,才能进行OTP认证,不然公司的那些小白用户,他们是搞不清楚登陆密码为【PIN码+动态码】是什么意思的
2、建议后台管理帐号也能增加OTP认证功能
3、建议审计日志有查询过虑条件, 不然日志大多,根本没办法看

Docker 一键安装体验[支持amd64/arm64/树莓派]

体验教程

集成配置文件自动生成,证书自动生成,iptables自动更新.

  • 支持 amd64/arm64/armv7`
  • 证书无效,仅为程序正常启动提供支持,如需正常使用,请自行在配置文件替换相关设置.

docker run -d --privileged=true --name anylink -p 443:443 -p 8800:8800 -v /path/you/dir:/app/conf jonnyan404/anylink

  • 账号: admin
  • 密码获取: docker logs anylink 2>&1|grep pwd

打开 http://IP:8800 访问后台

FAQ

有问题,欢迎跟帖反馈!

最新代码跑起来后台直接 404

环境
OS: centos 7.9 2009 latest
git clone 最新得 master 代码 (2021年-1月-11号 周一)

安装的 golang 版本
golang-1.15.5-1.el7.x86_64
golang-bin-1.15.5-1.el7.x86_64
golang-src-1.15.5-1.el7.noarch

按 README一路编译正常 , 运行后,前台 https://sslvpn.xxx.org 访问正常 ( 输出 hello world ),
访问 http://sslvpn.xxx.org:8800/ui/ 后台页面 ,直接报 404

日志无任何新增输出信息 ,log_level info 调为 debug 测试依旧无新增输出信息

server.toml 配置文件


#其他配置文件,可以使用绝对路径
#或者相对于server.toml的路径

#数据文件
db_file = "./data.db"
#证书文件
cert_file = "./sslvpn.pem"
cert_key = "./sslvpn.key"
ui_path = "../ui"
down_files_path = "../down_files"

log_level = "debug"

#系统名称
issuer = "xxx sslvpn"
#后台管理用户
admin_user = "root"
#pass 123456
admin_pass = "$2a$10$/ZKjHF1Gtx40/S9DP29WkO/VmHq2Q0usRcsHUqey7T1cjD040vre2"
jwt_secret = "0c0Jy9fY47upxjwoea33DxvRN4TGdqD0YxjCcd9MwXuAjJVwc3280tBAuK4yw-ezqFqV"


#vpn服务对外地址
link_addr = "sslvpn.xxx.org"

#前台服务监听地址
server_addr = ":443"
#后台服务监听地址
admin_addr = ":8800"
#开启tcp proxy protocol协议
proxy_protocol = false

link_mode = "tun"

#客户端分配的ip地址池
ipv4_network = "5.5.5.0"
ipv4_netmask = "255.255.255.0"
ipv4_gateway = "5.5.5.1"
ipv4_pool = ["5.5.5.10", "5.5.5.20"]

#最大客户端数量
max_client = 100
#单个用户同时在线数量
max_user_client = 3
#IP租期(秒)
ip_lease = 1209600

#默认选择的组
default_group = "one"

#客户端失效检测时间(秒) dpd > keepalive
cstp_keepalive = 20
cstp_dpd = 30
mobile_keepalive = 50
mobile_dpd = 60
#session过期时间,用于断线重连,0永不过期
session_timeout = 3600
auth_timeout = 0```
 

0.4.1 测试 docker 部署路径有点乱,附上建议.

build 了 0.4.1 docker 镜像测试后,发现默认启动后 data.db 和 证书文件默认 转移到 /app 目录下.

即使挂载 server.toml 到 /app/conf/ 下,同时 server.toml 中的相关路径也都是默认 ./data.db ./xxx.pem .但是相关文件实际上还是必须在 /app 下才能生效.

不太清楚这是bug还是因为改版需要把 data.db和证书提到 /app 目录...如果是这样,那么 server.toml 也应该放在 /app 才对.

但是建议还是和早前 0.3.3 版本那样规划比较科学,方便挂载整个/app/conf目录持久化存储 配置文件,数据库和证书文件.

毕竟app目录下有程序和脚本文件,不方便挂载目录,而单独挂载配置文件,数据库和证书文件,又太多了..比较繁琐

anylink使用建议

在安装体验了anylink软件后,提出以下建议:
1、 安装简单化,参考宝塔安装方法 安装脚本要做好一键安装部署自动加启动项,自动启动软件。
2、 配置简单化,安装完成后就可以通过WEB登录,对anylink系统的设置,建议增加配置向导,包括证书的生成,或者证书的导入,用户的管理 包括 用户设置 添加修改删除 启用 禁用 IP绑定
3、 系统的监控,
4、 审计日志

smtp 发送邮件 timeout

环境
最新master代码编译

创建用户时,勾选发送邮件按钮,点击保存,无响应,过几秒服务端日志就提示超时了
smtp 相关设置的域名,在同机器上进行 ping / telnet 25 port ,dns 解析等操作都是正常的, 确认anylink 到 smtp server 链路是通的

后台里的邮件设置(为了截图临时改值,由 xxx.cn 代替)
企业微信截图_16104327488362

服务端日志报错

2021/01/12 14:21:46 main.go:26: [Info] Server pid:  3470
2021/01/12 14:21:46 server.go:47: [Info] listen server :443
2021/01/12 14:21:46 server.go:58: [Info] Listen admin :8800

2021/01/12 14:22:30 common.go:96: [Error] Mail Error: SMTP Connection timed out
2021/01/12 14:22:34 common.go:96: [Error] Mail Error: SMTP Connection timed out

cisco anyconnect 连接报错

环境:
桌面 OS : Windows 10
vpn客户端 cisco anyconnect 版本 v4.9.04043

作为对比,同样是这个客户端,连另一台 VPN 服务端  OpenConnect server (ocserv 1.1.1)登录正常 

客户端报错
cisco anyconnect 输入 pin + OTP 动态码后 ,Banner信息弹出正常 ,但下一步就报错了

企业微信截图_16104172326780

服务端日志输出

2021/01/12 10:04:48 main.go:26: [Info] Server pid:  2027
2021/01/12 10:04:48 server.go:47: [Info] listen server :443
2021/01/12 10:04:48 server.go:58: [Info] Listen admin :8800
2021/01/12 10:05:30 link_tunnel.go:69: [Debug] 192.168.214.10 02:00:ac:1a:05:0e demo
2021/01/12 10:05:30 link_cstp.go:54: [Debug] DISCONNECT 192.168.214.10
2021/01/12 10:05:30 closeOnce: 192.168.214.10

生态长远建议

非常喜欢这个项目,也是sslvpn国内为数不多的精品,但是粗略看了下,目前有2个点可以重点考虑下
1,引用的github.com/songgao/water已经3年没有更新了,这个也是项目的核心
2,客户端用的是Cisco的客户端,是否可以使用开源的客户端或者实现通用通信协议标准的客户端,这样可以独立更新

预祝,后续生态繁荣壮大

建议增加证书登录支持

可视化的管理界面比ocserv好用,但是Anyconnect客户端不能保存密码,每次登录要输入6位数以上的密码也挺麻烦的,希望能够支持证书免密登录。

anylink 长期发展建议

anylink 作为一款亲民的SSL VPN软件,能与公司的LDAP 统一管理是不错的选择,建议开发SSL VPN+radius+ldap 满足账号授权问题。同时呢,也建议anylink 越来越精简。通过一系列的优化技术(如流压缩、流缓存、TCP协议代理等)提升用户的系统访问速度,增加用户体验。行为记录、展示及回溯:详细记录接入用户的访问行为,确保用户的访问过程可追溯加密算法有效性:根据不同业务的安全级别,提供AES、3DES、RSA、RC4、MD5及国密SM1、SM2、SM3、SM4等加密算法进行选择,保障数据的安全性

CentOS7 openconnect无法连接anylink

anylink使用的是v0.6.2

openconnect版本

[root@ecs-zPBqW ~]# openconnect --version
OpenConnect 版本 v8.10
Using GnuTLS 3.3.29. Features present: TPM, PKCS#11, RSA software token, HOTP software token, TOTP software token, Yubikey OATH, DTLS, ESP
支持的协议: anyconnect(默认), nc, gp, pulse

openconnect日志

[root@ecs-zPBqW ~]# echo "password" | openconnect -u username --passwd-on-stdin xxxx.com
POST https://xxxx.com/
已连接到 xxx.xxx.xxx.xxx:xxxx

SSL 与 xxxx.com 协商
Connected to HTTPS on xxxx.com with ciphersuite (TLS1.2)-(ECDHE-RSA-SECP256R1)-(AES-128-GCM)
XML POST 已启用
请输入你的用户名和密码
GROUP: [xxxx]:xxxx
POST https://xxxx.com/
XML POST 已启用
请输入你的用户名和密码
POST https://xxxx.com/
得到了 CONNECT 响应:HTTP/1.1 200 OK
未接收到 MTU。正在中止
创建 SSL 连接失败

账号安全功能

建议增加一个账号安全的功能,主要为自动检测多久未登录的账号自动禁用,功能如下:

  • 系统可以检测账号多久未登录
  • 可设定最大未登录时限,如30天,超过30天未登录过账号的自动禁用账号
  • 在账号即将到期前3天,自动发邮件提醒账号所有者登录账号激活账号,逾期未登录的自动禁用账号
  • 对超过一定期限(如180天)未使用的账号进行自动删除操作

docker启动不会自动修改转发

官方原配置文件为:
#客户端分配的ip地址池
ipv4_master = "eth0"
ipv4_cidr = "192.168.10.0/24"
当改为:
#客户端分配的ip地址池
ipv4_master = "eth0"
ipv4_cidr = "192.168.100.0/24"
的时候,启动docker,
默认的转发还是
MASQUERADE all -- 192.168.10.0/24 0.0.0.0/0
希望后续能修正为自动根据这个网段自动修改转发

给作者项目建议。利于发展。一定要看。

1、安装简化。最好做成一键脚本安装,带SSL自动申请证书
2、加入ikev2 支持。这样windows , mac , iphone 都有默认软件支持。
3、加入LDAP功能。很多公司都是用LDAP 绑定GITLAB, DOC, FILE 这样的功能的。不然要二套系统

建议 增加支持flannel 网络管理

由于 客户端连接的IP 经过 NAT 转换后 到达后端服务器上 显示都是VPN server的 IP ,无法进行 追踪和溯源
建议增加flannel 网络管理支持 ,
在 vpn server上启动了 flannel 服务,会有个flannel tun网卡

然后启动 vpn server 使其tun 网卡的网段和flannel的tun网段 一致,类似docker 使用flannel网卡 那样
这样客户端分配的IP 地址都是flannel 网络的子网IP, 如下图中所示
image

增加二次验证码输入方式

目前是 登陆密码为 【PIN码+动态码】
希望能增加先输入PIN码,认证ok再密码二次认证,再加上ldap接入,我就可以在公司推广使用了。

几个问题

  1. 有没有可能支持 lets encrypt 证书自动申请
  2. radius 用户无法支持 OTP
  3. OTP 二维码可以通过 VPN 443 接口获取,很危险
  4. 二维码是否可以通过 base64 图片直接发送邮件

请教下各位大佬关于anylink的几个问题,感谢答复!

1、前端界面每日在线统计和每日流量统计为什么显示的都是2019年,我看了我的机器时间是正确的;
2、审计日志里面没有数据;
3、用户组的radius认证服务器只能添加一个,能否实现可以添加两个radius服务器;

build.sh遇错

hi.

root@p1601860745:~/anylink# ./build.sh
++ pwd

  • cpath=/root/anylink
  • echo 编译二进制文件
    编译二进制文件
  • cd /root/anylink/server
    ++ git rev-parse HEAD
  • go build -v -o anylink -ldflags '-X main.COMMIT_ID=cd8922237f6c9770faee52dd9e16d1757f9d0eb1'
    go: downloading github.com/google/gopacket v1.1.19
    go: downloading github.com/gorilla/mux v1.8.0
    go: downloading github.com/pion/logging v0.2.2
    go: downloading github.com/songgao/packets v0.0.0-20160404182456-549a10cd4091
    go: downloading github.com/songgao/water v0.0.0-20200317203138-2b4b6d7c09d8
    go: downloading github.com/fsnotify/fsnotify v1.4.7
    go: downloading github.com/shirou/gopsutil v3.21.4+incompatible
    go: downloading github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e
    go: downloading github.com/xhit/go-simple-mail/v2 v2.9.0
    go: downloading github.com/asdine/storm/v3 v3.2.1
    go: downloading github.com/xlzd/gotp v0.0.0-20181030022105-c8557ba2c119
    go: downloading golang.org/x/net v0.0.0-20210520170846-37e1c6afe023
    go: downloading github.com/pion/transport v0.12.3
    go: downloading github.com/pion/udp v0.1.1
    go: downloading github.com/tklauser/go-sysconf v0.3.6
    go: downloading github.com/tklauser/numcpus v0.2.2
    golang.org/x/crypto/blowfish
    golang.org/x/crypto/bcrypt
    github.com/bjdgyc/anylink/pkg/utils
    github.com/spf13/pflag
    github.com/spf13/cobra
    golang.org/x/sys/internal/unsafeheader
    golang.org/x/sys/unix
    github.com/fsnotify/fsnotify
    github.com/hashicorp/hcl/hcl/strconv
    github.com/hashicorp/hcl/hcl/token
    github.com/hashicorp/hcl/hcl/ast
    github.com/hashicorp/hcl/hcl/scanner
    github.com/hashicorp/hcl/hcl/parser
    github.com/hashicorp/hcl/json/token
    github.com/hashicorp/hcl/json/scanner
    github.com/hashicorp/hcl/json/parser
    github.com/hashicorp/hcl
    github.com/hashicorp/hcl/hcl/printer
    github.com/magiconair/properties
    github.com/mitchellh/mapstructure
    github.com/pelletier/go-toml
    github.com/spf13/afero/mem
    golang.org/x/text/transform
    golang.org/x/text/unicode/norm
    github.com/spf13/afero
    github.com/spf13/cast
    github.com/spf13/jwalterweatherman
    github.com/subosito/gotenv
    gopkg.in/ini.v1
    gopkg.in/yaml.v2
    github.com/spf13/viper
    github.com/bjdgyc/anylink/base
    github.com/asdine/storm/v3/codec
    github.com/asdine/storm/v3/codec/json
    go.etcd.io/bbolt
    github.com/asdine/storm/v3/internal
    github.com/asdine/storm/v3/index
    github.com/asdine/storm/v3/q
    github.com/asdine/storm/v3
    github.com/xlzd/gotp
    github.com/bjdgyc/anylink/dbdata
    golang.org/x/time/rate
    github.com/bjdgyc/anylink/sessdata
    github.com/dgrijalva/jwt-go
    github.com/gorilla/mux
    github.com/shirou/gopsutil/internal/common
    github.com/tklauser/numcpus
    github.com/tklauser/go-sysconf
    github.com/shirou/gopsutil/cpu
    github.com/shirou/gopsutil/disk
    github.com/shirou/gopsutil/host
    github.com/shirou/gopsutil/load
    github.com/shirou/gopsutil/mem
    github.com/skip2/go-qrcode/bitset
    github.com/skip2/go-qrcode/reedsolomon
    github.com/skip2/go-qrcode
    github.com/xhit/go-simple-mail/v2
    github.com/bjdgyc/anylink/admin
    github.com/google/gopacket
    github.com/google/gopacket/layers
    golang.org/x/net/internal/iana
    golang.org/x/net/internal/socket
    golang.org/x/net/bpf
    golang.org/x/net/ipv4
    golang.org/x/net/ipv6
    golang.org/x/net/icmp
    github.com/bjdgyc/anylink/pkg/arpdis
    github.com/bjdgyc/anylink/pkg/proxyproto
    github.com/pion/dtls/v2/internal/util
    github.com/pion/dtls/v2/pkg/crypto/ccm
    golang.org/x/crypto/curve25519/internal/field
    golang.org/x/crypto/curve25519
    github.com/pion/dtls/v2/pkg/crypto/elliptic
    github.com/pion/dtls/v2/pkg/protocol
    github.com/pion/dtls/v2/pkg/crypto/prf
    github.com/pion/dtls/v2/pkg/protocol/alert
    github.com/pion/dtls/v2/pkg/crypto/clientcertificate
    github.com/pion/dtls/v2/pkg/crypto/hash
    github.com/pion/dtls/v2/pkg/crypto/signature
    golang.org/x/xerrors/internal
    golang.org/x/xerrors
    github.com/pion/dtls/v2/pkg/crypto/signaturehash
    golang.org/x/crypto/cryptobyte/asn1
    golang.org/x/crypto/cryptobyte
    github.com/pion/dtls/v2/pkg/protocol/extension
    github.com/pion/dtls/v2/pkg/protocol/handshake
    github.com/pion/dtls/v2/pkg/protocol/recordlayer
    github.com/pion/dtls/v2/pkg/crypto/ciphersuite
    github.com/pion/dtls/v2/internal/ciphersuite
    github.com/pion/dtls/v2/internal/closer
    github.com/pion/logging
    github.com/pion/transport/connctx
    github.com/pion/transport/deadline
    github.com/pion/transport/replaydetector
    github.com/pion/transport/packetio
    github.com/pion/udp
    github.com/pion/dtls/v2
    github.com/pion/dtls/v2/pkg/crypto/selfsign
    github.com/songgao/packets/ethernet
    github.com/songgao/water
    github.com/songgao/water/waterutil
    github.com/bjdgyc/anylink/handler
    github.com/bjdgyc/anylink
  • RETVAL 0
  • rt=0
  • '[' 0 '!=' 0 ']'
  • echo 编译前端项目
    编译前端项目
  • cd /root/anylink/web
  • npm install --registry=https://registry.npm.taobao.org
    [ .........] | reify:fsevents: timing reifyNode:node_modules/watchpack-
    npm WARN registry Unexpected warning for https://registry.npm.taobao.org/: Miscellaneous Warning ERR_SOCKET_TIMEOUT: request to https://cdn.npm.taobao.org/ms/-/ms-2.0.0.tgz failed, reason: Socket timeout
    npm WARN registry Using stale data from https://registry.npm.taobao.org/ due to a request error during revalidation.
    npm notice
    npm notice New minor version of npm available! 7.15.1 -> 7.18.1
    npm notice Changelog: https://github.com/npm/cli/releases/tag/v7.18.1
    npm notice Run npm install -g [email protected] to update!
    npm notice
    npm ERR! code ERR_SOCKET_TIMEOUT
    npm ERR! errno ERR_SOCKET_TIMEOUT
    npm ERR! request to https://cdn.npm.taobao.org/ws/-/ws-6.2.1.tgz failed, reason: Socket timeout

npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2021-06-18T09_52_53_279Z-debug.log

[email protected] build
vue-cli-service build

sh: vue-cli-service: command not found

  • RETVAL 127
  • rt=127
  • '[' 127 '!=' 0 ']'
  • echo 127
    127
  • exit 1
    root@p1601860745:~/anylink#

怎么解决?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.