我有这样的情况:
在SIP2上,我已经启动了OpenVPN服务器,并且从客户端连接到它,使用–client选项来打开VPN,将stream量绑定到CIP2
现在问题 – 如何修改服务器上的路由表,在客户端连接时通过隧道添加到SIP1的路由?
这只是猜测,但…
看起来你可能可以使用client-connect脚本来做你想做的事情。 从手册页:
The script is passed the common name and IP address of the just-authenticated client as environmental variables (see environmental variable sec- tion below). The script is also passed the pathname of a not-yet-created temporary file as $1 (ie the first command line argument), to be used by the script to pass dynamically generated config file directives back to OpenVPN.
所以,使用这个脚本,你应该能够将必要的路由命令添加到OpenVPNconfiguration。 您可以使用相应的client-disconnect脚本来拆除路由。
我认为这是典型的服务器到服务器[而不是拨号式]设置。
在服务器端放置如下:
# first local address assigned to the vpn tunnel, then remote # [ this is not SIPx/CIPx - it's just private addressing for the tunnel ] ifconfig 10.255.255.10 10.255.255.9 # here you install a new route on the server whenever vpn is established # you want to put CIP1/32 routed via vpn ip assigned to the remote end of vpn route 10.13.0.0 255.255.0.0 10.255.255.9 port somePort [..]
在客户端:
# put your SIP1 here and some port on which server is configured remote 213.xxx.xxx.xxx somePort # again - first is local, second - remote address of vpn tunnel ifconfig 10.255.255.9 10.255.255.10 # you want to put below SIP1/32 routed via vpn ip from far end of the tunnel route 10.15.0.0 255.255.0.0 10.255.255.10
您将需要添加到特定于您的encryption方法的那几行。 尝试按照此处所述的初学者预共享密钥。 如果使用适当的生产设置,这将更安全。
因为您将注入SIP1 / 32 [SIP1 255.255.255.255用于openvpn中使用的符号] – 您的安全路由 – 只要vpnbuild立 – 将始终select与SIP1 [反之亦然]的通信。 但是..一旦vpn变成了可能 – 敏感的stream量可能会通过不受信任的networkingstream动。 哪..你不想发生。 如果你必须使用公共的SIP1 / CIP1–确保防火墙(甚至是本地的)只允许通过openvpn创build的tunX设备进行通信,并且不允许在公共互联网上进行任何直接的通信。
路由xxxx 255.255.255.0 #将数据包引导到OVPN TUN接口
iroute xxxx 255.255.255.0 #在client-config-dir命令指定的用户configuration脚本中,在OVPN进程中添加路由