网络结构如图:
172.16.2.0/24
domain: .home.com
------------
| Home |
------------
/ \
/ \
------------ ------------
| Office | | NVR/NAS |
------------ ------------
172.16.4.0/24
domain: .office.com
1.在Home的网络中建设ocserv服务器,具体搭建方法可以参考:
http://gating.site/?p=692
如果要搭建site to site vpn的话,那么我们要注意几个参数:
config-per-user = /etc/ocserv/config-per-user/
expose-iroutes = false // 多子网重叠,一定要false,否则会导致网络挂掉
并且在config-per-user的目录下增加对应的用户名的配置文件,假设我们的用户名:office用来拨号的,那么我们要建一个以office命名的文件,并且其中的内容为客户端的子网地址
iroute = 172.16.4.0/24
服务器上需要打开路由设置的命令
route-add-cmd = "ip route add %{R} dev %{D}"
route-del-cmd = "ip route delete %{R} dev %{D}"
2.在Office的网络路由器的出口上新建网络VPN接口
3.在 Office的防火墙区域上选择WAN:
4.增加防火墙的转发规则
5.接口页面总览

如果证书没有得到openwrt的证书授权,那么你必须制定对应的Server’s certificate SHA1 hash
可以在系统日志中查看到类似的语
Wed May 1 21:45:06 2019 daemon.notice netifd: test (25517): Certificate from VPN server “172.16.1.1” failed verification.
Wed May 1 21:45:06 2019 daemon.notice netifd: test (25517): Reason: signer not found
Wed May 1 21:45:06 2019 daemon.notice netifd: test (25517): To trust this server in future, perhaps add this to your command line:
Wed May 1 21:45:06 2019 daemon.notice netifd: test (25517): –servercert sha256:b09d5179b9db9426087f644cae4124d03bd78999a393206b680895ed038a200e
那么在sha1的输入框加入sha256:b09d5179b9db9426087f644cae4124d03bd78999a393206b680895ed038a200e
即可
如果出现2个vpn接口互斥,那么就是推送的路由有冲突导致的。