標題: Openconnect server in DD-wrt / optware with cert auth (update 25/9) [打印本頁] 作者: zotac 時間: 2016-9-22 17:27 標題: Openconnect server in DD-wrt / optware with cert auth (update 25/9)
本帖最後由 zotac 於 2016-9-25 03:29 編輯
小弟在Buffalo G300NH v1 DD-wrt 17798a 裝了optware Barrier Breaker 14.07 (snapshots 無法安裝), 並成功安裝了ocserv 0.8.9, 設定後但在iphone ios 9.3.5 anyconnect client 無法連接, 煩請各位高手睇吓小弟的設定那里出錯, 謝! (update 23/9 revise ocserv.conf & IPv4 address, able to connect to HK openconnect server with internet access, update 24/9, able to use 10.10.0.0/24 by update firewall rule, able to use occtl to view occserv status in ssh, update 25/9, auth = cert OK)
================================================================================
install optware Barrier Breaker 14.07 in dd-wrt 17798a for Buffalo G300NH v1 (update 24/9)
因為dd-wrt 17798a official firmware太舊了, 不能安裝snapshots / Chaos Calmer 15.05, 升級最新版dd-wrt用webupgrade九成九會變磚, 所以只能張就吓用previous stable release Barrier Breaker 14.07, DD-wrt 17798a openssl version is 0.98, no need to worry about the heartbleed bug
1. Jffs2 setup
go to router admin / management, enable jffs2, clean, reboot
putty
cd /jffs
mkdir etc root opt tmp
chmod 755 etc root opt tmp
mount -o bind /jffs/opt /opt
mount -o bind /jffs/etc /etc
mount -o bind /jffs/root /tmp/root
(you will have read/write enabled etc root opt for later installation of optware)
set lib/bin path for opkg
export LD_LIBRARY_PATH='/opt/lib:/opt/usr/lib:/lib:/usr/lib'
export PATH='/opt/bin:/opt/usr/bin:/opt/sbin:/opt/usr/sbin:/bin:/sbin:/usr/sbin:/usr/bin'
# run opkg
opkg -f /opt/etc/opkg.conf update
opkg -f /opt/etc/opkg.conf list
Then you'll have optware Barrier Breaker 14.07 installed
edit startup script in router admin / management /command
#! /bin/sh
mount -o bind /jffs/root /tmp/root
mount -o bind /jffs/etc /etc
mount -o bind /jffs/opt /opt
(make sure you have chmod 755 /jffs/root before your mount to /tmp/root and reboot, otherwise you'll get access denied when you login to router admin GUI and root by telnet/ssh after reboot)
3. install ocserv
reboot router, 又入返putty
run 任何optware program 前都要reset LIB/Bin Path:
export LD_LIBRARY_PATH='/opt/lib:/opt/usr/lib:/lib:/usr/lib'
export PATH='/opt/bin:/opt/usr/bin:/opt/sbin:/opt/usr/sbin:/bin:/sbin:/usr/sbin:/usr/bin'
在深圳以中移動香港一卡兩號LTE測試, 連接失敗 (test failed on 22/9)
IOS error log:
[VPN]<Error>-connection attempt has timed out. Please verify internet connectivity.
於putty login router command line test ocserv:
root@DD-WRT:/# ocserv -f -c /opt/etc/ocserv/ocserv.conf -d 1
Skipping unknown option 'cctl-socket-file'
Unknown user: ocserv (problem due to run-as-user = ocserv, removed as per CKLeea advise, many thanks!)
Update connection successful (23/9):
after remove the run-as-user = ocserv, as per CKLeea advise and change IPv4 network to 192.168.1.0, successfully connected to HK opennect server with internet access
成功啟動ocserv:
root@DD-WRT:/opt/etc/ocserv# ocserv -f -c /opt/etc/ocserv/ocserv.conf -d 1
Skipping unknown option 'cctl-socket-file'
listening (TCP) on 0.0.0.0:443...
listening (UDP) on 0.0.0.0:443...
ocserv[2570]: main: initialized ocserv 0.8.9
ocserv[2571]: sec-mod: sec-mod initialized (socket: /var/run/ocserv-socket.2570)
ocserv[2571]: sec-mod: received request from pid 2570 and uid 0
ocserv[2571]: sec-mod: cmd [size=#55#] sm: sign
delete: [23/9, test by China mobile LTE / 中国电信固网 in PRC, 現時只能以ip-v4 network 192.168.1.0設定連線, 如用10.10.0.0能夠連線, 但client無法上網, 仲未搞掂firewall rule如何把10.10.0.0連線後把web traffic經過router上網, 還請各位大神指點firewall rule應該點搞, Thanks!]
update on 24/9:
IOS client successfully connected to ocserv with internet access
oscerv conf: changed IP-v4 to 10.10.0.0/24,
adding firewall rule: iptables -t nat -I POSTROUTING -s 10.10.0.0/24 -o eth1 -j MASQUERADE
oscerv conf: dns use 8.8.8.8 - instead of 10.10.0.1 since ocserv 0.8.9 may random assign LAN IP other than 10.10.0.1 (in my case is 10.10.0.40) , that make client connected successfully to ocserv but without web access, you need to define dns server in ocserv.conf i.e. 8.8.8.8, don't use 192.168.1.1 as it may crash with client lan
下一步會試玩client用cert auth. 遲D再報告!
update on 25/9
又係putty
vi client.tmpl
cn = client (試過cn名可以任改, 但unit一定要係users, 如果唔係會auth fail)
unit = "users"
expiration_days = -1 (咁你張user cert的期限係, 一萬年)
signing_key
tls_www_client