Zum Inhalt springen

VPN um 1 Euro im Monat

    Es gibt eine Möglichkeit seinen eigenen VPN und Proxy Server für nur einen Euro pro Monat einzurichten und selbst zu betreiben.

    Das ist interessant für Menschen, die nicht ein 2 Jahres Abo abschließen möchten, um dann umgerechnet 3 € pro Monat bei einem VPN Anbieter zu bezahlen, der evtl. nicht für den angedachten Einsatz kompatibel ist.

    Die VPN Hoster machen es einem natürlich einfach. Sie bieten entsprechende Apps und Anleitungen an aber nicht jeder Anbieter hat die Lösung die man selbst benötigt. Wer selbst Herr seines VPN Dienstes ein möchte, der kann sich zb. bei IONOS einen XS VPS für einen Euro im Monat mieten und darauf selbst den VPN oder Proxy Dienst einrichten, den man bevorzugt.
    Oder beides.

    IONOS

    Ionos (Partnerlink) hat Rechenzentren auf ein paar Standorten und keine Trafficeinschränkung.
    Der VPS Linux XS Server reicht im Prinzip völlig aus. VPN Dienste wie OpenVPN können den Speed allerdings evtl. nicht voll ausreizen, da der VPS XS nur eine vCPU hat und openVPN da doch etwas mehr CPU Leistung brauchen könnte.
    Aber man kann ja auch Wireguard verwenden, welches nicht so CPU lastig ist.
    Bei mieten der VPS wähle ich in der Regel Debian.

    ionos

    VPN und Proxy Tools

    Nachfolgend beschreibe ich welche VPN und Proxy Tools ich selbst nutze und wie man diese auf Debian installiert.
    Für manche gibts es inzwischen gute Skripte auf GitHub.

    OpenVPN

    Für OpenVPN kann man das GitHub Script von angristan verwenden.

    Man lädt das Script mit diesem Befehl herunter (sollte curl nicht installiert sein, muss man es mit „apt-get install curl“ vorher installieren)

    curl -O https://raw.githubusercontent.com/angristan/openvpn-install/master/openvpn-install.sh

    Und macht das Script mit

    chmod +x openvpn-install.sh

    ausführbar.

    Mit „./openvpn-install.sh“ führt man es aus.

    Das Installscript fragt nun ein paar Eingaben ab. Wer sich nicht sicher ist, kann meiste alles beim Standard belassen.

    Welcome to the OpenVPN installer!
    The git repository is available at: https://github.com/angristan/openvpn-install
    
    I need to ask you a few questions before starting the setup.
    You can leave the default options and just press enter if you are ok with them.
    
    I need to know the IPv4 address of the network interface you want OpenVPN listening to.
    Unless your server is behind NAT, it should be your public IPv4 address.
    IP address: 192.168.0.2
    
    It seems this server is behind NAT. What is its public IPv4 address or hostname?
    We need it for the clients to connect to the server.
    Public IPv4 address or hostname: 1.2.3.4 (IP geändert!)
    
    Checking for IPv6 connectivity...
    
    Your host does not appear to have IPv6 connectivity.
    
    Do you want to enable IPv6 support (NAT)? [y/n]: n
    
    What port do you want OpenVPN to listen to?
       1) Default: 1194
       2) Custom
       3) Random [49152-65535]
    Port choice [1-3]: 1
    
    What protocol do you want OpenVPN to use?
    UDP is faster. Unless it is not available, you shouldn't use TCP.
       1) UDP
       2) TCP
    Protocol [1-2]: 1
    
    What DNS resolvers do you want to use with the VPN?
       1) Current system resolvers (from /etc/resolv.conf)
       2) Self-hosted DNS Resolver (Unbound)
       3) Cloudflare (Anycast: worldwide)
       4) Quad9 (Anycast: worldwide)
       5) Quad9 uncensored (Anycast: worldwide)
       6) FDN (France)
       7) DNS.WATCH (Germany)
       8) OpenDNS (Anycast: worldwide)
       9) Google (Anycast: worldwide)
       10) Yandex Basic (Russia)
       11) AdGuard DNS (Anycast: worldwide)
       12) NextDNS (Anycast: worldwide)
       13) Custom
    DNS [1-12]: 11
    
    Do you want to use compression? It is not recommended since the VORACLE attack makes use of it.
    Enable compression? [y/n]: n
    
    Do you want to customize encryption settings?
    Unless you know what you're doing, you should stick with the default parameters provided by the script.
    Note that whatever you choose, all the choices presented in the script are safe. (Unlike OpenVPN's defaults)
    See https://github.com/angristan/openvpn-install#security-and-encryption to learn more.
    
    Customize encryption settings? [y/n]: n
    
    Okay, that was all I needed. We are ready to setup your OpenVPN server now.
    You will be able to generate a client at the end of the installation.
    Press any key to continue...
    

    Und danach noch eine Client Konfiguration.

    Tell me a name for the client.
    The name must consist of alphanumeric character. It may also include an underscore or a dash.
    Client name: vpnuser
    
    Do you want to protect the configuration file with a password?
    (e.g. encrypt the private key with a password)
       1) Add a passwordless client
       2) Use a password for the client
    Select an option [1-2]: 1
    
    * Using SSL: openssl OpenSSL 3.0.11 19 Sep 2023 (Library: OpenSSL 3.0.11 19 Sep 2023)
    
    * Using Easy-RSA configuration: /etc/openvpn/easy-rsa/vars
    
    * The preferred location for 'vars' is within the PKI folder.
      To silence this message move your 'vars' file to your PKI
      or declare your 'vars' file with option: --vars=<FILE>
    -----
    
    Notice
    ------
    Keypair and certificate request completed. Your files are:
    req: /etc/openvpn/easy-rsa/pki/reqs/vpnuser.req
    key: /etc/openvpn/easy-rsa/pki/private/vpnuser.key
    Using configuration from /etc/openvpn/easy-rsa/pki/0622683e/temp.87511285
    Check that the request matches the signature
    Signature ok
    The Subject's Distinguished Name is as follows
    commonName            :ASN.1 12:'vpnuser'
    Certificate is to be certified until Jun 15 20:08:25 2026 GMT (825 days)
    
    Write out database with 1 new entries
    Database updated
    
    Notice
    ------
    Certificate created at:
    * /etc/openvpn/easy-rsa/pki/issued/vpnuser.crt
    
    Notice
    ------
    Inline file created:
    * /etc/openvpn/easy-rsa/pki/inline/vpnuser.inline
    Client vpnuser added.
    
    The configuration file has been written to /root/vpnuser.ovpn.
    Download the .ovpn file and import it in your OpenVPN client.

    Die Konfigurationsdatei kann nun vom Server unter /root/vpnuser.ovpn runtergeladen und für den OpenVPN Client verwendet werden.

    Man kann mit dem Skript auch weitere Clients erstellen.
    Einfach das Scipt nochmal ausführen:

    ./openvpn-install.sh
    Welcome to OpenVPN-install!
    The git repository is available at: https://github.com/angristan/openvpn-install
    
    It looks like OpenVPN is already installed.
    
    What do you want to do?
       1) Add a new user
       2) Revoke existing user
       3) Remove OpenVPN
       4) Exit

    Wireguard

    Zum installieren von Wireguard gibts ebenfalls ein Skript auf GitHub von angristan.

    Herunterladen und ausführen des Scripts:

    curl -O https://raw.githubusercontent.com/angristan/wireguard-install/master/wireguard-install.sh
    chmod +x wireguard-install.sh
    ./wireguard-install.sh

    Auch hier sind wieder ein paar Eingaben zu machen und man kann diese auch mit Standardwerten duchgehen:

    Welcome to the WireGuard installer!
    The git repository is available at: https://github.com/angristan/wireguard-install
    
    I need to ask you a few questions before starting the setup.
    You can keep the default options and just press enter if you are ok with them.
    
    IPv4 or IPv6 public address: 1.2.3.4
    Public interface: enp2s0
    WireGuard interface name: wg0
    Server WireGuard IPv4: 10.66.66.1
    Server WireGuard IPv6: fd42:42:42::1
    Server WireGuard port [1-65535]: 62520
    First DNS resolver to use for the clients: 1.1.1.1
    Second DNS resolver to use for the clients (optional): 1.0.0.1
    
    WireGuard uses a parameter called AllowedIPs to determine what is routed over the VPN.
    Allowed IPs list for generated clients (leave default to route everything): 0.0.0.0/0,::/0
    
    Okay, that was all I needed. We are ready to setup your WireGuard server now.
    You will be able to generate a client at the end of the installation.

    Und am Ende auch noch eine Client Konfiguration:

    The client name must consist of alphanumeric character(s). It may also include underscores or dashes and can't exceed 15 chars.
    Client name: vpnuser
    Client WireGuard IPv4: 10.66.66.2
    Client WireGuard IPv6: fd42:42:42::2
    
    Here is your client config file as a QR Code:
    
    █████████████████████████████████████████████████████████████████████
    █████████████████████████████████████████████████████████████████████
    ████ ▄▄▄▄▄ █ ▄▄█   ▄ ██▄▄█▄▄█▄▀ ▀  ▄▀██ ▄█▄ ██▀ ▄▄▀▄█▄█  █ ▄▄▄▄▄ ████
    ████ █   █ █ ▀ ▄▄██▀█  ▄▄█  ▀█ ▄█▀▄▄█ █ ▄▄█▀█▀█▄▀   ▀  ▄ █ █   █ ████
    ████ █▄▄▄█ █▀▀█▀██▀▀▄█▀▀▄ ▀  ▄ ▄ ▄▄▄ ▄█▀▀  ▄ █ █▀██▀▄  ▄██ █▄▄▄█ ████
    ████▄▄▄▄▄▄▄█▄█▄▀▄█ █▄█ █ ▀▄█ ▀ ▀ █▄█ ▀▄▀ ▀▄▀ ▀▄█▄▀▄▀ █▄▀▄█▄▄▄▄▄▄▄████
    ████  ▀▀ ▄▄▀▀▀ ██ ▄█▀██ ██ █ ▄▄ ▄ ▄  ▄█ ▄▀▀ ▄ ▀█▄█ ▄▄▄ ▀ ▀▀ █ ▄▄ ████
    ████▄ █▀█▄▄█▄ ▄▀█▀▄▄▄▄█▄▄▀▄  █   ▀▄▄ █▀████▀█▀▄█▀▄██▀   ▄ ▄▄██ █▀████
    █████ ▀▄▄▄▄ █▄█▀█  █▄▄▄ ▄█ ▀▀▀  █▀▀▀▄ ▀▄  ▀▄▀█▄▄██▄ █▄ █▄▀ ▀██▀█▀████
    ████▀▄▀▀▄ ▄▀  ▀ ▄▀█▀▀▀█▀ ▄▄ ▄█  ▀▄ █▄▄▄  ██ █ ▀▄▀▄  ▄█ █  ▀█ █▄ ▄████
    ████▀█▄█ ▄▄▄ ▄ ▄▄▄ ▄██  ████   ▀ ▄█▀▀██▄▄▄  █ ▄ █ █  ▀▀ █▀▄ ▀█ ██████
    ██████ ▀ █▄█   ▀ ▄▀▀   ▀▀ ▄▀▄ ▄▄ ███▀ ▀▀▄▀▄▄ ▄▄ ▄█▀▀██  █▄▀█ ▀▄▀▄████
    ████▀▀▀ ▄▀▄ ▄▀ ██▀▀▀█▄▀  ▄█▀ ▀▀▄█▀▀█ ██ ▀▀█▄█▄   ██ ▀▄██▀██▀▀█▀▀▀████
    ████▄▀▄ ██▄█ ▀▄  ▄▀▀█ ▀ ▀▀▀  █▀█▀ ▄ ▀  ▀█▀▄▀▄▀▄▄███▀▄█▄▄▀ ▄▄▀█ ▄▄████
    ████▄ ▄ █▄▄ ▄ ▀█▄▄▀█▄ █▄▄▄█▀   ▄ ▀    █▄▄▀█▀█ ▀█  ███▄▀██  ▀▄█▄ ▀████
    ████▀ ▀▄ ▄▄▄▀██ ▀▀▄█▀▀██▄▄█▀█▀▄▀▄ █▄ ▄ █▀▀ ▀▀ ▄▄▄▄▄▄▄▀▄▀█ ▄███ █▀████
    ████▄██  ▄▄▄ ▄█▀▀ ▄ ▄▄▄ ██▀  ▀▄█ ▄▄▄ █▄▄██▄ ▄█    ▀█ ▄▀█ ▄▄▄ ▄▀▄█████
    ████ █ ▄ █▄█  ▀█▄ ▀▀▀█▀█▀ ▄ ▀▄▄▀ █▄█ ▄█ ▀▀▄▄██▀▄█ █ ▀█   █▄█ ▄▀ ▀████
    ████▀ ▄▄▄▄▄  ▀█ █▀ ▀▀██▄▀▄ ▀█ █▀ ▄ ▄ ▀▄█▀█▀ ▀▀ ▀█▄█▄ ▀▀█▄▄▄ ▄█ ▄▀████
    ████▀█▀  ▄▄▄█▀▀  ▄ ▄█▀▄▄▀▄█ ▄ ▄ ▄█▀▀▄  ▀  ▄ ▄ █▀▄ ▀▀▀▀▄   ▄▀▀▄ █▀████
    ████▄█▄█ ▄▄▄▀ █▄  ▀▀▄▄▀▀▀ ▀██▀ ▄▀ ▄▀▄ ▀█▄  ▄███ ▄█▀█▀ ██ ██ █▀▀ ▀████
    ████▄██ █▀▄  ▄▀▀▄  █▄▄▀▄▀█▀█▀▀▀ ▀▄▀▀▀▀▄▀▀██▀▀▄ █▀▀█  █▀▀▄ ▀▀▀▄▀ █████
    █████▄▄ █ ▄▄▀▀█ ▄ ▀▀▀█   █▄███▀▀█ ▄█ ▀█▄▄█ ▄   ▀ █▀▀▄█ ▄▄▄█  ▄▄█ ████
    ████ ▀▀▄▀▀▄▀ ▄ ▄█ ▄█▄▀█▄▄ ▀▀  ▀▄███ ▄▄ ▀███▀  ▄██▄▄▀  ▄█    ▀▀ ▀█████
    █████▀▀█▀ ▄▄▀██▄██▀ ▄ ▄▄ ▄█▀ ▄▄▄▀▄▀▀█▄▀█▀▄ █▄ █ █▄██▄   ▀▀▄█▀ ██▄████
    ████▄ █▄▄▀▄▀ ▄ ▄▄ ▄█ ▀█▀ ▄▄█▄▄▄▄▄█▀▄█▄▄ █ █▄█ ▀▄▄ ▀▄▀▄   ▀▀ ██  ▄████
    ████ ▀▀ ▀▄▄ ▄▀  ▀ ▀███ ▄▀███  █████▄ █▀▄▄▀▀▀█▀█ ▄██  ▀ █▀█▀▄ █ ▄▀████
    ████ ▄▄▄▄▄ █▀▀▄██ █▄▄ █▄██▀▄▄█▀▀ █▄█ ▄██▀█ ▀▄▀█▄ ██ █▀▄▄ █▄█ ▄ ▄█████
    ████ █   █ █▄▄    ▄▀ █████▀▀   █      ▄▀  ▀ █  ▄ ▀█▀▀▄▀█▄ ▄ ▄▀▄▄▀████
    ████ █▄▄▄█ █▀▄▀▄█▀▀▄▀ ▀█▄█▀▄ ▄█▀ ▀▀▄ ▄ ▄▀█▀ ▀▀█▄▄▄██ ▀▄ ▄ ▄ ▄▄▄ █████
    ████▄▄▄▄▄▄▄█▄▄▄▄█▄▄█▄▄▄▄█▄▄▄██▄▄█▄▄▄▄█▄▄███▄█▄▄██▄██▄▄▄▄▄███▄█▄▄▄████
    █████████████████████████████████████████████████████████████████████
    █████████████████████████████████████████████████████████████████████
    
    Your client config file is in /root/wg0-client-vpnuser.conf
    If you want to add more clients, you simply need to run this script another time!
    
    WireGuard is running.
    You can check the status of WireGuard with: systemctl status wg-quick@wg0
    
    
    If you don't have internet connectivity from your client, try to reboot the server.

    Das Client Konfig File kann nun auch vom Server unter /root/wg0-client-vpnuser.conf runtergeladen und im Wireguard Client verwendet werden.

    Mit dem Installationsskript kann man nun weitere Client Konfiguationen erstellen:

    ./wireguard-install.sh
    Welcome to WireGuard-install!
    The git repository is available at: https://github.com/angristan/wireguard-install
    
    It looks like WireGuard is already installed.
    
    What do you want to do?
       1) Add a new user
       2) List all users
       3) Revoke existing user
       4) Uninstall WireGuard
       5) Exit

    SOCKS5 Proxy

    Als SOCKS Proxy verwende ich den Dante Socks Server. Ich konfiguriere den Proxy so, das man sich mit Benutzername und Passwort authenfizieren muss.

    Diesen installiert man mit dem Befehl

    sudo apt install dante-server

    Danach editiert man die Datei /etc/danted.conf mit folgenden Inhalt:

    logoutput: /var/log/socks.log
    internal: 0.0.0.0 port = 2408
    external: enp2s0
    socksmethod: username
    user.privileged: root
    user.notprivileged: nobody
    
    client pass {
    from: 0.0.0.0/0 to: 0.0.0.0/0
    log: error connect disconnect
    }
    
    socks pass {
    from: 0.0.0.0/0 to: 0.0.0.0/0
    log: error connect disconnect
    }
    
    socks block {
            from: 0.0.0.0/0 to: lo
            log: connect error
    }
    
    socks block {
     from: 0.0.0.0/0 to: 0.0.0.0/0
     log: connect error
     }

    Achtung! enp2s0 kann auch eine andere Nummer oder zb eth0 lauten.
    Das findet man mit dem Befehl „ip a“ heraus:

    ip a
    1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
        link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
        inet 127.0.0.1/8 scope host lo
           valid_lft forever preferred_lft forever
        inet6 ::1/128 scope host noprefixroute
           valid_lft forever preferred_lft forever
    2: ens6: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq state UP group default qlen 1000
        link/ether 02:01:6c:8b:a9:02 brd ff:ff:ff:ff:ff:ff
        altname enp0s6
        inet 1.2.3.4/32 metric 100 scope global dynamic ens6
           valid_lft 416sec preferred_lft 416sec
        inet6 :1/128 scope global dynamic noprefixroute
           valid_lft 3431sec preferred_lft 2431sec
        inet6 :a902/64 scope link
           valid_lft forever preferred_lft forever

    Danach noch einen Benutze am Betriebssystem anlegen und ein Passwort vergeben:

    useradd socksuser
    passwd socksuser
    Geben Sie ein neues Passwort ein:

    Und starten den SOCKS5 Server Dienst:

    systemctl start danted.service

    SQUID Proxy Server

    Den guten alten SQUID Proxy verwende ich ebenfall nur mit Benutzer und Passwort authentifizierung.
    Installiert wird Squid mit dem Befehl:

    apt-get install squid

    Die Konfigurationsdatei /etc/squid/squid.conf sieht zb. so aus.

    cache_dir ufs /var/spool/squid 2000 16 256
    httpd_suppress_version_string on
    acl QUERY urlpath_regex cgi_bin \?
    auth_param basic program /usr/lib/squid/basic_ncsa_auth /etc/squid/passwords
    auth_param basic realm Squid proxy-caching web server
    auth_param basic credentialsttl 24 hours
    auth_param basic casesensitive off
    acl authenticated proxy_auth REQUIRED
    http_access allow authenticated
    http_access deny all
    forwarded_for delete
    via off
    http_port 3128
    cache deny QUERY
    cache_mem 100 MB

    Für die Benutzerauthentifierung muss man noch das „passwords“ File anlegen.
    Dafür benötigt man den Befehl „htpasswd“. Wenn dieser nicht installiert ist muss man mit

    apt-get install apache2-utils

    die HTTP Tools installieren.
    Das password file legt man mit diesem Befehl an:

    htpasswd -c /etc/squid/passwords username

    Danach Squid noch starten mit:

    systemctl start squid.service

    IONOS Firewall

    Damit man von extern auch auf die ensprechend Ports am VPS kommt, muss man bei IONOS die Ports in der Firewall noch öffnen.
    Das findet man im IONOS Kundenbereich unter Server & Cloud und seinem VPS > Netzwerk
    Sieht dann etwa so aus

    Firewall

    Es müssten die Ports

    TCP
    2408
    3128
    
    UDP
    51820
    1194

    hinzugefügt werden.

    Fazit

    Wenn alles richtig läuft hat man jetzt seinen eigenen VPN / Proxy Server in der Region, den man beim bestellen des IONOS VPS ausgewählt hat.
    Natürlich kann man diesen auch mit Freunden und Familie teilen, einen VPN Anbieter Betrieb würde ich mit Servern mit nur 1 vCPU und 1 GB RAM aber nicht gründen. 😉
    Dies ist auch nur ein Beispiel, was man mit dem Server machen kann. Für einen Webserver mit MySQL wird e smit 1 GB RAM wáber wohl etwas eng. Aber zum ausprobieren und rumspielen was so möglich wäre ist es super und günstig.

    Hinweis: Die Links zu IONOS sind Partnerlinks.

    Schreibe einen Kommentar

    Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert