Meine Standard Installation eines Debian Systems:


Wichtiger Hinweis

Für Schäden an eurem System übernehme ich keinerlei Haftung!

Diese Anleitung wurde auf meinem System hin abgestimmt, der Test mit anderen Systemen hat nie Stattgefunden.
Es wird empfohlen, dass nur erfahrene Administratoren diese Anleitung umsetzen.
Anwenden der Anleitung auf euer eigenes System erfolgt unter Eigenverantwortung!


Als erstes Editieren wir Lokal am PC/Server/VM die Datei: /etc/ssh/sshd_config und Entfernen die Raute (#) aus der Zeile 34.
Änderung PermitRootLogin von "without-password" zu "yes". Dies dient dazu sich mittels Root von Extern via WinSCP oder nur Putty einzuloggen, statt für Paket Installationen den Befehl "sudo" und die Passworteingabe benutzen zu müssen.
Die Root Aktivierung ist natürlich Optional und kann ausgelassen werden.


Wie man WinScp, Putty und Notepad++ für den Produktiven Einsatz bereit macht, findest du hier: WinSCP, Notepad++ inkl. Putty einrichten


sshd_config
[...]
# Authentication:

#LoginGraceTime 2m
PermitRootLogin yes
#StrictModes yes
#MaxAuthTries 6
#MaxSessions 10
[...]


Editieren der Datei /etc/default/grub in Zeile 9 und 10. Hinzufüge oder ergänzen der folgenden Boot Befehlen.

grub
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash net.ifnames=0 biosdevname=0"
GRUB_CMDLINE_LINUX="fsck.mode=force fsck.repair=yes"

Die Hinzugefügten Punkte "net.ifnames=0" und "biosdevname=0" stellen die Schnittstellen von "ensp", "eno", o.ä Schreibweisen zu "ethX" um. Können also Optional Genutzt werden wer die Eindeutigen Netzwerkkartenbezeichner behalten will!
Die Hinzugefügten Punkte "fsck.mode=force" und "fsck.repair=yes" sorgen dafür dass das Dateisystem beim Boot Repariert wird.


Nach der Änderung der Grub Config einmal mit

update-grub

die Config in den Bootloader Übernehmen. !! Der Nächste Schritt ist WICHTIG, die LAN Schnittstellen MÜSSEN jetzt geändert werden !!


Unter /etc/network/interfaces ersetzen wir die Schnittstellen von "ensp", "eno", o.ä Schreibweisen zu "ethX". Für Eine LAN Schnittstelle benutzen wir "eth0", für 2 Schnittstellen benutzen wir: "eth0" und "eth1", u.s.w.

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
allow-hotplug eth0
iface eth0 inet dhcp
# This is an autoconfigured IPv6 interface
iface eth0 inet6 auto



Kernel

Wichtiger Hinweis

Nur für Debian Basierte Installationen, bitte nicht für Virtualisierungshosts inkl. Proxmox VE einsetzen

Jetzt noch nen neuen Kernel. Ich empfehle hier seit neustem den XanMod Kernel, der sich wie folgt installieren lässt:

0. Optional - Installation von eventuell benötigten Paketen:

apt install curl ca-certificates apt-transport-https sudo gnupg gnupg2 htop iftop ethstatus net-tools -y

1. Prüfen welcher Kernel für mich infrage kommt. Das ist Wichtig um zu Prüfen welcher Kernel für das System geeignet ist.

 wget -O check_x86-64_psabi.sh https://dl.xanmod.org/check_x86-64_psabi.sh && chmod 755 check_x86-64_psabi.sh && ./check_x86-64_psabi.sh

Ausgabe: CPU supports x86-64-vX dabei steht das Unterstrichende X für die Versionsnummer. Beispielausgabe: CPU supports x86-64-v3


2. Registrieren Sie den PGP-Schlüssel:

wget -qO - https://dl.xanmod.org/archive.key | sudo gpg --dearmor -o /usr/share/keyrings/xanmod-archive-keyring.gpg

3. Sources List einspielen:

echo 'deb [signed-by=/usr/share/keyrings/xanmod-archive-keyring.gpg] http://deb.xanmod.org releases main' | sudo tee /etc/apt/sources.list.d/xanmod-release.list

4. Updaten und Installieren des Kernels, dabei beachten wir den Kernel Support unter Schritt 1:

sudo apt update && sudo apt install linux-xanmod-lts-x64v3 -y

 

Fehlermeldung beim Booten

Nach der Installation des XanMod Kernels erscheint unter UEFI Umgebungen beim Booten folgende Meldung:

UEFI Fehlermeldung

Loading Linux <KERNEL> ...
Fehler: Falsche Shim-Signatur.
Loading initial ramdisk ...
Fehler: Sie müssen zuerst den Kernel laden.

Beliebige Taste drucken, um fortzusetzen ...

Unter UEFI Umgebungen kann die Installation des neuen XanMod Kernels einen Boot Fehler hervorrufen, beheben kann man das Problem in dem man BIOS Seitig die "Secure Boot" Option deaktiviert.


Sources List

Hier findet man die Sources Listen für Debian 11 und 12 welche unter "/etc/apt/sources.list" angepasst werden kann.

Debian 12 - Stable
#------------------------------------------------------------------------------#
#                   OFFICIAL DEBIAN 12 REPOS                    
#------------------------------------------------------------------------------#

###### Debian Main Repos für Debian 12
deb http://ftp.de.debian.org/debian/ bookworm main contrib non-free-firmware
deb-src http://ftp.de.debian.org/debian/ bookworm main contrib non-free-firmware

deb http://ftp.de.debian.org/debian/ bookworm-updates main contrib non-free-firmware
deb-src http://ftp.de.debian.org/debian/ bookworm-updates main contrib non-free-firmware


deb http://ftp.debian.org/debian bookworm-backports main
deb-src http://ftp.debian.org/debian bookworm-backports main
Debian 11 - Oldstable
#------------------------------------------------------------------------------#
#                   OFFICIAL DEBIAN 11 REPOS                    
#------------------------------------------------------------------------------#

###### Debian Main Repos für Debian 11
deb http://ftp.de.debian.org/debian/ bullseye main contrib non-free
deb-src http://ftp.de.debian.org/debian/ bullseye main contrib non-free

deb http://ftp.de.debian.org/debian/ bullseye-updates main contrib non-free
deb-src http://ftp.de.debian.org/debian/ bullseye-updates main contrib non-free


deb http://ftp.debian.org/debian bullseye-backports main
deb-src http://ftp.debian.org/debian bullseye-backports main



Server Tuning

Dieses Dokument beschreibt die Optimierung von Servereinstellungen von sehr beschäftigten Netzwerkservern (Web, DNS, …) mit viel Arbeitsspeicher und Bandbreite.
Die Standardwerte eines “typischen” Linux-Servers sind normalerweise sehr gut. 


HINWEIS

Für Schäden an eurem System übernehme ich keinerlei Haftung!

Diese Anleitung wurde auf meinem System hin abgestimmt, der Test mit anderen Systemen hat nie Stattgefunden.
Es wird empfohlen, dass nur erfahrene Administratoren diese Anleitung umsetzen.
Anwenden der Anleitung auf euer eigenes System erfolgt unter Eigenverantwortung!


Erstelle/bearbeite die Datei /etc/sysctl.d/network-tuning.conf (oder weiter unten herunterladen):

network-tuning.conf
# Use BBR TCP congestion control and set tcp_notsent_lowat to 16384 to ensure HTTP/2 prioritization works optimally
# Do a 'modprobe tcp_bbr' first (kernel > 4.9)
# Fall-back to htcp if bbr is unavailable (older kernels)
# Default: tcp_congestion_control=cubic, tcp_notsent_lowat=-1
net.ipv4.tcp_congestion_control = htcp
net.ipv4.tcp_congestion_control = bbr
net.ipv4.tcp_notsent_lowat = 16384

# For servers with tcp-heavy workloads, enable 'fq' queue management scheduler (kernel > 3.12)
# Default: pfifo_fast
net.core.default_qdisc = fq

# Increase the read-buffer space allocatable
# Default: tcp_rmem=4096 87380 6291456, udp_rmem_min=4096, rmem_default=212992, rmem_max=212992
net.ipv4.tcp_rmem = 8192 87380 16777216
net.ipv4.udp_rmem_min = 16384
net.core.rmem_default = 262144
net.core.rmem_max = 16777216

# Increase the write-buffer-space allocatable
# Default: tcp_wmem=4096 16384 4194304, udp_wmem_min=4096, wmem_default=212992, wmem_max=212992
net.ipv4.tcp_wmem = 8192 65536 16777216
net.ipv4.udp_wmem_min = 16384
net.core.wmem_default = 262144
net.core.wmem_max = 16777216

# Increase number of incoming connections
# Default: 128
net.core.somaxconn = 32768

# Increase number of incoming connections backlog
# Default: 1000
net.core.netdev_max_backlog = 16384

# Increase the maximum amount of option memory buffers
# Default: 20480
net.core.optmem_max = 65535

# Increase the tcp-time-wait buckets pool size to prevent simple DOS attacks
# Default: 131072
net.ipv4.tcp_max_tw_buckets = 1440000

# try to reuse time-wait connections, but don't recycle them (recycle can break clients behind NAT)
# Default: tcp_tw_recycle=0, tcp_tw_reuse=0
net.ipv4.tcp_tw_recycle = 0
net.ipv4.tcp_tw_reuse = 1

# Limit number of orphans, each orphan can eat up to 16M (max wmem) of unswappable memory
# Default: 131072
net.ipv4.tcp_max_orphans = 16384

# Limit the maximum memory used to reassemble IP fragments (CVE-2018-5391)
# Default: ipfrag_low_thresh=3145728, ipfrag_high_thresh=4194304
net.ipv4.ipfrag_low_thresh = 196608
net.ipv6.ip6frag_low_thresh = 196608
net.ipv4.ipfrag_high_thresh = 262144
net.ipv6.ip6frag_high_thresh = 262144

# don't cache ssthresh from previous connection
# Default: 0
net.ipv4.tcp_no_metrics_save = 1

# Avoid falling back to slow start after a connection goes idle
# keeps our cwnd large with the keep alive connections (kernel > 3.6)
# Default: 1
net.ipv4.tcp_slow_start_after_idle = 0

# Decrease the default time for tcp_fin_timeout
# (connections in state TIME_WAIT)
# Default: 60
net.ipv4.tcp_fin_timeout = 15

# Decrease the time default value for connections to keep alive
# Default: tcp_keepalive_time=7200, tcp_keepalive_probes=9, tcp_keepalive_intvl=75
net.ipv4.tcp_keepalive_time = 300
net.ipv4.tcp_keepalive_probes = 5
net.ipv4.tcp_keepalive_intvl = 15

# This will enusre that immediatly subsequent connections use the new values
net.ipv4.route.flush = 1
net.ipv6.route.flush = 1


Erstelle/bearbeite die Datei
/etc/sysctl.d/network-security.conf (oder weiter unten herunterladen):

network-security.conf
# Prevent SYN attack, enable SYNcookies (they will kick-in when the max_syn_backlog reached)
# Default: tcp_syncookies=1, tcp_syn_retries=6, tcp_synack_retries=5, tcp_max_syn_backlog=1024
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_syn_retries = 2
net.ipv4.tcp_synack_retries = 2
net.ipv4.tcp_max_syn_backlog = 4096

# Disables IP source routing
net.ipv4.conf.all.send_redirects = 0
net.ipv4.conf.default.send_redirects = 0
net.ipv4.conf.all.accept_source_route = 0
net.ipv4.conf.default.accept_source_route = 0
net.ipv6.conf.all.accept_source_route = 0
net.ipv6.conf.default.accept_source_route = 0

# Enable IP spoofing protection, turn on source route verification
net.ipv4.conf.all.rp_filter = 1
net.ipv4.conf.default.rp_filter = 1

# Disable ICMP Redirect Acceptance
net.ipv4.conf.all.accept_redirects = 0
net.ipv4.conf.default.accept_redirects = 0
net.ipv4.conf.all.secure_redirects = 0
net.ipv4.conf.default.secure_redirects = 0
net.ipv6.conf.all.accept_redirects = 0
net.ipv6.conf.default.accept_redirects = 0

# Enable Log Spoofed Packets, Source Routed Packets, Redirect Packets
net.ipv4.conf.all.log_martians = 1
net.ipv4.conf.default.log_martians = 1

# Enable a fix for RFC1337 - time-wait assassination hazards in TCP
net.ipv4.tcp_rfc1337 = 1


Erstelle/bearbeite die Datei /etc/sysctl.d/security.conf (oder weiter unten herunterladen):

security.conf
# Controls the System Request debugging functionality of the kernel
# Default: 438
kernel.sysrq = 0

# Controls whether core dumps will append the PID to the core filename.
# Useful for debugging multi-threaded applications.
# Default: 0
kernel.core_uses_pid = 1

# Allow for more PIDs
# Default: 32768
kernel.pid_max = 65535

# Controls the maximum size of a message, in bytes
# Default: 16384
kernel.msgmnb = 65535

# Controls the default maxmimum size of a mesage queue
# Default: 8192
kernel.msgmax = 65535

# Hide exposed kernel pointers
# Default: 0
kernel.kptr_restrict = 1

 

Einstellungen anwenden

Um die neuen Einstellungen anzuwenden, führen Sie folgenden Befehl aus:

sysctl --system


Anhänge:

security.confnetwork-security.confnetwork-tuning.conf

  • Keine Stichwörter