Skip to content

Instantly share code, notes, and snippets.

@TimoDJatomika
Last active December 24, 2018 09:13
Show Gist options
  • Save TimoDJatomika/cf230514e724e5ab7a10a97bcad973e6 to your computer and use it in GitHub Desktop.
Save TimoDJatomika/cf230514e724e5ab7a10a97bcad973e6 to your computer and use it in GitHub Desktop.

Revisions

  1. TimoDJatomika revised this gist Dec 24, 2018. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions install-openvpn-ubuntu-18.04.md
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@
    by Timo Stankowitz <[email protected]>

    ## apt
    ```
    ```bash
    sudo su
    apt update -y
    apt install openvpn -y
    @@ -20,7 +20,7 @@ copy the following files into that folder
    - server.key (chown 600)
    - dh2048.pem

    ## Server conf
    ## server conf
    `vi /etc/openvpn/server.conf`

    copy the following content into that file
    @@ -65,7 +65,7 @@ log-append /var/log/openvpn
    ```

    ## activate masquerade
    ```
    ```bash
    #!/bin/bash

    echo activate MASQUERADE
  2. TimoDJatomika revised this gist Dec 24, 2018. 1 changed file with 4 additions and 10 deletions.
    14 changes: 4 additions & 10 deletions install-openvpn-ubuntu-18.04.md
    Original file line number Diff line number Diff line change
    @@ -64,25 +64,19 @@ verb 3
    log-append /var/log/openvpn
    ```

    ## /etc/rc.local
    add the following to the file `/etc/rc.local`

    ```
    #!/bin/sh -e
    sysctl -w net.ipv4.ip_forward=1
    exit 0
    ```

    ## activate masquerade
    ```
    #!/bin/bash
    echo activate MASQUERADE
    iptables -t nat -A POSTROUTING -s 172.28.28.0/24 -o eth0 -j MASQUERADE
    # enable ip forwarding
    sysctl -w net.ipv4.ip_forward=1
    ```

    ## reboot
    reboot the server. The OpenVPN Server should start automatically. Verify it with `systemctl status openvpn`
    Reboot the server. The OpenVPN Server should start automatically. Verify it with `systemctl status openvpn`


  3. TimoDJatomika revised this gist Dec 23, 2018. 1 changed file with 9 additions and 0 deletions.
    9 changes: 9 additions & 0 deletions install-openvpn-ubuntu-18.04.md
    Original file line number Diff line number Diff line change
    @@ -73,6 +73,15 @@ sysctl -w net.ipv4.ip_forward=1
    exit 0
    ```

    ## activate masquerade
    ```
    #!/bin/bash
    echo activate MASQUERADE
    iptables -t nat -A POSTROUTING -s 172.28.28.0/24 -o eth0 -j MASQUERADE
    ```

    ## reboot
    reboot the server. The OpenVPN Server should start automatically. Verify it with `systemctl status openvpn`

  4. TimoDJatomika created this gist Dec 23, 2018.
    79 changes: 79 additions & 0 deletions install-openvpn-ubuntu-18.04.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,79 @@
    # How to install OpenVPN on Ubuntu 18.04
    by Timo Stankowitz <[email protected]>

    ## apt
    ```
    sudo su
    apt update -y
    apt install openvpn -y
    ```

    ## certs
    Use the programm XCA to generate all certs and keys

    `mkdir /etc/openvpn/certs`

    copy the following files into that folder

    - ca.crt
    - server.crt
    - server.key (chown 600)
    - dh2048.pem

    ## Server conf
    `vi /etc/openvpn/server.conf`

    copy the following content into that file

    ```
    port 1194
    proto udp
    dev tun
    ca /etc/openvpn/certs/ca.crt
    cert /etc/openvpn/certs/server.crt
    key /etc/openvpn/certs/server.key
    dh /etc/openvpn/certs/dh2048.pem
    server 172.28.28.0 255.255.255.0
    push "redirect-gateway def1 bypass-dhcp"
    client-to-client
    push "dhcp-option DNS 8.8.8.8"
    push "dhcp-option DNS 4.2.2.2"
    push "topology subnet"
    topology subnet
    route 172.28.28.0 255.255.255.0
    keepalive 10 120
    #comp-lzo
    user nobody
    group nogroup
    persist-key
    persist-tun
    status /var/log/openvpn-status.log
    verb 3
    log-append /var/log/openvpn
    ```

    ## /etc/rc.local
    add the following to the file `/etc/rc.local`

    ```
    #!/bin/sh -e
    sysctl -w net.ipv4.ip_forward=1
    exit 0
    ```

    ## reboot
    reboot the server. The OpenVPN Server should start automatically. Verify it with `systemctl status openvpn`