Skip to content

Instantly share code, notes, and snippets.

@HackingGate
Created April 17, 2021 12:13
Show Gist options
  • Save HackingGate/cf0e2011d328e58f7ec61c5400f50bf5 to your computer and use it in GitHub Desktop.
Save HackingGate/cf0e2011d328e58f7ec61c5400f50bf5 to your computer and use it in GitHub Desktop.

Revisions

  1. HackingGate created this gist Apr 17, 2021.
    31 changes: 31 additions & 0 deletions oracle-wireguard-server.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,31 @@
    # WIP
    # The script is compatible with Canonical Ubuntu (Always Free Eligible) Minimal

    sudo apt update
    sudo apt install wireguard

    # ifconfig to check your interfae
    # for Ubuntu 20.04 Minimal 2021.03.25-0 it's ens3

    # Generate keys (WIP)

    sudo echo '
    [Interface]
    PrivateKey = server.key
    Address = 192.168.16.1/24
    ListenPort = 51820
    PostUp = sysctl -w net.ipv4.ip_forward=1; iptables -A FORWARD -i %i -j ACCEPT; iptables -t nat -A POSTROUTING -o ens3 -j MASQUERADE
    PostDown = iptables -D FORWARD -i %i -j ACCEPT; iptables -t nat -D POSTROUTING -o ens3 -j MASQUERADE
    [Peer]
    PublicKey = client.pub
    PresharedKey = shared.psk
    AllowedIPs = 192.168.16.0/24
    PersistentKeepalive = 25
    ' > /etc/wireguard/wg0.conf

    # Firewall settings
    # https://stackoverflow.com/a/54835902
    # WireGuard uses udp.
    sudo firewall-cmd --zone=public --permanent --add-port=51820/udp
    sudo firewall-cmd --reload