aiastia / note

笔记
17 stars 5 forks source link

魔改后端Anyconnect #29

Open aiastia opened 5 years ago

aiastia commented 5 years ago

根据这个教程衍生和记录而来。

Centos 6 x64 下进行。

1、依赖 yum install pam-devel readline-devel http-parser-devel unbound gmp-devel yum install tar gzip xz wget gcc make autoconf 2、安装 nettle cd wget https://ftp.gnu.org/gnu/nettle/nettle-3.1.tar.gz tar zxvf nettle-3.1.tar.gz cd nettle-3.1/ ./configure --prefix=/usr/local/nettle make && make install echo '/usr/local/nettle/lib64/' > /etc/ld.so.conf.d/nettle.conf ldconfig 3、安装 gnutls cd export NETTLE_CFLAGS="-I/usr/local/nettle/include/" export NETTLE_LIBS="-L/usr/local/nettle/lib64/ -lnettle" export HOGWEED_LIBS="-L/usr/local/nettle/lib64/ -lhogweed" export HOGWEED_CFLAGS="-I/usr/local/nettle/include" wget ftp://ftp.gnutls.org/gcrypt/gnutls/v3.4/gnutls-3.4.7.tar.xz tar xvf gnutls-3.4.7.tar.xz cd gnutls-3.4.7 ./configure --prefix=/usr/local/gnutls --with-included-libtasn1 --without-p11-kit make && make install ln -s /usr/local/gnutls/bin/certtool /usr/bin/certtool echo '/usr/local/gnutls/lib/' > /etc/ld.so.conf.d/gnutls.conf ldconfig 4、安装 libnl cd yum install bison flex wget https://www.infradead.org/~tgr/libnl/files/libnl-3.2.25.tar.gz tar xvf libnl-3.2.25.tar.gz cd libnl-3.2.25 ./configure --prefix=/usr/local/libnl make && make install echo '/usr/local/libnl/lib/' > /etc/ld.so.conf.d/libnl.conf ldconfig 5、安装 radius 相关 export LIBNL3_LIBS="-L//usr/local/libnl/lib/ -lnl-3 -lnl-route-3" export LIBGNUTLS_LIBS="-L/usr/local/gnutls/lib/ -lgnutls" export LIBGNUTLS_CFLAGS="-I/usr/local/gnutls/include/" wget https://github.com/radcli/radcli/releases/download/1.2.5/radcli-1.2.5.tar.gz tar xvzf radcli-1.2.5.tar.gz cd radcli-1.2.5 ./configure --prefix=/usr/local/radcli echo '/usr/local/radcli/lib/' > /etc/ld.so.conf.d/radcli.conf make && make install ldconfig yum install freeradius-client -y 6、安装正宫–ocserv export RADCLI_LIBS="-L/usr/local/radcli/lib/ -lradcli" export RADCLI_CFLAGS="-I/usr/local/radcli/include/" wget ftp://ftp.infradead.org/pub/ocserv/ocserv-0.10.9.tar.xz tar xvf ocserv-0.10.9.tar.xz cd ocserv-0.10.9 编辑 src/vpn.h

        #define DEFAULT_CONFIG_ENTRIES 96 
        改成 200

        ./configure --prefix=/usr/local/ocserv
        make && make install
        echo 'export PATH=$PATH://usr/local/ocserv/sbin/:/usr/local/ocserv/bin/' >> $HOME/.bashrc 
        source $HOME/.bashrc 

7、证书相关 这里因为我有个泛域名证书,所以就不生成了= =直接用。

mkdir /etc/ocserv/

编辑 /etc/ocserv/server-cert.pem ,把证书文件贴进去,记住只贴一个,就是颁发给你的证书= =你贴证书链后面会报错= =貌似是 CA 证书不科学的原因。

然后 chmod 600 /etc/ocserv/server-cert.pem 还有 server-key.pem ,也是一样的,密钥粘进去,权限设置好。

8、freeradius-client 的设置 我这里只做了登陆的验证。

编辑 /etc/radiusclient/radiusclient.conf

yourserveraddress 指代 radius 服务器地址。 authserver yourserveraddress:1812

        acctserver      yourserveraddress:1813

        dictionary      /etc/radiusclient/dictionary

        同时记住 radius 服务器要添加好权限。

然后是编辑 /etc/radiusclient/servers ,

添加

yourserveraddress 指代 radius 服务器地址。yourserversecret 指代 radius 服务器密钥。

        youserveraddress                   yourserversecret

        9、配置文件

配置文件的话,我们回到刚才编译 ocserv 的目录。

        cd /root/ocserv-0.10.9
        cp ./tests/docker-ocserv/ocserv-radius.conf /etc/ocserv/ocserv.conf

        然后编辑 /etc/ocserv/ocserv.conf

主要修改以下几个 try-mtu-discovery = true cisco-client-compat = true server-cert = /etc/ocserv/server-cert.pem server-key = /etc/ocserv/server-key.pem max-clients = 50 max-same-clients = 10 tcp-port = 5444 udp-port = 5444 dns = 8.8.8.8 dns = 8.8.4.4 ipv4-network = 192.168.10.0 occtl-socket-file = /var/run/occtl.socket

ca-cert=。。。。 对没错注释掉

还有特别注意路由表,先把 no-route 和 route 都给注释了,然后添加以下配置。

        route = 103.0.0.0/255.0.0.0
        route = 106.0.0.0/255.0.0.0
        route = 107.0.0.0/255.0.0.0
        route = 108.0.0.0/255.0.0.0
        route = 141.0.0.0/255.0.0.0
        route = 153.0.0.0/255.0.0.0
        route = 160.0.0.0/255.0.0.0
        route = 166.0.0.0/255.0.0.0
        route = 17.0.0.0/255.0.0.0
        route = 173.0.0.0/255.0.0.0
        route = 176.0.0.0/255.0.0.0
        route = 178.0.0.0/255.0.0.0
        route = 184.0.0.0/255.0.0.0
        route = 194.0.0.0/255.0.0.0
        route = 198.0.0.0/255.0.0.0
        route = 199.0.0.0/255.0.0.0
        route = 203.0.0.0/255.0.0.0
        route = 204.0.0.0/255.0.0.0
        route = 205.0.0.0/255.0.0.0
        route = 208.0.0.0/255.0.0.0
        route = 209.0.0.0/255.0.0.0
        route = 210.0.0.0/255.0.0.0
        route = 216.0.0.0/255.0.0.0
        route = 3.0.0.0/255.0.0.0
        route = 4.0.0.0/255.0.0.0
        route = 31.0.0.0/255.0.0.0
        route = 46.0.0.0/255.0.0.0
        route = 50.0.0.0/255.0.0.0
        route = 54.0.0.0/255.0.0.0
        route = 61.0.0.0/255.0.0.0
        route = 64.0.0.0/255.0.0.0
        route = 67.0.0.0/255.0.0.0
        route = 68.0.0.0/255.0.0.0
        route = 69.0.0.0/255.0.0.0
        route = 70.0.0.0/255.0.0.0
        route = 72.0.0.0/255.0.0.0
        route = 74.0.0.0/255.0.0.0
        route = 75.0.0.0/255.0.0.0
        route = 76.0.0.0/255.0.0.0
        route = 77.0.0.0/255.0.0.0
        route = 79.0.0.0/255.0.0.0
        route = 8.0.0.0/255.0.0.0
        route = 23.0.0.0/255.0.0.0
        route = 93.0.0.0/255.0.0.0
        route = 96.0.0.0/255.0.0.0
        route = 100.0.0.0/248.0.0.0
        route = 109.0.0.0/255.0.0.0
        route = 128.0.0.0/255.0.0.0
        route = 174.0.0.0/255.0.0.0
        route = 190.0.0.0/255.0.0.0
        route = 192.0.0.0/255.0.0.0

        OK,保存。

9、防火墙&系统配置

        echo 1 > /proc/sys/net/ipv4/ip_forward
        echo "echo 1 > /proc/sys/net/ipv4/ip_forward " >> /etc/rc.local
        iptables -t nat -A POSTROUTING  -o eth0 -j MASQUERADE
        service iptables save

        10、运行 opserv
        ocserv -f -c /etc/ocserv/ocserv.conf

        可以连接了。此处不再赘述。

把这行加进 /etc/rc.local 就可以开机自启动了。

aiastia commented 5 years ago

PPTP,L2TP,OpenVPN之VPN三合一安装包 2011年8月5日 | 分类: Linux, VPN | 标签: centos, Freeradius, l2tp, Linux, lnmp, mysql, OpenVPN, pptp, sh, shell, VPN, vpn三合一安装包, 三合一安装包, 快速安装系列

注意本地址在墙外,安装中断可以用screen -r vpn恢复,生产环境谨慎使用

yum -y install screen screen -S vpn wget -c http://nchc.dl.sourceforge.net/project/vpn3in1/vpn3in1.tar.gz tar zxvf vpn3in1.tar.gz ./vpn3in1.sh 2>&1 | tee vpn3in1.log

2014.1.20修复openvpn生成证书错误; 2012.8.25更新:本地完整安装包; 2012.3.19更新:添加对自定义下载安装包地址的支持; 2011.8.5更新:添加对centos 6.0支持; 2011.7.2更新:添加验证已安装mysql的root用户密码是否正确;添加Daloradius,RadiusManager,apache。详细安装可以看图示; 2011.5.8更新:添加可选使用本机freeradius服务或者使用远程freeradius服务器,如果使用远程则不会在本机安装freeradius及mysql服务; 提高Mysql是否安装识别,去除Nginx,phpMyAdmin,daloradius安装,这些功能建议单独安装,还原OPENVPN端口为1194。 已知问题: 1,可选RadiusManage是修改mac地址进行破解,如果vps不支持修改mac地址将导致无法连接。 2,L2TP不能记录callingstationid,OPENVPN使用UDP端口不能记录acctstoptime 根据palfans修改而成,http://www.palfans.net/3-in-1-vpn-package/

开启mysql远程帐号脚本 mysql -u root -proot; grant all on . to username@'%' identified by 'password'; flush privileges; 其中 all 指定相关的操作, .说明数据库和表名, username表示用户名,‘%’这里写Host名称,允许所有就用‘%’,‘password’是密码。这里改成相应的值后进行操作就可以开启远程帐号访问

修改VPN服务器radius认证为远程服务器 修改参数在VPN服务器运行下面脚本

radius_server="radius服务器IP" secret_key="yishanhome.com" etc_dir="/usr/local/etc" sed -i -e "s/name=127.0.0.1/name=$radius_server/" /etc/openvpn/radiusplugin.cnf sed -i -e "s/sharedsecret=testpw/sharedsecret=$secret_key/" /etc/openvpn/radiusplugin.cnf sed -i -e "s/localhost:1812/$radius_server:1812/" $etc_dir/radiusclient/radiusclient.conf sed -i -e "s/localhost:1813/$radius_server:1813/" $etc_dir/radiusclient/radiusclient.conf mv -f $etc_dir/radiusclient/servers $etc_dir/radiusclient/servers.bak cat >> $etc_dir/radiusclient/servers <<EOF $radius_server $secret_key EOF 修改参数在radius服务器运行下面脚本

client_ip="VPN服务器IP" secret_key="yishanhome.com" etc_dir="/usr/local/etc" iptables -A INPUT -i eth0 -p udp -s $client_ip --dport 1812 -j ACCEPT iptables -A INPUT -i eth0 -p udp -s $client_ip --dport 1813 -j ACCEPT cat >> $etc_dir/raddb/clients.conf <<EOF client localhost { ipaddr = $client_ip secret = $secret_key require_message_authenticator = no nastype = other } EOF

aiastia commented 5 years ago

如果您认为这个项目帮到了你,欢迎点击这里给我一些鼓励,谢谢您。

图片可以点击看大图。

首先是这个,目前支持九种。

0=SS
1=VPN
2=SSH
3=PAC
4=APN 描述文件外链
5=Anyconnect
6=APN
7=PAC PLUS
8=PAC PLUS PLUS

一个个来讲。

注意:

1、在添加节点的时候,请遵守 "节点名 - 方式"的命名规则,以便于自动归类,特别注意 “ - ”,即 一个空格 一个横杠 一个空格。

2、radius secret 密钥的话 ,你先在 sspanel 魔改版的配置文件里配置好,再在子节点配置的时候进行设置。自己定义,但一定要对应。

3、PAC 类应用需要在主服务器运行一个 PAC 生成器 https://github.com/Leask/Flora_Pac

监听在 127.0.0.1:8974

运行命令如下

cd ~/Flora_Pac
screen -dmS pac ./flora_pac -x "TIHUAN" -p 8974

0.SS

首先在面板里进行如下的节点添加。

QQ截图20160419165626 QQ截图20160419165649

然后,推荐部署 https://github.com/glzjin/ssshell-jar/wiki/

这个后端,此处不再赘述。记住 nodeid 要和

QQ截图20160419170315

 

对应。

 

1.VPN

首先请确保你正确地按照 https://www.zhaoj.in/read-3289.html

这里的说明安装了 Radius ,并正确地在 ss-panel  里设置了数据库信息,并且正确地设置了计划任务.

然后是在面板里添加一个 VPN 节点,请注意,添加这个节点的同时也会向 Radius 数据库里 nas 表添加一个节点,如果你不使用VPN ,但遇到要使用 Radius 验证的方式的时候,也请添加一个 类型 1 ,即 VPN 节点,这样才能保证能向 Radius 数据库里 添加 NAS 信息。

QQ截图20160419173200 QQ截图20160419173227

同时,要统计流量的话,请确保计划任务在正常运行,并且节点列表中有这两个东西

QQ截图20160419172923

至于子节点的安装,用 http://www.yishanhome.com/archives/307 的一键包即可,在填写 Radius 服务器信息的时候请填主节点的信息,并确保主节点 Radius 服务在正常运行。

 

2.SSH

同  VPN ,也是 Radius 验证,首先要添加一个类型 1 VPN 节点,以便使用 Radius 验证,然后在面板里添加节点也和 VPN 差不多,就是类型要填 2。

子节点的搭建,请参考这篇东西 https://www.zhaoj.in/read-2547.html

不过有点过时了= =在 ss-panel v3 可能会有错误= =自己拿源码改改吧。。。主要是现在我也不用这个方式了。

 

3.PAC 文件

通过连接 squid 监听 的 25 端口来进行连接。

同  VPN ,也是 Radius 验证,首先要添加一个类型 1 VPN 节点,以便使用 Radius 验证,然后在面板里添加节点也和 VPN 差不多,就是类型要填 3,同时地址要这样填 域名:端口。别看下面两张图,已经过期了。

QQ截图20160419174409 QQ截图20160419174421

子节点的搭建的话

以 Centos 6 x64 为例

首先安装 squid

yum install squid -y

然后编辑一下 /etc/squid/squid.conf

编辑成如下

#  TAG: auth_param
#Authentication Radius:
auth_param basic program /usr/lib64/squid/squid_radius_auth -f /etc/squid/squid_rad_auth.conf
auth_param basic children 10
auth_param basic realm Zhaojin97.cn
auth_param basic credentialsttl 24 hours
auth_param basic casesensitive off
acl radius-auth proxy_auth REQUIRED

#  TAG: http_access
# Allow authorized users:
http_access allow radius-auth

#
# Recommended minimum configuration:
#
acl manager proto cache_object
acl localhost src 127.0.0.1/32 ::1
acl to_localhost dst 127.0.0.0/8 0.0.0.0/32 ::1

# Example rule allowing access from your local networks.
# Adapt to list your (internal) IP networks from where browsing
# should be allowed
acl localnet src 10.0.0.0/8     # RFC1918 possible internal network
acl localnet src 172.16.0.0/12  # RFC1918 possible internal network
acl localnet src 192.168.0.0/16 # RFC1918 possible internal network
acl localnet src fc00::/7       # RFC 4193 local private network range
acl localnet src fe80::/10      # RFC 4291 link-local (directly plugged) machines

#acl SSL_ports port 443
acl Safe_ports port 80          # http
acl Safe_ports port 21          # ftp
acl Safe_ports port 443         # https
acl Safe_ports port 70          # gopher
acl Safe_ports port 210         # wais
acl Safe_ports port 1025-65535  # unregistered ports
acl Safe_ports port 280         # http-mgmt
acl Safe_ports port 488         # gss-http
acl Safe_ports port 591         # filemaker
acl Safe_ports port 777         # multiling http
acl CONNECT method CONNECT

#
# Recommended minimum Access Permission configuration:
#
# Only allow cachemgr access from localhost
http_access allow manager localhost
http_access deny manager

# Deny requests to certain unsafe ports
http_access deny !Safe_ports

# Deny CONNECT to other than secure SSL ports
#http_access deny CONNECT !SSL_ports

# We strongly recommend the following be uncommented to protect innocent
# web applications running on the proxy server who think the only
# one who can access services on "localhost" is a local user
#http_access deny to_localhost

#
# INSERT YOUR OWN RULE(S) HERE TO ALLOW ACCESS FROM YOUR CLIENTS
#

# Example rule allowing access from your local networks.
# Adapt localnet in the ACL section to list your (internal) IP networks
# from where browsing should be allowed
http_access allow localnet
http_access allow localhost

# And finally deny all other access to this proxy
http_access deny all

# Squid normally listens to port 3128
http_port 25

# Uncomment and adjust the following to add a disk cache directory.
#cache_dir ufs /var/spool/squid 100 16 256

# Leave coredumps in the first cache dir
coredump_dir /var/spool/squid

# Add any of your own refresh_pattern entries above these.
refresh_pattern ^ftp:           1440    20%     10080
refresh_pattern ^gopher:        1440    0%      1440
refresh_pattern -i (/cgi-bin/|\?) 0     0%      0
refresh_pattern .               0       20%     4320

然后编辑  /etc/squid/squid_rad_auth.conf

server 《主服务器域名》 # Radius Server IP or Hostname
secret 《密钥》

然后启动即可

service squid start
chkconfig squid on

 

4.PAC 外链

用得不多,就是链接到外部的 PAC 文件的。

 

5.Anyconnect

同  VPN ,也是 Radius 验证,首先要添加一个类型 1 VPN 节点,以便使用 Radius 验证,然后在面板里添加节点也和 VPN 差不多,就是类型要填 3,同时地址要这样填 地址:端口。

QQ截图20160419180648

 

子节点搭建的话 参考这里 https://www.zhaoj.in/read-2904.html

统计流量的话 看 https://mengyang.wang/anyconnect-node-mb/  

6.APN 文件

给苹果手机用的,

通过连接 squid 监听 的 25 端口来进行连接。

同  VPN ,也是 Radius 验证,首先要添加一个类型 1 VPN 节点,以便使用 Radius 验证,然后在面板里添加节点也和 VPN 差不多,就是类型要填 3,同时地址要这样填 节点域名:端口。

QQ截图20160419181404

 

7.PAC Plus

这个是国内中转套件的一部分,请捐赠用户们晚些看我另外一篇东西。

 

8.PAC Plus Plus

这个是国内中转套件的一部分,请捐赠用户们晚些看我另外一篇东西。

KevinZonda commented 5 years ago

openconnect是否支持流量统计呢

aiastia commented 5 years ago

是支持的

stardock commented 4 years ago

https://mengyang.wang/anyconnect-node-mb/ 这个网站已经进不去了, 还有别的办法嘛?