Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
gentoo:wireguard [2025/02/05 11:53] – willy | gentoo:wireguard [2025/03/13 13:26] (current) – [WireGuard] willy | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== WireGuard ====== | + | ====== |
- | [[https:// | + | [[https:// |
+ | |||
+ | WireGuard will create an encrypted and protected tunnel between hosts, where each host act as a peer. You need to have at least one host reachable from all the others, of course, but then WireGuard will create a common subnetwork on which all the hosts will see each other. | ||
===== Concepts ===== | ===== Concepts ===== | ||
- | network | + | You should be fmailiar with basic networking concepts like routing, subnets, addresses. |
- | tunnel | + | A **subnet** is a portion of a network where all the hosts can ping each other without the need of a // |
+ | |||
+ | All VPNs work by creating an encrypted **tunnel** between it's peers. This tunnel needs to be initiated from one host to the other (or viceversa) and whatever traffic flows inside the tunnes is not intellegible to anyone else because it's, guess what, encrypted. | ||
+ | |||
+ | To perform the encryption at both ends, some encryption **keys** needs to be shared. The approach used by WireGuard is to use the private/ | ||
- | keys | ||
===== Installation ===== | ===== Installation ===== | ||
+ | These steps need to be followed on every host that participate in the WireGuard tunnel. | ||
+ | |||
+ | Installing WireGuard on Gentoo is pretty easy since the latest release is always in portage, but you will also need [[gentoo: | ||
<code bash> | <code bash> | ||
- | emerge -v net-vpn/ | + | emerge -v net-vpn/ |
</ | </ | ||
+ | |||
Create local host private and public keys: | Create local host private and public keys: | ||
Line 21: | Line 30: | ||
wg genkey > / | wg genkey > / | ||
wg pubkey < / | wg pubkey < / | ||
+ | chmod 500 / | ||
</ | </ | ||
+ | |||
+ | You will need these two keys for the configuration below. | ||
===== Configuration ===== | ===== Configuration ===== | ||
- | Each WireGuard tunnel | + | A WireGuard tunnel |
- | So, create | + | So, create |
<file - wg0.conf> | <file - wg0.conf> | ||
[Interface] | [Interface] | ||
- | PrivateKey = << local private key >> | + | PrivateKey = << local host private key >> |
Address = 10.100.0.1/ | Address = 10.100.0.1/ | ||
- | ListenPort = << | + | ListenPort = << |
[Peer] | [Peer] | ||
- | PublicKey = << remote | + | PublicKey = << remote |
- | Endpoint = << | + | Endpoint = << |
- | AllowedIPs = 10.100.0.2/ | + | AllowedIPs = 10.100.0.2/ |
PersistentKeepAlive = 25 | PersistentKeepAlive = 25 | ||
</ | </ | ||
Where: | Where: | ||
- | * You can have as many peers as you need to connect to the local host | + | * You can have as many peers as you need to connect to the local host, just create one [Peer] block for each one. |
* The // | * The // | ||
- | * The //Address// is the __local host__ address on the tunnel subnetwork | + | * The //Address// is the __local host__ address on the __tunnel subnetwork__ (usually, a new subnet you are not using already) |
- | * The // | + | * The // |
* The // | * The // | ||
- | * The // | + | * The // |
- | * The //peer port// is the // | + | * The // |
- | * The // | + | |
* The // | * The // | ||
- | Each peer (host) connecting to the WireGuard tunnel will need one of these files. If you have two hosts (tipycal setup), assume that you need two // | + | Each host connecting to the WireGuard tunnel will need one of these files. These configuration files should usually be symmetrical to each other. |
Link the startup scripts and set it to start on boot: | Link the startup scripts and set it to start on boot: | ||
Line 59: | Line 70: | ||
rc-update add wg-quick.wg0 default | rc-update add wg-quick.wg0 default | ||
</ | </ | ||
+ | |||
+ | ===== Remote access ===== | ||
+ | |||
+ | There are tons of WireGuard tutorials online on how to use WireGuard to connect your mobile device securely to your home network, i do not plan to cover this topic here. | ||
+ | |||
+ | |||