Firewall mit nftables

For topics beyond KeyHelp. / Für Themen jenseits von KeyHelp.
Post Reply
WebLive
Posts: 9
Joined: Fri 30. Mar 2018, 10:43

Firewall mit nftables

Post by WebLive »

Hallo,
hat jemand von euch eine Firewall mit nftables erstellt?

Ich probiere es gerade und so sieht es bisher aus:

Code: Select all

#!/usr/sbin/nft -f

flush ruleset

table ip filter {
    chain input {
        type filter hook input priority 0; policy drop;
		ct state { established, related } accept
		ct state invalid drop
		iifname lo accept
		tcp dport { ftp, ftp-data, ftps, ftps-data } accept comment "FTP-Server"
		tcp dport ssh limit rate 3/minute accept comment "SSH"
		tcp dport { http, https } accept comment "Webserver"
		tcp dport { smtp, submission, imaps, pop3s } accept comment "Mailserver"
		tcp dport domain accept comment "DNS-Server"
		udp dport domain accept comment "DNS-Server"
		udp dport ntp accept comment "NTP"
		icmp type { echo-request, echo-reply, destination-unreachable, time-exceeded } limit rate 7/second accept comment "ICMP"
		icmp type { echo-request, echo-reply, destination-unreachable, time-exceeded } counter drop comment "ICMP-Drop"
		tcp flags & ( fin | syn | rst | ack ) == syn drop
		counter drop;
	}
	chain forward {
		type filter hook forward priority 0; policy drop;
	}
	chain output {
		type filter hook output priority 0; policy accept;
	}
}

include "/etc/nftables/fail2ban.conf"
Nur habe ich das problem das FTP nicht geht solange die Firewall altiviert ist, unabhängig von dem was in der "nftables.conf" steht.
Muß man noch irgenwelche Kernel-Module laden und wie?

lsmod | grep ^nf gibt folgendes aus:

Code: Select all

nf_log_ipv4            16384  0
nf_log_common          16384  1 nf_log_ipv4
nft_log                16384  0
nft_limit              16384  2
nft_ct                 20480  3
nf_conntrack          172032  1 nft_ct
nf_defrag_ipv6         20480  1 nf_conntrack
nf_defrag_ipv4         16384  1 nf_conntrack
nf_tables_set          32768  7
nf_reject_ipv4         16384  1 ipt_REJECT
nft_compat             20480  0
nft_counter            16384  3
nf_tables             143360  73 nft_ct,nft_compat,nft_log,nft_counter,nft_limit,nf_tables_set
nfnetlink              16384  2 nft_compat,nf_tables
Hat da jemand eine Idee?

Grüße
WebLive

[Mod-Edit]
Thread nach Off Topic verschoben, da der Topic erstmal nichts mit Keyhelp zu tun hat.
Last edited by Jolinar on Mon 16. Dec 2019, 18:02, edited 1 time in total.
Reason: Mod-Edit
User avatar
Jolinar
Community Moderator
Posts: 3595
Joined: Sat 30. Jan 2016, 07:11
Location: Weimar (Thüringen)
Contact:

Re: Firewall mit nftables

Post by Jolinar »

Was sagen die relevanten Logfiles?
Wenn jemand inkompetent ist, dann kann er nicht wissen, daß er inkompetent ist. (David Dunning)

Data Collector für Community Support
___
Ich verwende zwei verschiedene Schriftfarben in meinen Beiträgen /
I use two different font colors in my posts:
  • In dieser Farbe schreibe ich als Moderator und gebe moderative Hinweise oder begründe moderative Eingriffe /
    In this color, I write as a moderator and provide moderative guidance or justify moderative interventions
  • In dieser Farbe schreibe ich als Community Mitglied und teile meine private Meinung und persönlichen Ansichten mit /
    In this color, I write as a community member and share my personal opinions and views
WebLive
Posts: 9
Joined: Fri 30. Mar 2018, 10:43

Re: Firewall mit nftables

Post by WebLive »

Versuch mit FileZilla:

Code: Select all

Status:	Auflösen der IP-Adresse für srv.meinserver.de
Status:	Verbinde mit xx.xx.xx.111:21...
Status:	Verbindung hergestellt, warte auf Willkommensnachricht...
Status:	Initialisiere TLS...
Status:	Überprüfe Zertifikat...
Status:	TLS-Verbindung hergestellt.
Status:	Der Server unterstützt keine Nicht-ASCII-Zeichen.
Status:	Angemeldet
Status:	Empfange Verzeichnisinhalt...
Befehl:	PWD
Antwort:	257 "/" is the current directory
Befehl:	TYPE I
Antwort:	200 Type set to I
Befehl:	PASV
Antwort:	227 Entering Passive Mode (xx,xx,xx,111,119,34).
Befehl:	LIST
Fehler:	Die Datenverbindung konnte nicht hergestellt werden: ETIMEDOUT - Zeitüberschreitung bei Verbindungsversuch
tls.log

Code: Select all

2019-12-16 19:04:57,846 mod_tls/2.7[23288]: TLS/TLS-C requested, starting TLS handshake
2019-12-16 19:04:57,959 mod_tls/2.7[23288]: TLSv1.3 connection accepted, using cipher TLS_AES_256_GCM_SHA384 (256 bits)
2019-12-16 19:05:00,596 mod_tls/2.7[23288]: Protection set to Private
Versuch mit WinSCP:

Code: Select all

Zeit abgelaufen (Datenverbindung)
Konnte Verzeichnisinhalt nicht abrufen
Fehler beim Anzeigen des Verzeichnisses '/'.
tls.log

Code: Select all

2019-12-16 19:13:05,181 mod_tls/2.7[23619]: TLS/TLS-C requested, starting TLS handshake
2019-12-16 19:13:05,561 mod_tls/2.7[23619]: client supports secure renegotiations
2019-12-16 19:13:05,561 mod_tls/2.7[23619]: TLSv1.2 connection accepted, using cipher ECDHE-RSA-AES256-GCM-SHA384 (256 bits)
2019-12-16 19:13:08,993 mod_tls/2.7[23619]: Protection set to Private
proftpd.log:

Code: Select all

2019-12-16 19:11:12,162 srv.meinserver.de proftpd[23216] srv.meinserver.de (HSI-KBW-046-005-228-065.hsi8.kabel-badenwuerttemberg.de[46.5.228.65]): Data transfer stall timeout: 600 seconds
2019-12-16 19:15:01,020 srv.meinserver.de proftpd[23288] srv.meinserver.de (HSI-KBW-046-005-228-065.hsi8.kabel-badenwuerttemberg.de[46.5.228.65]): Data transfer stall timeout: 600 seconds
Sonstige Fehlermeldungen habe ich nicht gefunden.
Last edited by WebLive on Mon 16. Dec 2019, 19:26, edited 1 time in total.
User avatar
Jolinar
Community Moderator
Posts: 3595
Joined: Sat 30. Jan 2016, 07:11
Location: Weimar (Thüringen)
Contact:

Re: Firewall mit nftables

Post by Jolinar »

WebLive wrote: Mon 16. Dec 2019, 18:25

Code: Select all

Passive data transfer failed, possibly due to network issues
Damit läßt es sich schon etwas eingrenzen.

Jetzt bitte noch die Ausgabe von:

Code: Select all

lsmod | grep ftp
Wenn jemand inkompetent ist, dann kann er nicht wissen, daß er inkompetent ist. (David Dunning)

Data Collector für Community Support
___
Ich verwende zwei verschiedene Schriftfarben in meinen Beiträgen /
I use two different font colors in my posts:
  • In dieser Farbe schreibe ich als Moderator und gebe moderative Hinweise oder begründe moderative Eingriffe /
    In this color, I write as a moderator and provide moderative guidance or justify moderative interventions
  • In dieser Farbe schreibe ich als Community Mitglied und teile meine private Meinung und persönlichen Ansichten mit /
    In this color, I write as a community member and share my personal opinions and views
WebLive
Posts: 9
Joined: Fri 30. Mar 2018, 10:43

Re: Firewall mit nftables

Post by WebLive »

Mit "lsmod | grep ftp" keine Ausgabe.
User avatar
Jolinar
Community Moderator
Posts: 3595
Joined: Sat 30. Jan 2016, 07:11
Location: Weimar (Thüringen)
Contact:

Re: Firewall mit nftables

Post by Jolinar »

WebLive wrote: Mon 16. Dec 2019, 19:28 Mit "lsmod | grep ftp" keine Ausgabe.
Okay.
Dann gib mal am CLI folgende Befehle ein:

Code: Select all

modprobe nf_conntrack_ftp
echo 1 > /proc/sys/net/netfilter/nf_conntrack_helper
und versuche jetzt nochmal, per FTP zu connecten.
Wenn jemand inkompetent ist, dann kann er nicht wissen, daß er inkompetent ist. (David Dunning)

Data Collector für Community Support
___
Ich verwende zwei verschiedene Schriftfarben in meinen Beiträgen /
I use two different font colors in my posts:
  • In dieser Farbe schreibe ich als Moderator und gebe moderative Hinweise oder begründe moderative Eingriffe /
    In this color, I write as a moderator and provide moderative guidance or justify moderative interventions
  • In dieser Farbe schreibe ich als Community Mitglied und teile meine private Meinung und persönlichen Ansichten mit /
    In this color, I write as a community member and share my personal opinions and views
WebLive
Posts: 9
Joined: Fri 30. Mar 2018, 10:43

Re: Firewall mit nftables

Post by WebLive »

Leider immer noch das gleiche ...
User avatar
Jolinar
Community Moderator
Posts: 3595
Joined: Sat 30. Jan 2016, 07:11
Location: Weimar (Thüringen)
Contact:

Re: Firewall mit nftables

Post by Jolinar »

WebLive wrote: Mon 16. Dec 2019, 20:03 Leider immer noch das gleiche ...
Hmm...
Werden denn jetzt die geladenen FTP-Module angezeigt (lsmod | grep ftp)?
Was sagt jetzt das Logfile bei einem Connect-Versuch?
Wenn jemand inkompetent ist, dann kann er nicht wissen, daß er inkompetent ist. (David Dunning)

Data Collector für Community Support
___
Ich verwende zwei verschiedene Schriftfarben in meinen Beiträgen /
I use two different font colors in my posts:
  • In dieser Farbe schreibe ich als Moderator und gebe moderative Hinweise oder begründe moderative Eingriffe /
    In this color, I write as a moderator and provide moderative guidance or justify moderative interventions
  • In dieser Farbe schreibe ich als Community Mitglied und teile meine private Meinung und persönlichen Ansichten mit /
    In this color, I write as a community member and share my personal opinions and views
WebLive
Posts: 9
Joined: Fri 30. Mar 2018, 10:43

Re: Firewall mit nftables

Post by WebLive »

lsmod | grep ftp

Code: Select all

nf_conntrack_ftp       20480  0
nf_conntrack          172032  2 nft_ct,nf_conntrack_ftp
tls.log (FileZilla)

Code: Select all

2019-12-16 20:17:16,772 mod_tls/2.7[27508]: TLS/TLS-C requested, starting TLS handshake
2019-12-16 20:17:16,897 mod_tls/2.7[27508]: TLSv1.3 connection accepted, using cipher TLS_AES_256_GCM_SHA384 (256 bits)
2019-12-16 20:17:19,354 mod_tls/2.7[27508]: Protection set to Private
tls.log (WinSCP)

Code: Select all

2019-12-16 20:18:53,083 mod_tls/2.7[27531]: TLS/TLS-C requested, starting TLS handshake
2019-12-16 20:18:53,220 mod_tls/2.7[27531]: client supports secure renegotiations
2019-12-16 20:18:53,220 mod_tls/2.7[27531]: TLSv1.2 connection accepted, using cipher ECDHE-RSA-AES256-GCM-SHA384 (256 bits)
2019-12-16 20:18:55,549 mod_tls/2.7[27531]: Protection set to Private
proftpd.log

Code: Select all

2019-12-16 20:24:12,364 srv.meinserver.de proftpd[27430] srv.meinserver.de (HSI-KBW-046-005-228-065.hsi8.kabel-badenwuerttemberg.de[46.5.228.65]): Passive data transfer failed, possibly due to network issues
2019-12-16 20:24:12,364 srv.meinserver.de proftpd[27430] srv.meinserver.de (HSI-KBW-046-005-228-065.hsi8.kabel-badenwuerttemberg.de[46.5.228.65]): Check your PassivePorts and MasqueradeAddress settings,
2019-12-16 20:24:12,364 srv.meinserver.de proftpd[27430] srv.meinserver.de (HSI-KBW-046-005-228-065.hsi8.kabel-badenwuerttemberg.de[46.5.228.65]): and any router, NAT, and firewall rules in the network path.
2019-12-16 20:24:12,364 srv.meinserver.de proftpd[27430] srv.meinserver.de (HSI-KBW-046-005-228-065.hsi8.kabel-badenwuerttemberg.de[46.5.228.65]): FTP no transfer timeout, disconnected
derFu
Posts: 99
Joined: Sat 28. Apr 2018, 18:46

Re: Firewall mit nftables

Post by derFu »

Moin!

Ich musste bei mir noch die Ports 30000-30500 freigeben. Die sind in der proftpd.conf als Passive Ports definiert.
ftp-data reichte nicht.
User avatar
Jolinar
Community Moderator
Posts: 3595
Joined: Sat 30. Jan 2016, 07:11
Location: Weimar (Thüringen)
Contact:

Re: Firewall mit nftables

Post by Jolinar »

derFu wrote: Mon 16. Dec 2019, 20:50 Ich musste bei mir noch die Ports 30000-30500 freigeben. Die sind in der proftpd.conf als Passive Ports definiert.
ftp-data reichte nicht.
Sehe ich ähnlich.

@WebLive:
Füge mal in deine Rules unter:

Code: Select all

tcp dport { ftp, ftp-data, ftps, ftps-data } accept comment "FTP-Server"
die Zeile:

Code: Select all

tcp dport 30000-30500 accept comment "FTP-Passiv-Ports"
ein und starte nftables neu.
Dann sollte es eigentlich gehen.
Wenn jemand inkompetent ist, dann kann er nicht wissen, daß er inkompetent ist. (David Dunning)

Data Collector für Community Support
___
Ich verwende zwei verschiedene Schriftfarben in meinen Beiträgen /
I use two different font colors in my posts:
  • In dieser Farbe schreibe ich als Moderator und gebe moderative Hinweise oder begründe moderative Eingriffe /
    In this color, I write as a moderator and provide moderative guidance or justify moderative interventions
  • In dieser Farbe schreibe ich als Community Mitglied und teile meine private Meinung und persönlichen Ansichten mit /
    In this color, I write as a community member and share my personal opinions and views
WebLive
Posts: 9
Joined: Fri 30. Mar 2018, 10:43

Re: Firewall mit nftables

Post by WebLive »

Jungs, ihr seid klasse!
Es funktioniert ...

Habe schon lange nach einer Lösung gesucht.

Danke

Grüße
WebLive
User avatar
Jolinar
Community Moderator
Posts: 3595
Joined: Sat 30. Jan 2016, 07:11
Location: Weimar (Thüringen)
Contact:

Re: Firewall mit nftables

Post by Jolinar »

WebLive wrote: Mon 16. Dec 2019, 21:20 Jungs, ihr seid klasse!
Es funktioniert ...
Schön, daß es jetzt funktioniert. 8-)
Wenn jemand inkompetent ist, dann kann er nicht wissen, daß er inkompetent ist. (David Dunning)

Data Collector für Community Support
___
Ich verwende zwei verschiedene Schriftfarben in meinen Beiträgen /
I use two different font colors in my posts:
  • In dieser Farbe schreibe ich als Moderator und gebe moderative Hinweise oder begründe moderative Eingriffe /
    In this color, I write as a moderator and provide moderative guidance or justify moderative interventions
  • In dieser Farbe schreibe ich als Community Mitglied und teile meine private Meinung und persönlichen Ansichten mit /
    In this color, I write as a community member and share my personal opinions and views
Post Reply