Skip to content

Commit

Permalink
IP6 Option added
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Dowse committed Jul 6, 2021
1 parent ae1799a commit 3eca5f2
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 18 deletions.
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# _Advanced Users only_

# openvpn-multihop
Multihop with OpenVPN Tunnels on OPNsense

Expand All @@ -8,7 +6,7 @@ Multihop with OpenVPN Tunnels on OPNsense
Check if your provider supports this. [Perfect Privacy](https://www.perfect-privacy.com/en/features/multi-hop-vpn) is known to support at least 4 Tunnel.


Build Instructions
# Build Instructions

``` bash
git clone https://github.com/opnsense/plugins
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,11 @@
<help>If unchecked no static route entry will be added. Use only if you know what you are doing.</help>
<advanced>true</advanced>
</field>
<field>
<id>multihop.general.inet6</id>
<label>Enable IPv6</label>
<type>checkbox</type>
<help>If unchecked IP6 Traffice will not be routed trough tunnels</help>
<advanced>true</advanced>
</field>
</form>
4 changes: 4 additions & 0 deletions src/opnsense/mvc/app/models/OPNsense/Multihop/Multihop.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
<default>1</default>
<required>N</required>
</setroute>
<inet6 type="BooleanField">
<default>1</default>
<required>N</required>
</inet6>
</general>
<clients>
<client type="ArrayField">
Expand Down
35 changes: 20 additions & 15 deletions src/opnsense/scripts/OPNsense/Multihop/multihop.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
VPNID=$(pluginctl -g OPNsense.multihop | jq -r '.[].client[]? | .vpnid')
ROUTE=$(pluginctl -g OPNsense.multihop | jq -r '.general.setroute')
AUTO=$(pluginctl -g OPNsense.multihop | jq -r '.general.autorestart')
INET6=$(pluginctl -g OPNsense.multihop | jq -r '.general.inet6')
DFL_ROUTE=$(netstat -4nr | grep default | awk '{ print $2}')
HOPS=$(echo $VPNID | wc -w)
COUNT=1
Expand Down Expand Up @@ -118,6 +119,10 @@ else
func_addroute $IP
fi

if [ $INET6 -eq 1 ]; then
NET6='--redirect-gateway ipv6'
fi

#Bring up the tunnels

for HOP in $VPNID
Expand All @@ -140,6 +145,7 @@ else
# before we check the status

sleep 5;

echo "state all" | \
nc -N -U /var/etc/openvpn/client$HOP.sock | \
grep CONNECTED > /dev/null
Expand All @@ -149,14 +155,13 @@ else
func_stop
fi
else

#Start last tunnel
openvpn --config /var/etc/openvpn/client$HOP.conf \
--route-nopull \
--redirect-gateway ipv6 \
--redirect-gateway def1
--redirect-gateway def1 \
$NET6

sleep 5;
sleep 5;

echo "state all" | \
nc -N -U /var/etc/openvpn/client$HOP.sock | \
Expand All @@ -174,14 +179,14 @@ else

if [ $AUTO -eq 1 ]; then
DPING=$(netstat -4nr | grep ovpnc | grep UGS | \
awk '{ print $2 }' | sort -u)

for GW in $DPING
do
dpinger -o /dev/null -S -L 35% \
-C "/usr/local/opnsense/scripts/OPNsense/Multihop/multihop.sh restart" \
-p /var/run/dpinger-multihop-`echo $GW | sed 's/\./-/g'`.pid $GW
done
awk '{ print $2 }' | sort -u)

for GW in $DPING
do
dpinger -o /dev/null -S -L 35% \
-C "/usr/local/opnsense/scripts/OPNsense/Multihop/multihop.sh restart" \
-p /var/run/dpinger-multihop-`echo $GW | sed 's/\./-/g'`.pid $GW
done
fi
fi
#End Tunnel Function
Expand All @@ -190,13 +195,13 @@ fi

case $1 in
start) func_start
func_check
func_check
;;
stop) func_stop
;;
restart) func_stop
func_start
func_check
func_start
func_check
;;
status) func_check
;;
Expand Down

0 comments on commit 3eca5f2

Please sign in to comment.