How to configure Multihop
WireGuard Multihop
This guide is for Linux systems only. Mac and Windows will not be able to follow this guide.
To start, head over to the configs section of your dashboard and download the configs you'd like to use for multihop. This guide will show you how to do it with 2 configs (a single hop), for any more hops please refer to Additional Hops. After downloading your configs, move or copy them to your WireGuard folder at /etc/wireguard
. Next, if your configs are using a domain for the endpoint (for example ny1.shockvpn.com
), you will need to find the address that this resolves to. Provided you have nslookup
and sed
installed on your system, this can be done easily with the command:
For this guide, we will be using configs from Texas (tx2) and West Chicago (wc2). We will be hopping from the Texas config to the West Chicago config, so for clarity we are going to rename the configs appropriately. Our Texas config will be named hop.conf
and our West Chicago config will be named dest.conf
, this is also how we will refer to each config moving forward.
First, open your hop.conf
in your favorite editor and make the following changes:
- remove the
DNS
line as we don't need it anymore (should look something likeDNS = 10.0.0.1
) - modify the
AllowedIPs
section so that it points to the IP address for our destination with the "prefix" 32 (in our case104.36.229.172/32
for wc2)
At this point, your hop.conf
should look something like this:
Next, it gets a little complicated. We need to exclude all the subnets that don't include the IP address for the hop config (in our case 172.96.137.210
). To assist with this, we've created a helpful script you can download from our helpful scripts repo on GitHub, or you can download it with curl by running:
Be sure that your script is executable (chmod +x exclude_subnets.sh
) and run the the script with the -s
(sort the subnets by prefix for clarity) and -w
(give us a response in the format needed for the our WireGuard config) flags. In our case that would look like this:
This should return something similar to this:
Copy and paste this into your dest.conf
where it currently shows AllowedIPs = 0.0.0.0/0, ::/0
. Your dest.conf
should now look something like this:
At this point, we're ready to bring up the interfaces. Starting with our hop: sudo wg-quick up hop
, and following with our destination sudo wg-quick up dest
. You can verify that this is now working by running curl -LsS api.shockvpn.com/v1/ip
or curl -LsS api.shockvpn.com/v1/ip | jq
if you have jq
installed for a cleaner output. You should see that your response shows the output of whatever location you have for your dest.conf
, in our case, this is the response we see:
Great, looks like we're all set!
Additional Hops
For any hops other than the single hop outlined in this guide, the process will be mostly the same, aside from the AllowedIPs
section of your configurations section of your configurations. For example, if we did 2 hops our first hop would have the AllowedIPs
for only the IP address of our second hop, the second hop would have only the AllowedIPs
for our destination, and the destination would have all the subnets that don't include either of the first 2 config's IP addresses. Using our examples from the guide, that would look something like ./exclude_subnets.sh 172.96.137.210,104.36.229.172 -s -w
with the output being: