Outils pour utilisateurs

Outils du site


technique:referentiel:chd-stg1

Ceci est une ancienne révision du document !


Serveur chd-stg1

Caractéristiques

  • Machine virtuelle (KVM amd64)
  • Debian 8

Roles

  • Routage des adhérents sur le LAN2LAN Fullsave

Fonctionnement général

  • Les données de routage sont dans /root/config_adt.sh
    • Mise à jour déclanchée par le lien “Appliquer le routage” dans l'interface de gestion
    • Appelle l'API de l'application de gestion api/gen_conf.php
    • Se connecte en ssh sur stg.chd.sx et utilise le script /usr/local/bin/genconf_prod
  • Le routage est appliqué grâce au script /root/setup_routing.sh
    • Prends en compte les suppression de NAT automatiquement, pas besoin de flusher quoi que ce soit
  • /etc/network/interfaces contient
    • La config IP v4 et v6 statique du routeur
    • Du routage statique pour les serveurs
    • Le tuning des paramètres kernel pour le réseau
    • L'appel à setup_routing.sh pour le routage des adhérents

Notes d'installation

Système / Réseau

# Parti d'un iso de Debian 8.
editor /etc/network/interfaces /etc/resolv.conf
mkdir /root/.ssh
editor /etc/ssh/sshd_config /root/.ssh/authorized_keys
deluser temp
editor ~root/.ssh/authorized_keys
passwd -dl root
editor /etc/aliases
apt-get autoremove --purge rpcbind nfs-common vim-tiny
apt-get install --purge nullmailer
# Donner chd.sx comme smarthost
apt-get install sudo arping gt5 htop iftop iperf mtr-tiny sdparm iotop molly-guard nmap ntp powertop procps rdiff-backup rsync screen sshpass strace sysstat tcpdump tree unzip vim
update-alternatives --config editor
apt-get install fail2ban munin-node pdns-recursor lldpd
# Configuration des services
rm /etc/munin/plugins/ntp_kernel_*
rm /etc/munin/plugins/nfs*
service munin-node reload
editor ~/.bashrc ~/.vimrc ~/.iftoprc
editor /etc/default/grub
update-grub
editor /etc/powerdns/recursor.conf
service pdns-recursor restart
rm /etc/lldpd.d/README.conf
editor /etc/default/lldpd
service lldpd restart

fail2ban : ne pas utiliser iptables

iptables est a bannir sur un routeur linux car consomme bcp du CPU et des watts. Il y a deux mauvaises raisons de l'utiliser : le NAT et fail2ban.

Contournement pour fail2ban : n'utiliser que le action route. Ça bannit via la table de routage les paquets de réponse à l'attaquant, quelque soit le port. En dégraissant la config par défaut de Debian, ça donne :

chd-stg1:/etc/fail2ban# tree
.
├── action.d
│   └── route.conf
├── fail2ban.conf
├── fail2ban.d
├── filter.d
│   ├── common.conf
│   ├── pam-generic.conf
│   └── sshd.conf
├── jail.conf
└── jail.d
action.d/route.conf
[Definition]
actionstart =
actionstop  =
actioncheck =
actionban   = ip route add <blocktype> <ip>
actionunban = ip route del <blocktype> <ip>
 
[Init]
blocktype = blackhole
jail.conf
chd-stg1:/etc/fail2ban# cat jail.conf 
[DEFAULT]
ignoreip = 127.0.0.1/8
ignorecommand =
bantime  = 600
# A host is banned if it has generated "maxretry" during the last "findtime" seconds.
findtime = 600
maxretry = 3
 
backend = auto
usedns = warn
 
destemail = root@localhost
sendername = Fail2Ban
sender = fail2ban@localhost
 
#
# JAILS
#
[pam-generic]
enabled  = true
filter   = pam-generic
action = route
logpath  = /var/log/auth.log
maxretry = 6
 
[ssh-route]
enabled = true
filter = sshd
action = route
logpath  = /var/log/auth.log
maxretry = 6

lldpd 0.7.2 : max_neighbors non configurable (= 4)

add-max-neighbors-arg.patch
--- a/src/daemon/lldpd.c
+++ b/src/daemon/lldpd.c
@@ -1294,8 +1294,9 @@
      * unless there is a very good reason. Most command-line options will
      * get deprecated at some point. */
     char *popt, opts[] =
-        "H:vhkrdD:xX:m:u:4:6:I:C:p:M:P:S:iL:@                    ";
+        "n:H:vhkrdD:xX:m:u:4:6:I:C:p:M:P:S:iL:@                    ";
     int i, found, advertise_version = 1;
+    int max_neighbors = LLDPD_MAX_NEIGHBORS;
 #ifdef ENABLE_LLDPMED
     int lldpmed = 0, noinventory = 0;
     int enable_fast_start = 1;
@@ -1332,6 +1333,9 @@
     }
     while ((ch = getopt(argc, argv, opts)) != -1) {
         switch (ch) {
+        case 'n':
+            max_neighbors = atoi(optarg);
+            break;
         case 'h':
             usage();
             break;
@@ -1565,7 +1569,7 @@
     cfg->g_config.c_receiveonly = receiveonly;
     cfg->g_config.c_tx_interval = LLDPD_TX_INTERVAL;
     cfg->g_config.c_tx_hold = LLDPD_TX_HOLD;
-    cfg->g_config.c_max_neighbors = LLDPD_MAX_NEIGHBORS;
+    cfg->g_config.c_max_neighbors = max_neighbors;
 #ifdef ENABLE_LLDPMED
     cfg->g_config.c_enable_fast_start = enable_fast_start;
     cfg->g_config.c_tx_fast_init = LLDPD_FAST_INIT;
dpkg -i /opt/lldpd/lldpd_0.7.11-2~lpo1_amd64.deb
echo "lldpd hold" | sudo dpkg --set-selections

Pro tip : avoir la console d'une VM depuis son hôte avec ''virsh console''

Nécessite que la VM soit configurée pour parler sur le port série qui va bien

Methode 1 - login sans traces systemd (non employée)

chd-stg1:~# cd /etc/systemd/system/getty.target.wants/
chd-stg1:/etc/systemd/system/getty.target.wants# cp -a getty@tty1.service getty@ttyS0.service
chd-stg1:/etc/systemd/system/getty.target.wants# ls -l
total 0
lrwxrwxrwx 1 root root 34 déc.  24 12:09 getty@tty1.service -> /lib/systemd/system/getty@.service
lrwxrwxrwx 1 root root 34 déc.  24 12:09 getty@ttyS0.service -> /lib/systemd/system/getty@.service

Méthode 2 - login + traces systemd (employée)

chd-stg1:~# editor /etc/default/grub
#GRUB_CMDLINE_LINUX_DEFAULT="quiet"
GRUB_CMDLINE_LINUX_DEFAULT="systemd.journald.forward_to_console=1 console=ttyS0,38400"
chd-stg1:~# update-grub
technique/referentiel/chd-stg1.1462567983.txt.gz · Dernière modification: 2016/05/06 22:53 par admin