发现 ocserv 自动配置脚本一枚 - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
bigtan
5.12D
V2EX    分享发现

发现 ocserv 自动配置脚本一枚

  •  
  •   bigtan 2014-10-13 23:35:07 +08:00 11667 次点击
    这是一个创建于 4066 天前的主题,其中的信息可能已经有所发展或是发生改变。
    https://www.stunnel.info/tag/ocserv

    先放链接。
    这个东西配置起来还是蛮麻烦的,有了一个自动配置脚本就舒爽多了
    32 条回复    2015-03-30 11:36:43 +08:00
    soli
        1
    soli  
       2014-10-14 09:45:52 +08:00
    赞!

    我在配置过程中,用证书认证的话,ocserv 会崩溃。
    lhbc
        2
    lhbc  
       2014-10-14 13:16:35 +08:00
    我是作者,过来冒个泡……
    sansam
        3
    sansam  
       2014-10-14 13:36:21 +08:00
    @lhbc Thanks.
    bigtan
        4
    bigtan  
    OP
       2014-10-14 14:12:32 +08:00
    @lhbc 搬瓦工测试失败
        5
    chinni  
       2014-10-14 14:46:25 +08:00
    ocserv 必须不能用ovz的vps @bigtan
    yywudi
        6
    yywudi  
       2014-10-14 18:19:35 +08:00
    @chinni 为何不能?我就在128M OVZ小鸡上跑了Debian 7 + ocserv + pam+远程radius认证,挺正常啊。
    fanzc
        7
    fanzc  
       2014-10-14 20:43:44 +08:00
    密码认证有点麻烦,有没有证书认证的配置脚本?
    lhbc
        8
    lhbc  
       2014-10-15 00:11:35 +08:00 via iPhone
    @bigtan 系统版本是CentOS 7吗?
    没有搬瓦工测试不了。
    lhbc
        9
    lhbc  
       2014-10-15 00:13:45 +08:00 via iPhone
    @fanzc 用自签CA给客户端颁发个证书就行了。
    chinni
        10
    chinni  
       2014-10-15 10:48:15 +08:00
    @yywudi 我一直以为 ocserv 需要内核级别类似于ipsec 之类的支持的....原来是不要的么...我等下在ovz上测试下...
    anyfc
        11
    anyfc  
       2014-10-15 11:05:08 +08:00
    求debian 7.0自动安装配置脚本
    chinni
        12
    chinni  
       2014-10-15 11:15:18 +08:00
    @yywudi 我在ovz上测试了 以前KVM下成功的 0.8.0 版本 使用 passwd文件 验证 拨号连接的时候一直说 401 验证错误. 但是在kvm的机器上是可以用的... 我迷茫了..
    chinni
        13
    chinni  
       2014-10-15 11:19:01 +08:00
    大家可以看看我整理的 0.8.0 的 服务端. 有 debian 和ubuntu的脚本. 可能需要有修改.
    我kvm下测试通过

    下载地址 https://www.dropbox.com/s/qeyftm9ixxgky8y/ocserv_full.zip?dl=0
    yywudi
        14
    yywudi  
       2014-10-15 11:36:27 +08:00
    @chinni 我就参考了这篇文章啊 http://ttz.im/blog/2014/02/1131 用的是0.8.4 passwd文件测试OK,然后改用pam + radius 远程认证也没问题。
    401验证错误是啥情况,ocserv的log有什么提示吗?
    chinni
        15
    chinni  
       2014-10-15 12:37:02 +08:00
    @yywudi 暂时没去管了...我现在vpn都是用ipsec的. 不用anyconnect了太慢...

    用racoon 在非ovz下 做ipsec vpn ,速度可以接受
    yywudi
        16
    yywudi  
       2014-10-15 12:44:08 +08:00
    @chinni 因为自己自用主要是看网页之类,视频需求不是很大,加上本地带宽也不是很高,所以暂时没去考虑速度的问题-_-
    kkxxxxxxx
        17
    kkxxxxxxx  
       2014-10-19 21:37:26 +08:00
    @lhbc 安卓是否要 ROOT 才能连上
    lhbc
        18
    lhbc  
       2014-10-21 09:13:57 +08:00 via iPhone
    @kkxxxxxxx 4.0+不用,2.x要。
    kkxxxxxxx
        19
    kkxxxxxxx  
       2014-10-21 09:17:51 +08:00
    @lhbc 明了,谢谢回复
    dynfeisu
        20
    dynfeisu  
       2014-11-28 16:39:26 +08:00
    @yywudi 请问能提供一个OCSERV+PAM+RADIUS的教程吗?我这几天一直在折腾无果。
    yywudi
        21
    yywudi  
       2014-11-28 17:05:18 +08:00 via Android
    /@dynfeisu 首先确认password认证ok,radius服务器ok
    然后我看你们在另一个主题回复的那个配置文件,再多加一行试试

    /etc/pam.d/ocserv

    # PAM Configuration for OpenConnect Server
    # Created by tony, 11/13/13
    # This is designed to work with RADIUS PAM Module
    auth required /lib/security/pam_radius_auth.so
    account required /lib/security/pam_radius_auth.so


    当然这个文件需要添加radius服务器信息
    /etc/pam_radius_auth.conf
    ghovik
        22
    ghovik  
       2015-03-26 00:18:20 +08:00
    @chinni 能不能分享一个racoon配置的教程?我比较小白,配置了半天连不上..非常感谢~
    chinni
        23
    chinni  
       2015-03-26 14:31:08 +08:00
    @ghovik 上面的zip包里是有脚本的. 还有配置文件. 测试通过的.
    ghovik
        24
    ghovik  
       2015-03-26 16:58:41 +08:00
    @chinni 感谢!可惜链接失效了,可否其它方式分享一下?ghovik#gmail
    ghovik
        26
    ghovik  
       2015-03-26 18:30:10 +08:00
    @chinni 感谢!
    能不能帮忙看一下log?我实在是有点捉急,搞不定:
    `
    Foreground mode.
    2015-03-26 18:19:48: INFO: @(#)ipsec-tools 0.8.0 (http://ipsec-tools.sourceforge.net)
    2015-03-26 18:19:48: INFO: @(#)This product linked OpenSSL 1.0.1f 6 Jan 2014 (http://www.openssl.org/)
    2015-03-26 18:19:48: INFO: Reading configuration from "/etc/racoon/racoon.conf"
    2015-03-26 18:19:48: INFO: Resize address pool from 0 to 100
    2015-03-26 18:19:48: INFO: [VPS IP][4500] used for NAT-T
    2015-03-26 18:19:48: INFO: [VPS IP][4500] used as isakmp port (fd=7)
    2015-03-26 18:19:48: INFO: [VPS IP][500] used for NAT-T
    2015-03-26 18:19:48: INFO: [VPS IP][500] used as isakmp port (fd=8)
    2015-03-26 18:19:58: INFO: respond new phase 1 negotiation: [VPS IP][500]<=>[家里的 IP][9950]
    2015-03-26 18:19:58: INFO: begin Aggressive mode.
    2015-03-26 18:19:58: INFO: received broken Microsoft ID: FRAGMENTATION
    2015-03-26 18:19:58: INFO: received Vendor ID: RFC 3947
    2015-03-26 18:19:58: INFO: received Vendor ID: draft-ietf-ipsec-nat-t-ike-08
    2015-03-26 18:19:58: INFO: received Vendor ID: draft-ietf-ipsec-nat-t-ike-07
    2015-03-26 18:19:58: INFO: received Vendor ID: draft-ietf-ipsec-nat-t-ike-06
    2015-03-26 18:19:58: INFO: received Vendor ID: draft-ietf-ipsec-nat-t-ike-05
    2015-03-26 18:19:58: INFO: received Vendor ID: draft-ietf-ipsec-nat-t-ike-04
    2015-03-26 18:19:58: INFO: received Vendor ID: draft-ietf-ipsec-nat-t-ike-03
    2015-03-26 18:19:58: INFO: received Vendor ID: draft-ietf-ipsec-nat-t-ike-02
    2015-03-26 18:19:58: INFO: received Vendor ID: draft-ietf-ipsec-nat-t-ike-02

    2015-03-26 18:19:58: INFO: received Vendor ID: draft-ietf-ipsra-isakmp-xauth-06.txt
    2015-03-26 18:19:58: INFO: received Vendor ID: CISCO-UNITY
    2015-03-26 18:19:58: INFO: received Vendor ID: DPD
    2015-03-26 18:19:58: [[家里的 IP]] INFO: Selected NAT-T version: RFC 3947
    2015-03-26 18:19:58: INFO: Adding remote and local NAT-D payloads.
    2015-03-26 18:19:58: [[家里的 IP]] INFO: Hashing [家里的 IP][9950] with algo #2 (NAT-T forced)
    2015-03-26 18:19:58: [[VPS IP]] INFO: Hashing [VPS IP][500] with algo #2 (NAT-T forced)
    2015-03-26 18:19:58: INFO: Adding xauth VID payload.
    2015-03-26 18:19:58: INFO: NAT-T: ports changed to: [家里的 IP][31334]<->[VPS IP][4500]
    2015-03-26 18:19:58: INFO: NAT-D payload #0 doesn't match
    2015-03-26 18:19:58: INFO: NAT-D payload #1 doesn't match
    2015-03-26 18:19:58: [[家里的 IP]] ERROR: notification INITIAL-CONTACT received in aggressive exchange.
    2015-03-26 18:19:58: INFO: NAT detected: ME PEER
    2015-03-26 18:19:58: INFO: Sending Xauth request
    2015-03-26 18:19:58: INFO: ISAKMP-SA established [VPS IP][4500]-[家里的 IP][31334] spi:2214689180cd369e:af93ce0f86f5d50e
    2015-03-26 18:19:58: INFO: Using port 0
    2015-03-26 18:19:58: INFO: login succeeded for user "vpn"

    大概过了不到半分钟,iPhone上面显示: 与VPN服务器协议失败

    然后又过了一小段时间,出现下面的信息:

    2015-03-26 18:20:53: [[家里的 IP]] INFO: DPD: remote (ISAKMP-SA spi=2214689180cd369e:af93ce0f86f5d50e) seems to be dead.
    2015-03-26 18:20:53: INFO: purging ISAKMP-SA spi=2214689180cd369e:af93ce0f86f5d50e.
    2015-03-26 18:20:53: INFO: purged ISAKMP-SA spi=2214689180cd369e:af93ce0f86f5d50e.
    2015-03-26 18:20:53: INFO: ISAKMP-SA deleted [VPS IP][4500]-[家里的 IP][31334] spi:2214689180cd369e:af93ce0f86f5d50e
    2015-03-26 18:20:53: INFO: Released port 0
    `
    贴一下我的配置.
    /etc/racoon/racoon.conf
    `
    log info;
    path pre_shared_key "/etc/racoon/psk.txt";
    path certificate "/etc/racoon/certs";
    listen {
    isakmp 服务器IP地址 [500];
    isakmp_natt 服务器IP地址 [4500];
    }

    remote anonymous {
    exchange_mode main,aggressive;
    mode_cfg on;
    proposal_check claim; #替换掉客户端的比如lifetime的配置。
    nat_traversal force;
    generate_policy unique;
    ike_frag on;
    passive off;
    dpd_delay 30;

    proposal {
    lifetime time 12 hour; ## 设置一个比较长的时间,避免OSX每小时断一次
    encryption_algorithm 3des;
    hash_algorithm sha1;
    authentication_method xauth_psk_server;
    dh_group modp1024;
    }
    }

    sainfo anonymous {
    encryption_algorithm aes, 3des, blowfish;
    authentication_algorithm hmac_sha1, hmac_md5;
    pfs_group 2;
    lifetime time 100 hour;
    compression_algorithm deflate;
    }

    mode_cfg {
    auth_source system;
    dns4 8.8.4.4,8.8.8.8;
    save_passwd on;
    banner "/etc/racoon/motd";
    network4 10.100.0.10;
    netmask4 255.255.255.0;
    pool_size 100;
    pfs_group 2;
    }
    `
    /etc/racoon/psk.txt:
    `
    group group_password
    `

    非常感谢!
    chinni
        27
    chinni  
       2015-03-26 22:00:36 +08:00
    @ghovik 这我就不知道了...我看日志表示用户vpn登陆成功的. = =
    ghovik
        28
    ghovik  
       2015-03-26 22:40:55 +08:00
    @chinni 感谢回复!
    是的,日志上面显示用户'vpn'登陆成功,可是就是手机端还一直显示正在连接.然后过一会就提示说协议失败..我设置有没有问题?

    iptables设置以及端口转发:
    /sbin/iptables -t nat -A POSTROUTING -j MASQUERADE
    /sbin/iptables -A INPUT -p udp --dport 500 -j ACCEPT
    /sbin/iptables -A INPUT -p udp --dport 4500 -j ACCEPT
    /sbin/iptables -A FORWARD -s 10.100.0.0/24 -j ACCEPT
    iptables --table nat --append POSTROUTING -o eth0 --jump MASQUERADE

    net.ipv4.ip_forward = 1
    net.ipv6.conf.all.forwarding = 1
    chinni
        29
    chinni  
       2015-03-27 22:50:30 +08:00
    @ghovik 系统设置没问题 具体问题我也不清楚.
    以上.
    ghovik
        30
    ghovik  
       2015-03-29 21:59:11 +08:00
    @chinni 感谢..抱歉又来打扰你,因为实在很想搞定.
    能不能把你的配置文件发一份给我研究一下?racoon.conf, psk.txt, 还有对应的iptables的设置?
    我的邮箱ghovik#gmail.com
    非常感谢!
    chinni
        31
    chinni  
       2015-03-30 09:32:36 +08:00   1
    @ghovik 配置文件之前发你的里面都有.
    ghovik
        32
    ghovik  
       2015-03-30 11:36:43 +08:00
    @chinni 谢谢..我就是按照那个来的..我觉得问题出在iptables规则上,我新手,不太理解,都是照copy..
    关于     帮助文档     自助推广系统     博客     API     FAQ     Solana     1071 人在线   最高记录 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 27ms UTC 17:36 PVG 01:36 LAX 09:36 JFK 12:36
    Do have faith in what you're doing.
    ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86