Aktuelles
Digital Eliteboard - Das Digitale Technik Forum

Registriere dich noch heute kostenlos, um Mitglied zu werden! Sobald du angemeldet bist, kannst du auf unserer Seite aktiv teilnehmen, indem du deine eigenen Themen und Beiträge erstellst und dich über deinen eigenen Posteingang mit anderen Mitgliedern unterhalten kannst! Zudem bekommst du Zutritt zu Bereichen, welche für Gäste verwehrt bleiben

Registriere dich noch heute kostenlos, um Mitglied zu werden! Sobald du angemeldet bist, kannst du auf unserer Seite aktiv teilnehmen, indem du deine eigenen Themen und Beiträge erstellst und dich über deinen eigenen Posteingang mit anderen Mitgliedern unterhalten kannst! Zudem bekommst du Zutritt zu Bereichen, welche für Gäste verwehrt bleiben

Eigenen VPN Server mit Wireguard einrichten

Die configs werden jetzt im Userverzeichnis abgelegt da es in /opt als user Probleme gab.
mv "wgclient_client$i.conf" "$USER_HOME/client$i.conf"

Das werde ich noch ändern.
Danke für den Hinweis.


Erl. sollte jetzt passen und alle configs und QR Codes sind auch in /etc/wireguard
 
Zuletzt bearbeitet:
Erstmal vielen Dank für das tolle Skript, was mir wirklich viel Zeit erspart hat.

Bei mir hat das mit der Verbindung vom VPS zurück ins Heimnetz auch nicht gut geklappt.
Es ging sogar mal für ein paar Stunden und dann war es wieder weg.
Vielleicht hatte ich eine Route irgendwo richtig eingetragen und dann nicht so gesichert, dass sie nach dem Neustart wieder erstellt wird.

Ich hab es jedenfalls nicht mehr hinbekommen.
Aber egal, ich habe für mich bzw. meine Anforderung einen anderen Weg gefunden, der vielleicht auch für andere passt und den ich hier gerne teilen möchte.


Hintergrund:

Ich habe Portals auf meinem Homeserver laufen und die Streams sollen dann über den VPS gehen.
Also muss der Player erst Portals im Heimnetz abrufen können und erst dann in den Tunnel gehen und den Stream verbinden.

Lösung:

Split Tunneling!
Ich lasse alle Anfragen über den Tunnel laufen, außer die für mein Heimnetz.
Man kann das bei "AllowedIPs" eintragen. Und man braucht es nur beim Client machen.

Ich hab mir etwas von ChatGPT helfen lassen, welche IPs genau dort stehen müssen, wenn mein Heimnetz nicht inbegriffen sein soll.
Denn die Anfragen gehen ja nur durch den Tunnel, wenn es für den Client auch erlaubt ist. Was dort nicht steht, wird nicht über den Tunnel connected.

Für mein Heimnetz 192.168.1.0/24 war es dann

AllowedIPs =
0.0.0.0/1,
128.0.0.0/2,
192.0.0.0/9,
192.128.0.0/11,
192.160.0.0/13,
192.168.0.0/24,
192.168.2.0/23,
192.168.4.0/22,
192.168.8.0/21,
192.168.16.0/20,
192.168.32.0/19,
192.168.64.0/18,
192.168.128.0/17,
193.0.0.0/8,
194.0.0.0/7,
196.0.0.0/6,
200.0.0.0/5,
208.0.0.0/4
 
Kann mann denn ein webif drüber installieren der die jetztigen configs mit einbezieht ?
So das man user einfacher hinzu bzw löschen kann ?
Finde es immer etwas umständlich mit ssh auf den server zu connecten und dort user anzu legen oder zu löschen .

Besten dank im voraus
 
Hi Osprey. Ich wollte Dein Script gerade auf einem frischen IONOS VPS testen, aber es läuft nicht durch.

Das Script wird geladen und ich kann es starten.
Es werden ein paar Pakete geladen, dann steigt es einfach aus.

WireGuard und auch die Tools werden nicht installiert.

Kannst Du das bitte nochmal überprüfen?

Danke und Gruß
szonic
 
Habe ich probiert, bis zu dem Punkt, wo er die Schleife beim anlegen der User dreht, da war ich dann raus.
 
Na klar, sehr gerne.
Ich hoffe Du findest mein Problem... Ich denke es hängt an den wg-tools
Code:
 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/pro

 System information as of Sun Sep 14 08:55:40 UTC 2025

  System load:  0.0               Processes:             99
  Usage of /:   23.8% of 8.65GB   Users logged in:       0
  Memory usage: 27%               IPv4 address for ens6: 217.154.18.103
  Swap usage:   0%


Expanded Security Maintenance for Applications is not enabled.

3 updates can be applied immediately.
To see these additional updates run: apt list --upgradable

Enable ESM Apps to receive additional future security updates.
See https://ubuntu.com/esm or run: sudo pro status


root@ubuntu:~# sudo wget https://neutrinobox.de/wireguard.sh
--2025-09-14 08:55:46--  https://neutrinobox.de/wireguard.sh
Resolving neutrinobox.de (neutrinobox.de)... 104.21.47.15, 172.67.143.162, 2606:4700:3035::ac43:8fa2, ...
Connecting to neutrinobox.de (neutrinobox.de)|104.21.47.15|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2309 (2.3K) [application/octet-stream]
Saving to: ‘wireguard.sh’

wireguard.sh        100%[===================>]   2.25K  --.-KB/s    in 0s

2025-09-14 08:55:46 (50.6 MB/s) - ‘wireguard.sh’ saved [2309/2309]

root@ubuntu:~# sudo bash wireguard.sh
Hit:1 http://archive.ubuntu.com/ubuntu noble InRelease
Get:2 http://archive.ubuntu.com/ubuntu noble-updates InRelease [126 kB]
Get:3 http://security.ubuntu.com/ubuntu noble-security InRelease [126 kB]
Get:4 http://archive.ubuntu.com/ubuntu noble-backports InRelease [126 kB]
Get:5 http://archive.ubuntu.com/ubuntu noble-updates/main amd64 Packages [1389 kB]
Get:6 http://archive.ubuntu.com/ubuntu noble-updates/main amd64 Components [175 kB]
Get:7 http://archive.ubuntu.com/ubuntu noble-updates/universe amd64 Packages [1483 kB]
Get:8 http://archive.ubuntu.com/ubuntu noble-updates/universe amd64 Components [377 kB]
Get:9 http://archive.ubuntu.com/ubuntu noble-updates/restricted amd64 Components [212 B]
Get:10 http://archive.ubuntu.com/ubuntu noble-updates/multiverse amd64 Components [940 B]
Get:11 http://archive.ubuntu.com/ubuntu noble-backports/main amd64 Components [7056 B]
Get:12 http://archive.ubuntu.com/ubuntu noble-backports/universe amd64 Components [19.2 kB]
Get:13 http://archive.ubuntu.com/ubuntu noble-backports/restricted amd64 Components [216 B]
Get:14 http://archive.ubuntu.com/ubuntu noble-backports/multiverse amd64 Components [212 B]
Get:15 http://security.ubuntu.com/ubuntu noble-security/main amd64 Components [21.5 kB]
Get:16 http://security.ubuntu.com/ubuntu noble-security/universe amd64 Components [52.3 kB]
Get:17 http://security.ubuntu.com/ubuntu noble-security/restricted amd64 Components [212 B]
Get:18 http://security.ubuntu.com/ubuntu noble-security/multiverse amd64 Components [212 B]
Fetched 3905 kB in 1s (2771 kB/s)
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
3 packages can be upgraded. Run 'apt list --upgradable' to see them.
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
systemd-resolved is already the newest version (255.4-1ubuntu8.10).
systemd-resolved set to manually installed.
mawk is already the newest version (1.3.4.20240123-1build1).
mawk set to manually installed.
grep is already the newest version (3.11-4build1).
iproute2 is already the newest version (6.1.0-1ubuntu6.2).
iproute2 set to manually installed.
The following additional packages will be installed:
  libqrencode4 netfilter-persistent
The following packages will be REMOVED:
  ufw
The following NEW packages will be installed:
  iptables-persistent libqrencode4 net-tools netfilter-persistent qrencode
  wireguard wireguard-tools
0 upgraded, 7 newly installed, 1 to remove and 3 not upgraded.
Need to get 362 kB of archives.
After this operation, 515 kB of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu noble/universe amd64 netfilter-persistent all 1.0.20 [7402 B]
Get:2 http://archive.ubuntu.com/ubuntu noble/universe amd64 iptables-persistent all 1.0.20 [6946 B]
Get:3 http://archive.ubuntu.com/ubuntu noble/universe amd64 libqrencode4 amd64 4.1.1-1build2 [25.0 kB]
Get:4 http://archive.ubuntu.com/ubuntu noble-updates/main amd64 net-tools amd64 2.10-0.1ubuntu4.4 [204 kB]
Get:5 http://archive.ubuntu.com/ubuntu noble/universe amd64 qrencode amd64 4.1.1-1build2 [26.1 kB]
Get:6 http://archive.ubuntu.com/ubuntu noble/main amd64 wireguard-tools amd64 1.0.20210914-1ubuntu4 [89.1 kB]
Get:7 http://archive.ubuntu.com/ubuntu noble/universe amd64 wireguard all 1.0.20210914-1ubuntu4 [3086 B]
Fetched 362 kB in 1s (575 kB/s)
Preconfiguring packages ...
(Reading database ... 106396 files and directories currently installed.)
Removing ufw (0.36.2-6) ...
Skip stopping firewall: ufw (not enabled)
Selecting previously unselected package netfilter-persistent.
(Reading database ... 106301 files and directories currently installed.)
Preparing to unpack .../0-netfilter-persistent_1.0.20_all.deb ...
Unpacking netfilter-persistent (1.0.20) ...
Selecting previously unselected package iptables-persistent.
Preparing to unpack .../1-iptables-persistent_1.0.20_all.deb ...
Unpacking iptables-persistent (1.0.20) ...
Selecting previously unselected package libqrencode4:amd64.
Preparing to unpack .../2-libqrencode4_4.1.1-1build2_amd64.deb ...
Unpacking libqrencode4:amd64 (4.1.1-1build2) ...
Selecting previously unselected package net-tools.
Preparing to unpack .../3-net-tools_2.10-0.1ubuntu4.4_amd64.deb ...
Unpacking net-tools (2.10-0.1ubuntu4.4) ...
Selecting previously unselected package qrencode.
Preparing to unpack .../4-qrencode_4.1.1-1build2_amd64.deb ...
Unpacking qrencode (4.1.1-1build2) ...
Selecting previously unselected package wireguard-tools.
Preparing to unpack .../5-wireguard-tools_1.0.20210914-1ubuntu4_amd64.deb ...
Unpacking wireguard-tools (1.0.20210914-1ubuntu4) ...
Selecting previously unselected package wireguard.
Preparing to unpack .../6-wireguard_1.0.20210914-1ubuntu4_all.deb ...
Unpacking wireguard (1.0.20210914-1ubuntu4) ...
Setting up net-tools (2.10-0.1ubuntu4.4) ...
Setting up libqrencode4:amd64 (4.1.1-1build2) ...
Setting up qrencode (4.1.1-1build2) ...
Setting up wireguard-tools (1.0.20210914-1ubuntu4) ...
wg-quick.target is a disabled or a static unit, not starting it.
Setting up netfilter-persistent (1.0.20) ...
Created symlink /etc/systemd/system/iptables.service → /usr/lib/systemd/system/netfilter-persistent.service.
Created symlink /etc/systemd/system/ip6tables.service → /usr/lib/systemd/system/netfilter-persistent.service.
Created symlink /etc/systemd/system/multi-user.target.wants/netfilter-persistent.service → /usr/lib/systemd/system/netfilter-persistent.service.
Setting up wireguard (1.0.20210914-1ubuntu4) ...
Setting up iptables-persistent (1.0.20) ...
Processing triggers for man-db (2.12.0-4build2) ...
Processing triggers for libc-bin (2.39-0ubuntu8.5) ...
Scanning processes...
Scanning linux images...

Running kernel seems to be up-to-date.

No services need to be restarted.

No containers need to be restarted.

No user sessions are running outdated binaries.

No VM guests are running outdated hypervisor (qemu) binaries on this host.
wireguard
Created symlink /etc/systemd/system/multi-user.target.wants/wg-quick@wg0.service → /usr/lib/systemd/system/wg-quick@.service.
root@ubuntu:~#

EDIT:
Jetzt wollte ich das Terminal mit EXIT verlassen und plötzlich lief das script weiter...was ist da los?
Es wurden jetzt die codes erstellt und es scheint alles da zu sein... das gibts nicht.
Warum steigt das script da aus und läuft auf "exit" weiter?


Code:
No VM guests are running outdated hypervisor (qemu) binaries on this host.
wireguard
Created symlink /etc/systemd/system/multi-user.target.wants/wg-quick@wg0.service → /usr/lib/systemd/system/wg-quick@.service.
root@ubuntu:~# ^C
root@ubuntu:~# exit
logout
--2025-09-14 09:18:26--  https://neutrinobox.de/easy-wg-quick
Resolving neutrinobox.de (neutrinobox.de)... 104.21.47.15, 172.67.143.162, 2606:4700:3035::6815:2f0f, ...
Connecting to neutrinobox.de (neutrinobox.de)|104.21.47.15|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 16406 (16K) [application/octet-stream]
Saving to: ‘easy-wg-quick’

easy-wg-quick       100%[===================>]  16.02K  --.-KB/s    in 0s

2025-09-14 09:18:26 (73.1 MB/s) - ‘easy-wg-quick’ saved [16406/16406]

No extnetif.txt... creating one!
No extnetip.txt... creating one!
No intnetmask.txt... creating one!
No intnetdns.txt... creating one!
No intnetaddress.txt... creating one!
No intnetallowedips.txt... creating one!
No fwtype.txt... creating one!
No sysctltype.txt... creating one!
No seqno.txt... creating one!
No portno.txt... creating one!
No wgpsk.key... creating one!
No wghub.key... creating one!
No wghub.conf... creating one!
Wireguard hub address is xxxxxxxxxxxx:xxxxxx on ens6.
Note: customize [Interface] section of wghub.conf if required!
No wgclient_client1.conf... creating one!
No wgclient_client1.uci.txt... creating one!


Code:
Important: Deploy updated wghub.conf configuration to wireguard with wg-quick:
  sudo wg-quick down ./wghub.conf # if already configured
  sudo wg-quick up ./wghub.conf
  sudo wg show # to check status
net.ipv4.ip_forward = 1
net.ipv6.conf.all.forwarding = 1
run-parts: executing /usr/share/netfilter-persistent/plugins.d/15-ip4tables save
run-parts: executing /usr/share/netfilter-persistent/plugins.d/25-ip6tables save
Das ist der UDP-Port, der geöffnet werden muss:
  listening port: 16748
root@ubuntu:~# Created symlink /etc/systemd/system/multi-user.target.wants/wg-quick@wg0.service → /usr/lib/systemd/system/wg-quick@.service.
root@ubuntu:~# ^C
root@ubuntu:~# exit
logout
--2025-09-14 09:18:26--  https://neutrinobox.de/easy-wg-quick
Resolving neutrinobox.de (neutrinobox.de)... 104.21.47.15, 172.67.143.162, 2606:4700:3035::6815:2f0f, ...
Connecting to neutrinobox.de (neutrinobox.de)|104.21.47.15|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 16406 (16K) [application/octet-stream]
Saving to: ‘easy-wg-quick’

easy-wg-quick       100%[===================>]  16.02K  --.-KB/s    in 0s

2025-09-14 09:18:26 (73.1 MB/s) - ‘easy-wg-quick’ saved [16406/16406]

No extnetif.txt... creating one!
No extnetip.txt... creating one!
No intnetmask.txt... creating one!
No intnetdns.txt... creating one!
No intnetaddress.txt... creating one!
No intnetallowedips.txt... creating one!
No fwtype.txt... creating one!
No sysctltype.txt... creating one!
No seqno.txt... creating one!
No portno.txt... creating one!
No wgpsk.key... creating one!
No wghub.key... creating one!
No wghub.conf... creating one!
Wireguard hub address is xxxxxxx:xxxx on ens6.
Note: customize [Interface] section of wghub.conf if required!
No wgclient_client1.conf... creating one!
 
Zuletzt bearbeitet:
Kann dir leider nicht sagen was da passiert ist. Normalerweise nach einem exit wird das Terminal geschlossen und nix geht mehr.
 
Zurück
Oben