This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| raspberry_wireguard [2022/02/17 18:45] โ herwarth | raspberry_wireguard [2022/02/17 19:07] (current) โ herwarth | ||
|---|---|---|---|
| Line 53: | Line 53: | ||
| <code - / | <code - / | ||
| alias temp='/ | alias temp='/ | ||
| + | </ | ||
| + | ====Unattended upgrades==== | ||
| + | I do not want to update manually. | ||
| + | < | ||
| + | apt install -y unattended-upgrades apt-listchanges | ||
| + | </ | ||
| + | < | ||
| + | cp / | ||
| + | </ | ||
| + | <code - / | ||
| + | . | ||
| + | . | ||
| + | Unattended-Upgrade:: | ||
| + | // Codename based matching: | ||
| + | // This will follow the migration of a release through different | ||
| + | // archives (e.g. from testing to stable and later oldstable). | ||
| + | // Software will be the latest available for the named release, | ||
| + | // but the Debian release itself will not be automatically upgraded. | ||
| + | " | ||
| + | |||
| + | // Archive or Suite based matching: | ||
| + | // Note that this will silently match a different release after | ||
| + | // migration to the specified archive (e.g. testing becomes the | ||
| + | // new stable). | ||
| + | // " | ||
| + | // " | ||
| + | // " | ||
| + | // " | ||
| + | }; | ||
| + | . | ||
| + | . | ||
| + | . | ||
| + | // Remove unused automatically installed kernel-related packages | ||
| + | // (kernel images, kernel headers and kernel version locked tools). | ||
| + | Unattended-Upgrade:: | ||
| + | |||
| + | // Do automatic removal of newly unused dependencies after the upgrade | ||
| + | Unattended-Upgrade:: | ||
| + | |||
| + | // Do automatic removal of unused packages after the upgrade | ||
| + | // (equivalent to apt-get autoremove) | ||
| + | Unattended-Upgrade:: | ||
| + | |||
| + | // Automatically reboot *WITHOUT CONFIRMATION* if | ||
| + | // the file / | ||
| + | Unattended-Upgrade:: | ||
| + | |||
| + | // Automatically reboot even if there are users currently logged in | ||
| + | // when Unattended-Upgrade:: | ||
| + | Unattended-Upgrade:: | ||
| + | |||
| + | // If automatic reboot is enabled and needed, reboot at the specific | ||
| + | // time instead of immediately | ||
| + | // Default: " | ||
| + | Unattended-Upgrade:: | ||
| + | . | ||
| + | . | ||
| + | </ | ||
| + | Test | ||
| + | < | ||
| + | unattended-upgrades -d | ||
| + | </ | ||
| + | This should not give any error | ||
| + | < | ||
| + | dpkg-reconfigure -plow unattended-upgrades | ||
| </ | </ | ||
| ===== Wireguard ===== | ===== Wireguard ===== | ||
| ==== Packages ==== | ==== Packages ==== | ||
| < | < | ||
| - | apt install -y wireguard | + | apt install -y wireguard |
| </ | </ | ||
| ==== IP forwarding==== | ==== IP forwarding==== | ||
| Line 70: | Line 135: | ||
| sysctl -p / | sysctl -p / | ||
| </ | </ | ||
| + | ==== Configuration==== | ||
| + | I am not going to explain how Wireguard works. There is plenty to find on internet. In this example we ha defined two clients (peers) who can connect to the server | ||
| + | <code - / | ||
| + | [Interface] | ||
| + | Address = 192.168.168.1 | ||
| + | ListenPort = 51820 | ||
| + | PrivateKey = < | ||
| + | [Peer] | ||
| + | PublicKey = < | ||
| + | AllowedIPs = 192.168.168.2/ | ||
| + | [Peer] | ||
| + | PublicKey = < | ||
| + | AllowedIPs = 192.168.168.3/ | ||
| + | </ | ||
| + | |||
| + | ==== Enable the wg-quick service==== | ||
| + | < | ||
| + | systemctl enable wg-quick@wg0 | ||
| + | systemctl start wg-quick@wg0 | ||
| + | systemctl status wg-quick@wg0 | ||
| + | โ wg-quick@wg0.service - WireGuard via wg-quick(8) for wg0 | ||
| + | | ||
| + | | ||
| + | Docs: man: | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | Process: 913 ExecStart=/ | ||
| + | Main PID: 913 (code=exited, | ||
| + | CPU: 144ms | ||
| + | |||
| + | Feb 17 19:52:38 wireguard systemd[1]: Starting WireGuard via wg-quick(8) for wg0... | ||
| + | Feb 17 19:52:38 wireguard wg-quick[913]: | ||
| + | Feb 17 19:52:38 wireguard wg-quick[913]: | ||
| + | Feb 17 19:52:38 wireguard wg-quick[913]: | ||
| + | Feb 17 19:52:38 wireguard wg-quick[913]: | ||
| + | Feb 17 19:52:38 wireguard wg-quick[913]: | ||
| + | Feb 17 19:52:38 wireguard wg-quick[913]: | ||
| + | Feb 17 19:52:38 wireguard systemd[1]: Finished WireGuard via wg-quick(8) for wg0. | ||
| + | </ | ||
| + | |||
| + | ==== Enable masquerading ==== | ||
| + | Raspberry OS has changed to nftables instead of iptabes | ||
| + | <code - / | ||
| + | . | ||
| + | . | ||
| + | . | ||
| + | add table wireguard-nat | ||
| + | |||
| + | table ip wireguard-nat { | ||
| + | chain prerouting { | ||
| + | type nat hook prerouting priority -100; policy accept; | ||
| + | } | ||
| + | |||
| + | chain postrouting { | ||
| + | type nat hook postrouting priority 100; policy accept; | ||
| + | oifname " | ||
| + | } | ||
| + | } | ||
| + | </ | ||
| + | < | ||
| + | systemctl enable --now nftables | ||
| + | systemctl start nftables | ||
| + | </ | ||
| + | ====Done==== | ||
| + | Do a final reboot | ||
| + | < | ||
| + | shutdown -r now | ||
| + | </ | ||
| {{tag> | {{tag> | ||