-
Notifications
You must be signed in to change notification settings - Fork 694
/
ovpn-linkup
executable file
·32 lines (26 loc) · 1.02 KB
/
ovpn-linkup
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/bin/sh
ROUTERV4=
ROUTERV6=
if [ -n "${route_vpn_gateway}" ]; then
ROUTERV4="-a ${route_vpn_gateway}"
elif [ -n "${ifconfig_remote}" ]; then
ROUTERV4="-a ${ifconfig_remote}"
elif [ -n "${ifconfig_local}" ]; then
# XXX: We can't reliably determine the tunnels endpoint, other than parsing ifconfig.
# Use our standard parser to request the tunnels other end. Eventually we could pass this to configd if
# needed, but openvpn has elevated rights anyway at the moment.
ROUTERV4="-a $(/usr/local/etc/inc/plugins.inc.d/openvpn/tunnel_endpoint.php ${1})"
elif [ "${dev_type}" = "tun" -a -n "${5}" ]; then
ROUTERV4="-a ${5}"
fi
if [ -n "${route_ipv6_gateway_1}" ]; then
ROUTERV6="-a ${route_ipv6_gateway_1}"
elif [ -n "${ifconfig_ipv6_remote}" ]; then
ROUTERV6="-a ${ifconfig_ipv6_remote}"
elif [ -n "${ifconfig_ipv6_local}" ]; then
ROUTERV6="-a ${ifconfig_ipv6_local}"
fi
/usr/local/sbin/ifctl -4rd -i ${1} ${ROUTERV4}
/usr/local/sbin/ifctl -6rd -i ${1} ${ROUTERV6}
/usr/local/sbin/configctl -d interface newip ${1}
exit 0