Board logo

標題: Installation of Openconnect Server on QNAP NAS Virtualisation Station [打印本頁]

作者: 角色    時間: 2018-8-26 22:01     標題: Installation of Openconnect Server on QNAP NAS Virtualisation Station

本帖最後由 角色 於 2018-9-13 07:13 編輯

因为之前有位member [1] 提及过逗比根据地 [2], 里面有提及过怎样一键安装Openconnect server [3,4].

由于我在香港有一台QNAP NAS TS-453 Pro (Intel-based J1900 CPU,有Virtualisation Station and Container Station),在Virtualisation Station安装Debian 8.11. 然后按照一键安装方法下载和安装Openconnect server,整个流程也非常简单。

Reference:
[1] http://www.telecom-cafe.com/foru ... =7177&pid=45276
[2] https://doub.io/
[3] https://doub.io/vpnzy-7/
[4] http://www.telecom-cafe.com/foru ... =7177&pid=45273

AnyConnect Client Manual
https://www.cisco.com/c/en/us/su ... ser-guide-list.html

Cisco AnyConnect Client Administrator Guide
https://www.cisco.com/c/en/us/su ... on-guides-list.html

从下面的link,如果用Cisco AnyConnect client是不可以把所有traffic都送到remote gateway,解决方法是用OpenConnet Client,而不是AnyConnect。
https://medium.com/@acecilia/how ... u-cant-a6a1ea1f4a58

========== 安装后遇到的问题 ==================
用Cisco Anyconnect Client连接Openconnect Server后,有些网站打不开,例如MyTV Super就能发现我用VPN,而用PPTP就没有这个问题,看起来Cisco Anyconnect没有把所有Traffic都push 到对方的Gateway。如果哪位members知道解决方法,请留言,谢谢。

终于知道答案: 就是把/etc/ocserv/ocscer.conf的所有“no-route = xxx.xxx.xxx.xxx/netmask"产走。
作者: 角色    時間: 2018-8-26 22:15

本帖最後由 角色 於 2018-8-26 22:21 編輯

怎样利用Virtualisation Station安装Debian 8.11就不说了,都是基本的东西。在安装Debian 8.11时大家要注意几点。

1、在哪里下载安装image?
https://cdimage.debian.org/cdimage/archive/

2、选用哪个image安装呢?8.11
https://cdimage.debian.org/cdimage/archive/8.11.0/

3、我选32-bit i386, 大家也可以选用64-bit amd64
https://cdimage.debian.org/cdimage/archive/8.11.0/i386/

4、然后选用iso-cd
https://cdimage.debian.org/cdimage/archive/8.11.0/i386/iso-cd/

5、再选 debian-8.11.0-i386-netinst.iso
https://cdimage.debian.org/cdima ... .0-i386-netinst.iso

通过QNAP NAS里的Download Station把上面ISO的image下载到NAS的download directory,然后进行安装。安装可以参考下面文章:

https://www.howtoforge.com/tutor ... sie-minimal-server/

其中最容易出问题就是安装GRUB boot loader (之前选整个盘后,都启动不了)。

When you're asked Install the GRUB boot loader to the master boot record?, select Yes:

The installer might ask you in which partition Grub shall be installed. This server has just one harddisk, so I choose /dev/sda here.
作者: 角色    時間: 2018-8-26 22:36

本帖最後由 角色 於 2018-8-26 22:41 編輯

安装好image后,我们要用putty port 22进入Debian系统。因为我要remote ssh login香港的Debian系统,我不用port 22,改用别的port number,remote ssh login时做port forwarding。

当上面的router port forwarding tasks做好后,我们可以用putty进入Debian系统,然后cut-and-paste下面的指令:
  1. wget -N --no-check-certificate https://softs.loan/Bash/ocserv.sh && chmod +x ocserv.sh && bash ocserv.sh
複製代碼
#


过了一段时间,你会在屏幕看到:
  1. ocserv 一键安装管理脚本 [vx.x.x]
  2. -- Toyo | doub.io/vpnzy-7 --

  3. 0. 升级脚本
  4. ————————————
  5. 1. 安装 ocserv
  6. 2. 卸载 ocserv
  7. ————————————
  8. 3. 启动 ocserv
  9. 4. 停止 ocserv
  10. 5. 重启 ocserv
  11. ————————————
  12. 6. 设置 账号配置
  13. 7. 查看 配置信息
  14. 8. 修改 配置文件
  15. 9. 查看 日志信息
  16. ————————————

  17. 当前状态: 已安装 并 已启动

  18. 请输入数字 [0-9]:
複製代碼
#

我输入“1”进行安装。

又过了一段时间,你会看到下面画面:
  1. ..
  2. [信息] 开始设置账号配置...
  3. 请输入 要添加的VPN账号 用户名
  4. (默认: admin):doubi

  5.         用户名 : doubi

  6. 请输入 要添加的VPN账号 密码
  7. (默认: doub.io):doubi233

  8.         密码 : doubi233

  9. 请输入VPN服务端的TCP端口
  10. (默认: 443):443

  11.         TCP端口 : 443

  12. 请输入VPN服务端的UDP端口
  13. (默认: 443):

  14.         TCP端口 : 443

  15. [信息] 开始设置 iptables防火墙...
  16. ...
複製代碼
#
作者: 角色    時間: 2018-8-26 23:13

本帖最後由 角色 於 2018-8-26 23:38 編輯

因为我觉得Openconnect比较重要,所以我预留port 443给(both TCP and UDP)都留给Openconnect server。

因为我用RouterOS做router,而port 443和别的port number做port forwarding有些不同,就是要说明哪个interface进入。例如我的就是从ether1。如果不指定interface,Openconnect client能注册Openconnect server,但是没有flow,不能翻墙。
  1. /ip firewall nat
  2. add action=dst-nat chain=dstnat comment="ocserv TCP" dst-port=443 in-interface=ether1 protocol=tcp \
  3. to-addresses=10.0.88.40 to-ports=443
  4. add action=dst-nat chain=dstnat comment="ocserv UDP" dst-port=443 in-interface=ether1 protocol=udp \
  5. to-addresses=10.0.88.40 to-ports=443
複製代碼

作者: 角色    時間: 2018-8-26 23:43

本帖最後由 角色 於 2018-8-26 23:45 編輯

安装完,有的时候修改ocserv.conf,然后重新启动。下面有不同的commands。
  1. /etc/init.d/ocserv start
  2. # 启动 ocserv
  3. /etc/init.d/ocserv stop
  4. # 停止 ocserv
  5. /etc/init.d/ocserv restart
  6. # 重启 ocserv
  7. /etc/init.d/ocserv status
  8. # 查看 ocserv 运行状态
  9. /etc/init.d/ocserv log
  10. # 查看 ocserv 运行日志
  11. /etc/init.d/ocserv test
  12. # 测试 ocserv 配置文件是否正确
複製代碼
#

我没有用上面的commands,而用
  1. 启动系统 service ocserv start
複製代碼

作者: 角色    時間: 2018-8-26 23:50

本帖最後由 角色 於 2018-8-27 01:23 編輯

如果要熟悉Openconnect,我们就需要认识ocserv.conf,下面有不同的samples

Sample 1:
https://gist.github.com/wongsyrone/55165ce767f7248656cc

Sample 2:
https://ocserv.gitlab.io/www/rec ... guration-basic.html

Sample 3:
http://www.mmcaijing.com/25859.html
作者: 角色    時間: 2018-8-27 08:13

用Openconnect Server + Cisco AnyConnect Client不能打开的网站:

1. http://www.rthk.hk/
2. https://www.mingpao.com/
3. 在myTV Super不能观看免费区的节目

如果您知道怎样解救,欢迎跟帖指教。
作者: 角色    時間: 2018-8-30 07:51

虽然public的Cisco AnyConnect client有很多pre-set settings,对于完全翻墙是行不通的,但是一般用是可以的,还有是非常稳定。OpenConnect Server是有OpenConnect client,但是需要自己compile才可以。

有个后背的OpenConnect Server + Cisco AnyConnect Client是不错的选择。至于Cisco AnyConnect client是否可以更改settings,是可以的,但是要subscribe Cisco AnyConnect service, 这对于我们来说,根本没有可能,所以大家都别想,除非是公司去subscribe。
作者: tomleehk    時間: 2018-8-30 10:45

本帖最後由 tomleehk 於 2018-8-30 11:04 編輯

奇怪了..

我用Cisco Anyconnect + Openconnect server 這組合在外地看 myTV 或 之後嘅myTV  super 用了多年, ー直可以成功看到

openconnect server 在 openwrt上安裝
行cert 走443port
Cisco Anyconnect client ( IOS, Android, Windows )
作者: 角色    時間: 2018-8-30 12:38

那就奇怪,我的cert不是trusted,难度不是trusted,routing就有区别?

CHing,你的cert是trusted吗?
作者: tomleehk    時間: 2018-8-30 14:05

本帖最後由 tomleehk 於 2018-8-30 14:11 編輯

亦不是trusted cert , 只喺普通self signed

安裝過程就喺之前Post 過

喺外地如果唔Connect server,mytv client當然喺會出類似外地不能觀看嘅message,一旦connect 之後就可以正常觀看
作者: 角色    時間: 2018-8-30 14:15

我在免费区看,出来的结果如下:

[attach]4157[/attach]

不知道CHing你是否能看到,而且没有上面的message?
作者: 角色    時間: 2018-8-30 14:16

本帖最後由 角色 於 2018-8-30 14:31 編輯

如果十这样可能十OpenConnect  Server的settings不一样,我用default的,可能需要更改一下才能正常看。

下面的RTHK网站,用v2ray能打开,用OpenConnect就打不开。

http://www.rthk.hk/

你的OpenConnect Server + Cisco AnyConnect Client是否能打开?
作者: tomleehk    時間: 2018-8-30 16:03

本帖最後由 tomleehk 於 2018-8-30 17:05 編輯

現在不能試,因正處於香港

但你用Anyconnect連接server之後,用browser開whatismyipaddress com, 確認可以出到香港ip?

ocserv.conf 裡面
route = ip...
route = ip...
route = ip...

可以試吓全部清除, 一句不留

我嘅config一句不留, 全部 target ip 經openconnect server 出去 target ip
作者: 角色    時間: 2018-8-30 17:04

回復 14# tomleehk

能显示香港IP。

Cisco AnyConnect Client有个routing table,如果不在list的IP就走香港的Gateway。
作者: 角色    時間: 2018-9-13 07:19

本帖最後由 角色 於 2018-9-13 16:22 編輯

如果你看不到MyTV Super,RTHK TV,那么就把所有no-routes都delete掉,就可以。
  1. auth = "plain[passwd=/etc/ocserv/ocpasswd]"
  2. # listen-host = [IP|HOSTNAME]
  3. tcp-port = 443
  4. udp-port = 443
  5. run-as-user = nobody
  6. run-as-group = daemon
  7. socket-file = /var/run/ocserv-socket
  8. server-cert = /etc/ocserv/ssl/server-cert.pem
  9. server-key = /etc/ocserv/ssl/server-key.pem
  10. ca-cert = /etc/ocserv/ssl/ca-cert.pem
  11. isolate-workers = true
  12. banner = "Welcome DOUB.IO"
  13. max-clients = 0
  14. max-same-clients = 0
  15. rate-limit-ms = 0
  16. server-stats-reset-time = 604800
  17. keepalive = 32400
  18. dpd = 90
  19. mobile-dpd = 1800
  20. switch-to-tcp-timeout = 25
  21. try-mtu-discovery = false
  22. tls-priorities = "NORMAL:%SERVER_PRECEDENCE:%COMPAT:-VERS-SSL3.0"
  23. auth-timeout = 240
  24. idle-timeout = 86400
  25. mobile-idle-timeout = 86400
  26. min-reauth-time = 300
  27. max-ban-score = 80
  28. ban-reset-time = 1200
  29. cookie-timeout = 300
  30. deny-roaming = false
  31. rekey-time = 172800
  32. rekey-method = ssl
  33. use-occtl = true
  34. pid-file = /var/run/ocserv.pid
  35. net-priority = 6
  36. device = vpns
  37. predictable-ips = trueipv4-network = 192.168.1.0
  38. ipv4-netmask = 255.255.255.0
  39. # An alternative way of specifying the network:
  40. #ipv4-network = 192.168.1.0/24
  41. # The IPv6 subnet that leases will be given from.
  42. #ipv6-network = fda9:4efe:7e3b:03ea::/48
  43. # Specify the size of the network to provide to clients. It is
  44. # generally recommended to provide clients with a /64 network in
  45. # IPv6, but any subnet may be specified. To provide clients only
  46. # with a single IP use the prefix 128.
  47. #ipv6-subnet-prefix = 128
  48. #ipv6-subnet-prefix = 64

  49. # tunnel-all-dns = true
  50. dns = 8.8.8.8
  51. dns = 8.8.4.4
  52. ping-leases = false

  53. # Beginning of no-route, the following no-routes will be pushed to the client when connected. If all no-routes are removed, then all the traffic will be directed the remote gateway, i.e., Openconnect server gateway
  54. #no-route = 1.0.0.0/255.192.0.0
  55. #no-route = 1.64.0.0/255.224.0.0
  56. #no-route = 1.112.0.0/255.248.0.0
  57. #***
  58. #***
  59. #***
  60. #no-route = 223.0.0.0/255.224.0.0
  61. #no-route = 223.64.0.0/255.192.0.0
  62. #no-route = 223.128.0.0/255.128.0.0
  63. # End of no-route

  64. cisco-client-compat = true
  65. dtls-legacy = true
  66. default-domain = example.com
複製代碼

作者: 角色    時間: 2018-9-13 16:24

回復 14# tomleehk

谢谢CHing的信息,可能版本不一样。我的就把所有no-route删去就可以了。
作者: tomleehk    時間: 2018-9-13 18:46

回復 17# 角色

openwrt平台 亦都要將 openconnect server  上嘅 config file 裏面嘅routing 全部remove 或者 remark 咗佢




歡迎光臨 電訊茶室 (http://www.telecom-cafe.com/forum/) Powered by Discuz! 7.2