Optimized wireguard for ubuntu

This commit is contained in:
Kevin Veen-Birkenbach 2021-01-12 09:44:14 +01:00
parent a273f6752f
commit f9abd2d9be
4 changed files with 31 additions and 11 deletions

View File

@ -1,4 +1,5 @@
- name: apt update all packages to their latest version - name: apt update all packages to their latest version
apt: apt:
name: "*" update_cache: yes
state: latest upgrade: dist
force_apt_get: yes

View File

@ -2,3 +2,4 @@
# see # see
- https://gist.github.com/insdavm/b1034635ab23b8839bf957aa406b5e39 - https://gist.github.com/insdavm/b1034635ab23b8839bf957aa406b5e39
- https://wiki.debian.org/iptables

View File

@ -1,10 +1,23 @@
# Role Native Wireguard # Role Native Wireguard
Manages wireguard natively on host. More information are available in the [Arch wiki](https://wiki.archlinux.org/index.php/WireGuard#Manual_WireGuard_setup). Manages wireguard on host.
## Create Client Key ## Client
``bash ### Create Client Keys
wg genkey | tee peer_A.key | wg pubkey > peer_A.pub ```bash
`` wg_private_key="$(wg genkey)"
wg_public_key="$(echo "$wg_private_key" | wg pubkey)"
echo "PrivateKey: $wg_private_key"
echo "PublicKey: $wg_public_key"
echo "PresharedKey: $(wg genpsk)"
```
chown root:systemd-network /etc/systemd/network/99-*.netdev ### Activate Configuration
chmod 0640 /etc/systemd/network/99-*.netdev ```bash
cp /path/to/wg0.conf /etc/wireguard/wg0.conf
systemctl enable wg-quick@wg0.service --now
```
## See
- https://golb.hplar.ch/2019/01/expose-server-vpn.html
- https://wiki.archlinux.org/index.php/WireGuard
- https://wireguard.how/server/raspbian/

View File

@ -1,5 +1,10 @@
- name: install wireguard - name: install wireguard for Arch
pacman: name=wireguard-tools state=present pacman: name=wireguard-tools state=present
when: ansible_os_family == "Arch"
- name: install wireguard for Ubuntu
apt: name=wireguard state=present
when: ansible_os_family == "Debian"
- name: create /etc/wireguard/wg0.conf - name: create /etc/wireguard/wg0.conf
copy: copy: