Page 1 of 1
WireGuard Server und KeyHelp Firewall
Posted: Wed 26. Jul 2023, 10:30
by tbongo
Hallo liebes Forum,
ich habe auf meinem Server mit KeyHelp 23.1.1 und Ubuntu 20.04 WireGuard installiert und den UDP Port 51820 in der Firewall Administration in KeyHelp im eingehenden Traffic erlaubt.
Der ausgehende Traffic ist komplett erlaubt.
Wenn die Firewall aktiv ist, kann ich mich per WireGuard Client mit dem KeyHelp Server verbinden, aber ich habe nicht wirklich eine Internetverbindung (auch der Ping geht nicht).
Wenn ich die Firewall deaktiviere klappt alles wie erwartet.
Ich habe mittlerweile den Port 51820 (den ich auch ganz sicher in der WireGuard Konfiguration benutze) mittlerweile in der Firewall in allen drei Punkten hinzugefügt und sowohl TCP als auch UDP aktiviert. Irgendwas blockiert weiterhin die VPN Verbindung.
Hat jemand einen Tipp was ich machen kann, in welche Logdatei ich schauen kann?
Vielen Dank,
Tobias
Re: WireGuard Server und KeyHelp Firewall
Posted: Wed 26. Jul 2023, 11:05
by Jolinar
tbongo wrote: ↑Wed 26. Jul 2023, 10:30
Hat jemand einen Tipp was ich machen kann, in welche Logdatei ich schauen kann?
Erste Anlaufstellen wären folgende Logs:
/var/log/syslog
/var/log/kern.log
Hast du auch IPv6 berücksichtigt?
Re: WireGuard Server und KeyHelp Firewall
Posted: Thu 27. Jul 2023, 09:29
by tbongo
Hallo Jolinar,
vielen Dank für deine Antwort.
Leider wird in den beiden Logdateien nichts passendes geloggt wenn ich die Verbindung mit WireGuard herstelle.
Auch IPv6 habe ich hier am Client nicht aktiviert und darum denke ich, dass das nicht die Ursache sein kann, oder? In der Firewall Oberfläche kann ich ja auch nicht zwischen IPv4 und IPv6 Traffic unterscheiden.
Re: WireGuard Server und KeyHelp Firewall
Posted: Thu 27. Jul 2023, 09:34
by tbongo
Das hier sind meine iptable Rules.
Code: Select all
Chain INPUT (policy DROP)
target prot opt source destination
ACCEPT all -- anywhere anywhere state RELATED,ESTABLISHED
DROP all -- anywhere anywhere state INVALID
DROP tcp -- anywhere anywhere tcp flags:FIN,SYN,RST,PSH,ACK,URG/NONE
DROP tcp -- anywhere anywhere tcp flags:FIN,SYN,RST,PSH,ACK,URG/FIN,SYN,RST,PSH,ACK,URG
DROP tcp -- anywhere anywhere tcp flags:!FIN,SYN,RST,ACK/SYN state NEW
DROP tcp -- anywhere anywhere tcp flags:FIN,SYN/FIN,SYN
DROP tcp -- anywhere anywhere tcp flags:SYN,RST/SYN,RST
DROP all -- localhost/8 anywhere
ACCEPT all -- anywhere anywhere
ACCEPT tcp -- anywhere anywhere tcp dpt:51820
ACCEPT udp -- anywhere anywhere udp dpt:51820
ACCEPT tcp -- anywhere anywhere tcp dpt:ssh
ACCEPT tcp -- anywhere anywhere tcp dpt:domain
ACCEPT udp -- anywhere anywhere udp dpt:domain
ACCEPT tcp -- anywhere anywhere tcp dpt:http
ACCEPT tcp -- anywhere anywhere tcp dpt:https
ACCEPT tcp -- anywhere anywhere tcp dpt:pop3
ACCEPT tcp -- anywhere anywhere tcp dpt:pop3s
ACCEPT tcp -- anywhere anywhere tcp dpt:imap2
ACCEPT tcp -- anywhere anywhere tcp dpt:imaps
ACCEPT tcp -- anywhere anywhere tcp dpt:smtp
ACCEPT tcp -- anywhere anywhere tcp dpt:submissions
ACCEPT tcp -- anywhere anywhere tcp dpt:submission
DROP tcp -- anywhere anywhere tcp dpt:mysql
ACCEPT tcp -- anywhere anywhere tcp dpt:1935
ACCEPT tcp -- anywhere anywhere tcp dpt:http-alt
ACCEPT tcp -- anywhere anywhere tcp dpt:ftp-data
ACCEPT tcp -- anywhere anywhere tcp dpt:ftp
ACCEPT tcp -- anywhere anywhere tcp dpts:30000:30500
ACCEPT icmp -- anywhere anywhere icmptype 8 code 0
ACCEPT icmp -- anywhere anywhere icmp any limit: avg 10/sec burst 20
DROP icmp -- anywhere anywhere icmp any
Chain FORWARD (policy DROP)
target prot opt source destination
ACCEPT all -- anywhere anywhere state RELATED,ESTABLISHED
DROP all -- localhost/8 anywhere
ACCEPT all -- anywhere anywhere
ACCEPT tcp -- anywhere anywhere tcp dpt:51820
ACCEPT udp -- anywhere anywhere udp dpt:51820
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
ACCEPT all -- anywhere anywhere state RELATED,ESTABLISHED
ACCEPT all -- anywhere anywhere
ACCEPT tcp -- anywhere anywhere tcp dpt:51820
ACCEPT udp -- anywhere anywhere udp dpt:51820
Der Port 51820 ist überall freigegeben (auch zusätzlich für TCP zum sicher gehen).
Ist dort ein Fehler den ich nicht sehe?
Vielen Dank,
Tobias
Re: WireGuard Server und KeyHelp Firewall
Posted: Thu 27. Jul 2023, 09:40
by Florian
Hi,
ich nutze Wireguard nicht aber brauchts dafür nicht eh noch mehr Einträge in der NAT Tabelle, FORWARD Rules usw. Der Traffic muss ja auch entsprechend geroutet werden.
Ich würde da nicht das Keyhelp Modul nutzen für IPTables, sondern die Regeln selbst erstellen.
Re: WireGuard Server und KeyHelp Firewall
Posted: Thu 27. Jul 2023, 14:12
by Ralph
Florian wrote: ↑Thu 27. Jul 2023, 09:40
Hi,
ich nutze Wireguard nicht aber brauchts dafür nicht eh noch mehr Einträge in der NAT Tabelle, FORWARD Rules usw. Der Traffic muss ja auch entsprechend geroutet werden.
Ich würde da nicht das Keyhelp Modul nutzen für IPTables, sondern die Regeln selbst erstellen.
das benötigt u.a. auch eigene Ports für's GUI (sind ja von Apache belegt) und einige andere Dinge
Wireguard ist für eine shared Hosting Umgebung nicht geeignet und muß als eigenständiges System installiert werden.
Re: WireGuard Server und KeyHelp Firewall
Posted: Sun 15. Oct 2023, 07:04
by PadMan
Ralph wrote: ↑Thu 27. Jul 2023, 14:12Wireguard ist für eine shared Hosting Umgebung nicht geeignet und muß als eigenständiges System installiert werden.
Oder es würde demnächst kompatibel gemacht werden
Es wäre einerseits schön, wenn WireGuard irgendwie mit KH auf Wunsch integriert werden könnte, damit man via WireGuard zum Beispiel sich darüber per SSH verbinden könnte und auch über die UI mit verwaltet werden könnte und das bei Bedarf der offene SSH-Port für außen zu gemacht werden könnte, somit wäre es eigentlich dichter

nur käme man in einem Falle eines Falles nicht ohne weiteres auf dem Server, sofern SSH noch funktioniert, es sei denn, man käme anderweitig, ohne das SSH benötigt wird, drauf
Von einem Script wurde folgendes in der
wg0.conf abgelegt, wobei gerade mit der FW bzw. mit der Weiterleitung Probleme gibt...
eth0 müsste ggf. sofern der Name der Netzwerkkarte nicht übereinstimmt, umbenannt werden

Der Port wurde vom ersten Post hier übernommen
Code: Select all
PostUp = iptables -I INPUT -p udp --dport 51820 -j ACCEPT
PostUp = iptables -I FORWARD -i eth0 -o wg0 -j ACCEPT
PostUp = iptables -I FORWARD -i wg0 -j ACCEPT
PostUp = iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
PostUp = ip6tables -I FORWARD -i wg0 -j ACCEPT
PostUp = ip6tables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
PostDown = iptables -D INPUT -p udp --dport 51820 -j ACCEPT
PostDown = iptables -D FORWARD -i eth0 -o wg0 -j ACCEPT
PostDown = iptables -D FORWARD -i wg0 -j ACCEPT
PostDown = iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE
PostDown = ip6tables -D FORWARD -i wg0 -j ACCEPT
PostDown = ip6tables -t nat -D POSTROUTING -o eth0 -j MASQUERADE