This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| wireguard_on_freshtomato [2023/07/17 01:30] – [Introduction] -condense, change link label to "Quick Start", as per original hogwild | wireguard_on_freshtomato [2025/11/12 21:57] (current) – [Web interface or command-line configuration] -Update intro and add link to main WireGuard page hogwild | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== Wireguard ====== | ====== Wireguard ====== | ||
| - | Wireguard is a revolutionary VPN technology that allows for very fast throughput | + | Wireguard is a revolutionary VPN technology that allows for very fast throughput |
| Here are some rough benchmarks that illustrate the performance differences: | Here are some rough benchmarks that illustrate the performance differences: | ||
| Line 8: | Line 8: | ||
| | | ||
| + | |||
| + | ===== Web interface or command-line configuration ===== | ||
| + | |||
| + | r2024.1 and later allow Wireguard configuration via the web interface. Configuration is still available via command line as well. The instructions on this page explain how to configure WireGuard via the command-line interface. If you want to use the web interface instead, please see the main [[vpn-wireguard|WireGuard]] page. | ||
| + | |||
| + | The main principles will apply, regardless of the interface used. | ||
| ===== Introduction ===== | ===== Introduction ===== | ||
| - | Wireguard' | + | Wireguard' |
| - | Wireguard is not a " | + | Wireguard is not a " |
| - | Before configuring Wireguard, | + | Before configuring Wireguard, consult the official documentation' |
| ===== Overview ===== | ===== Overview ===== | ||
| - | Until a graphical interface | + | Wireguard |
| + | |||
| + | Once you understand some basic principles, | ||
| \\ | \\ | ||
| + | |||
| + | === Checking if Modules are Available/ | ||
| + | |||
| + | \\ If you're unsure, try loading the kernel module as follows: | ||
| <code -> | <code -> | ||
| Line 29: | Line 41: | ||
| </ | </ | ||
| - | | + | If you see no output, |
| - | \\ | + | |
| - | + | ||
| - | You should now be able to find it in the list of loaded modules: | + | |
| - | + | ||
| - | \\ | + | |
| <code -> | <code -> | ||
| Line 46: | Line 54: | ||
| \\ | \\ | ||
| - | If Wireguard | + | If Wireguard |
| - | + | ||
| - | \\ | + | |
| <code -> | <code -> | ||
| Line 58: | Line 64: | ||
| ===== Syntax ===== | ===== Syntax ===== | ||
| - | The first step is familiarize yourself with the '' | + | The first step is to familiarize yourself with the '' |
| \\ | \\ | ||
| Line 78: | Line 84: | ||
| You may pass `--help' | You may pass `--help' | ||
| </ | </ | ||
| + | |||
| + | \\ | ||
| \\ | \\ | ||
| Line 84: | Line 92: | ||
| For example: | For example: | ||
| - | |||
| - | \\ | ||
| <code -> | <code -> | ||
| Line 91: | Line 97: | ||
| Usage: wg show { < | Usage: wg show { < | ||
| </ | </ | ||
| + | |||
| + | \\ | ||
| ===== Configuration ===== | ===== Configuration ===== | ||
| - | There are multiple way wireguard | + | There are many ways Wireguard |
| - | ==== Point-to-point ==== | + | ==== Point-to-Point Connection |
| - | Here, we will illustrate how to achieve a point-to-point connection, the simplest kind. Let's assume we have two devices with these prerequisites: | + | This will illustrate how to achieve a point-to-point connection, the simplest kind. |
| - | | + | Let's assume there are two devices with these prerequisites: |
| - | * At least one of the devices has a public IP address. | + | |
| - | * DDNS is set up for the device' | + | |
| - | * SSH access | + | * At least one device with a public IP address. |
| - | * An alternate method of accessing the router or a host on the LAN accessible via \\ remote access software that doesn' | + | * DDNS configured |
| + | * SSH access available | ||
| + | * An alternate method of accessing the router, or a host on the LAN \\ accessible via remote access software that doesn' | ||
| \\ | \\ | ||
| - | You will need some type of permanent storage so settings will survive a reboot. | + | You will need some type of permanent storage so settings will survive a reboot. |
| + | |||
| + | The options | ||
| * [[nas-usb|USB]] | * [[nas-usb|USB]] | ||
| Line 119: | Line 131: | ||
| \\ | \\ | ||
| - | If that storage becomes unavailable, | + | If the storage becomes unavailable, |
| + | |||
| + | For this example, and the final setup, we'll use JFFS. It' | ||
| \\ | \\ | ||
| Line 126: | Line 140: | ||
| The first step is to create a working pair of keys for each device: | The first step is to create a working pair of keys for each device: | ||
| - | |||
| - | \\ | ||
| <code -> | <code -> | ||
| Line 135: | Line 147: | ||
| \\ | \\ | ||
| - | |||
| - | The above two key generation programs should have created two files: | ||
| \\ | \\ | ||
| + | |||
| + | The above two key generation programs should create two files: | ||
| <code -> | <code -> | ||
| root@routerA:/ | root@routerA:/ | ||
| - | -rw-r--r-- | + | -rw-r--r-- |
| - | -rw-r--r-- | + | -rw-r--r-- |
| </ | </ | ||
| | | ||
| - | The content of these files needs to be added to the configuration file. In this case, we will call that file: '' | + | The content of these files must be added to the configuration file. In this case, we will call that file: "wg0.conf". |
| - | Please | + | **Do not** use the keys from this example. They are hypothetical and only an example. |
| - | \\ The contents of the wg0.conf file on routerA are as follows: | + | |
| - | + | ||
| - | \\ | + | |
| <code -> | <code -> | ||
| root@routerA:/ | root@routerA:/ | ||
| - | [Interface] # RouterA | + | [Interface] # routerA |
| - | PrivateKey = WOOgLRpUxq3XjGfuP79JHKR/ | + | PrivateKey = WOOgLRpUxq3XjGfuP79JHKR/ |
| ListenPort = 51820 # Default port this router listen to, but can be changed if needed | ListenPort = 51820 # Default port this router listen to, but can be changed if needed | ||
| Line 168: | Line 178: | ||
| </ | </ | ||
| - | | + | |
| - | \\ | + | The contents of the wg0.conf file on routerB look like this: |
| <code -> | <code -> | ||
| root@routerB:/ | root@routerB:/ | ||
| - | [Interface] # RouterB | + | [Interface] # routerB |
| - | PrivateKey = WOOgLRpUxq3XjGfuP79JHKR/ | + | PrivateKey = WOOgLRpUxq3XjGfuP79JHKR/ |
| ListenPort = 51820 # Default port this router listen to, but can be changed if needed | ListenPort = 51820 # Default port this router listen to, but can be changed if needed | ||
| - | [peer] # RouterA | + | [peer] # routerA |
| Endpoint = rtra.ddns.org: | Endpoint = rtra.ddns.org: | ||
| PublicKey = Pr1EV/ | PublicKey = Pr1EV/ | ||
| Line 190: | Line 200: | ||
| \\ | \\ | ||
| - | === The consequences | + | === The Consequences |
| \\ | \\ | ||
| Line 198: | Line 208: | ||
| \\ | \\ | ||
| - | On a network with private addressing (behind NAT) that isn't reachable | + | On a network with private addressing (behind NAT), unreachable |
| + | |||
| + | \\ | ||
| + | |||
| + | Let's assume | ||
| - | \\ \\ The necessary changes to the wf0.conf file are seen here: \\ | + | \\ \\ The necessary changes to wg0.conf for this are: \\ |
| <code -> | <code -> | ||
| - | [peer] # RouterA | + | [peer] # routerA |
| Endpoint = rtra.ddns.org: | Endpoint = rtra.ddns.org: | ||
| PublicKey = Pr1EV/ | PublicKey = Pr1EV/ | ||
| Line 212: | Line 226: | ||
| \\ | \\ | ||
| - | The // | + | A // |
| \\ | \\ | ||
| Line 218: | Line 232: | ||
| \\ | \\ | ||
| - | === The consequences | + | === The Consequences |
| \\ | \\ | ||
| Line 224: | Line 238: | ||
| {{: | {{: | ||
| - | On a point-to-point connection, | + | On a point-to-point connection, |
| - | ===== Automated Script with full mesh support | + | ===== Automated Script with Full Mesh Support |
| - | Current version: 1.22\\ | + | A wizard creates the configuration in this all-in-one solution. It will automate all other steps including key creation, loading, unloading and more. The current version of this script is: 1.22\\ |
| - | + | ||
| - | This all-in-one solution | + | |
| <code -> | <code -> | ||
| - | wget https://tinyurl.com/28b5rckn | + | wget https://gist.githubusercontent.com/pedro0311/ |
| </ | </ | ||
| Line 244: | Line 256: | ||
| \\ | \\ | ||
| - | * On each device, both the " | + | * On each device, both the " |
| - | * The wg.sh and " | + | |
| - | \\ \\ {{: | + | * The " |
| - | \\ {{: | + | \\ {{: |
| - | Running " | + | Running " |
| * wg.sh | * wg.sh | ||
| Line 258: | Line 269: | ||
| \\ | \\ | ||
| - | You do not need to make any changes to those files. Simply copy them both to the relevant device (preferably jffs). This means you must run the makeconf on any one (and only one) device.\\ | + | You do not need to make changes to those files. Simply copy them both to the relevant device (preferably jffs). This means you must run the makeconf on any one, and only one, device. |
| - | The wg.sh script has been written | + | The wg.sh script has been written |
| + | The script also supports an '' | ||
| - | ==== Bringing up the VPN ==== | ||
| - | Now that we have the " | + | ==== Starting |
| - | \\ | + | Now that we have the " |
| + | |||
| + | Once the script completes (in about 5-10 seconds), the next step is to verify the last handshake command between the two hosts using the //show// parameter, like this: | ||
| <code -> | <code -> | ||
| Line 276: | Line 289: | ||
| This can be shortened to just '' | This can be shortened to just '' | ||
| - | |||
| - | \\ | ||
| <code -> | <code -> | ||
| Line 295: | Line 306: | ||
| \\ | \\ | ||
| - | The next step is to ping the remote intra-VPN IP address. For example, from RouterA: | + | The next step is to ping the remote intra-VPN IP address. |
| + | |||
| + | For example, from RouterA: | ||
| + | |||
| + | Then ping the remote LAN IP address | ||
| Line 313: | Line 328: | ||
| - | ==== Running | + | ==== Running Wireguard at Boot ==== |
| As hinted previously, you must rely on permanent storage to make this work. Regardless of what type of storage you choose, it might become unavailable. For this reason, [[jffs|JFFS]] has been used throughout the examples, as it arguably the most reliable form. To run Wireguard automatically, | As hinted previously, you must rely on permanent storage to make this work. Regardless of what type of storage you choose, it might become unavailable. For this reason, [[jffs|JFFS]] has been used throughout the examples, as it arguably the most reliable form. To run Wireguard automatically, | ||
| Line 332: | Line 347: | ||
| ==== Running multiple VPN technologies at once ==== | ==== Running multiple VPN technologies at once ==== | ||
| - | It is generally | + | It is generally |
| + | |||
| + | Having a Wireguard client connect from a mobile phone or a site that uses slow DSL could create unwanted overhead. So why use two VPNs at once? | ||
| \\ \\ {{: | \\ \\ {{: | ||
| - | Let' | + | Let' |
| - | \\ \\ If something | + | \\ \\ If something |
| - | | + | \\ {{: |
| - | However, | + | However, |
| - | * A "/ | + | * A "/ |
| - | * A "/ | + | * A "/ |
| - | \\ | + | |
| - | Under those conditions, the tinc-only devices could play a very important role in resilience/ | + | If the Wireguard script is up (" |
| - | + | ||
| - | If the Wireguard script is up (the " | + | |
| \\ | \\ | ||
| Line 357: | Line 372: | ||
| === Routing verification === | === Routing verification === | ||
| - | When your routing table has multiple options to reach a destination, | + | When your routing table has multiple options to reach a destination, |
| + | |||
| + | In the same example, with two VPN technologies running at once, you can verify the routing table' | ||
| '' | '' | ||
| Line 384: | Line 401: | ||
| to the following: | to the following: | ||
| + | |||
| + | \\ | ||
| <code -> | <code -> | ||
| Line 391: | Line 410: | ||
| Using the script with the " | Using the script with the " | ||
| - | Remember that you can get help with any subcommand by typing: | + | \\ |
| \\ | \\ | ||
| + | |||
| + | Remember that you can get help with any subcommand by typing:\\ | ||
| <code -> | <code -> | ||
| Line 401: | Line 422: | ||
| \\ | \\ | ||
| - | Remember also that '' | + | \\ |
| - | \\ \\ {{:pasted: | + | Remember that '' |
| - | However, you can also display advanced information by using: | + | \\ {{:pasted: |
| - | \\ | + | You can also display more advanced information by using: |
| <code -> | <code -> | ||
| root@routera:/# | root@routera:/# | ||
| + | </ | ||
| + | |||
| + | | ||
| + | \\ If there' | ||
| + | |||
| + | <code -> | ||
| + | root@routera:/# | ||
| </ | </ | ||
| \\ | \\ | ||
| - | If there' | + | Pinging the intra-VPN IP address first will help to identify if Wireguard is the issue or if it is routing-related.\\ |
| + | |||
| + | |||
| + | ==== Known Bugs ==== | ||
| \\ | \\ | ||
| - | <code -> | + | With the current version of the code (v1.0.20200827), |
| - | root@routera:/# | + | |
| - | </ | + | |
| \\ | \\ | ||
| - | Pinging the intra-VPN IP address first will help to identify if Wireguard is the issue or if it is routing-related.\\ \\ | + | {{: |
| - | Finally, pay attention to the // | + | This should be fixed in a later version of the code. |
| + | \\ | ||
| + | |||
| + | \\ | ||
| - | ==== Known bugs ==== | ||
| - | On the current version of the code: | ||
| - | <code -> | ||
| - | wireguard-tools v1.0.20200827 - https:// | ||
| - | {{: | ||
| - | Using the wg (a.k.a. wg show) command it appears like the sent traffic is not counted as it should. | ||