Skip to content

Instantly share code, notes, and snippets.

@cyrex562
Created May 16, 2019 16:12
Show Gist options
  • Select an option

  • Save cyrex562/553398e6946ee409c86072fd021b56d5 to your computer and use it in GitHub Desktop.

Select an option

Save cyrex562/553398e6946ee409c86072fd021b56d5 to your computer and use it in GitHub Desktop.
Setup Wireguard on a Linux Host

Ubuntu Server 18.04

  1. Add the WireGuard apt repo:

    sudo add-apt-repository ppa:wireguard/wireguard
    sudo apt-get update
  2. Install WireGuard: sudo apt install wireguard

  3. Generate private key: wg genkey > /etc/wireguard/private_key

  4. Generate public key: wg pubkey < /etc/wireguard/private_key > /etc/wg/public_key

  5. Create a WireGuard interface configuration file: nano /etc/wireguard/{int}.conf:

    [Interface]
    ListenPort = 54321
    PrivateKey = +PL/53noze0Gxx2QzY2fDy24E4jX42LoD/RIMpJP7lI=
    [Peer]
    PublicKey = juvTm8/xAjCNRnGcQq0hormgBvSIZLCrb6sSk2dFa2s=
    AllowedIPs = 0.0.0.0/0
    Endpoint = 104.248.2.255:54321
  6. Create directory for WireGuard scripts: sudo mkdir -p /opt/wireguard

  7. Copy over wg_up.py to /opt/wireguard/

  8. Create a WireGuard extra config file: nano /etc/wireguard{int}_extra.conf:

    [interface]
    routes =
    name = wg0
    address = 10.200.200.2/30
  9. Bring up WireGuard interface with python config script: sudo python3 wg_up.py --wg_conf /etc/wireguard/wgx.conf --wg_extra_conf /etc/wireguard/wgx_extra.conf

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment