@@ -35,6 +35,21 @@ function addArg {
35
35
fi
36
36
}
37
37
38
+ # set up iptables rules and routing
39
+ # this allows rules/routing to be altered by supplying this function
40
+ # in an included file, such as ovpn_env.sh
41
+ function setupIptablesAndRouting {
42
+ iptables -t nat -C POSTROUTING -s $OVPN_SERVER -o $OVPN_NATDEVICE -j MASQUERADE || {
43
+ iptables -t nat -A POSTROUTING -s $OVPN_SERVER -o $OVPN_NATDEVICE -j MASQUERADE
44
+ }
45
+ for i in " ${OVPN_ROUTES[@]} " ; do
46
+ iptables -t nat -C POSTROUTING -s " $i " -o $OVPN_NATDEVICE -j MASQUERADE || {
47
+ iptables -t nat -A POSTROUTING -s " $i " -o $OVPN_NATDEVICE -j MASQUERADE
48
+ }
49
+ done
50
+ }
51
+
52
+
38
53
addArg " --config" " $OPENVPN /openvpn.conf"
39
54
40
55
source " $OPENVPN /ovpn_env.sh"
53
68
54
69
# Setup NAT forwarding if requested
55
70
if [ " $OVPN_DEFROUTE " != " 0" ] || [ " $OVPN_NAT " == " 1" ] ; then
56
- iptables -t nat -C POSTROUTING -s $OVPN_SERVER -o $OVPN_NATDEVICE -j MASQUERADE || {
57
- iptables -t nat -A POSTROUTING -s $OVPN_SERVER -o $OVPN_NATDEVICE -j MASQUERADE
58
- }
59
- for i in " ${OVPN_ROUTES[@]} " ; do
60
- iptables -t nat -C POSTROUTING -s " $i " -o $OVPN_NATDEVICE -j MASQUERADE || {
61
- iptables -t nat -A POSTROUTING -s " $i " -o $OVPN_NATDEVICE -j MASQUERADE
62
- }
63
- done
71
+ # call function to setup iptables rules and routing
72
+ # this allows rules to be customized by supplying
73
+ # a replacement function in, for example, ovpn_env.sh
74
+ setupIptablesAndRouting
64
75
fi
65
76
66
77
# Use a hacky hardlink as the CRL Needs to be readable by the user/group
85
96
86
97
echo " Running 'openvpn ${ARGS[@]} ${USER_ARGS[@]} '"
87
98
exec openvpn ${ARGS[@]} ${USER_ARGS[@]}
88
-
0 commit comments