Outils pour utilisateurs

Outils du site


technique:referentiel:chd-stg1-ng

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Les deux révisions précédentes Révision précédente
Prochaine révision
Révision précédente
technique:referentiel:chd-stg1-ng [2018/04/07 20:54]
admin
technique:referentiel:chd-stg1-ng [2018/05/19 20:46] (Version actuelle)
admin
Ligne 33: Ligne 33:
 update-grub update-grub
  
-apt install arping beep bind binutils borgbackup conntrack cpufrequtils dnsutils ethtool fail2ban git gt5 htop iftop iotop iperf iperf3 ipmitool libvirt-daemon llibvirt-daemon-system ​lldpd lm-sensors molly-guard mtr-tiny nmap ntp nullmailer powertop psmisc qemu-kvm rsync screen sdparm smartmontools sshpass strace sysstat tcpdump tree unzip vim lvm2- mysql-common-+apt install arping beep bind binutils borgbackup conntrack cpufrequtils dnsutils ethtool fail2ban git gt5 htop iftop iotop iperf iperf3 ipmitool libvirt-daemon llibvirt-daemon-system lm-sensors molly-guard mtr-tiny nmap ntp nullmailer powertop psmisc qemu-kvm rsync screen sdparm smartmontools sshpass strace ​sudo sysstat tcpdump tree unzip vim aspell- ​lvm2- mysql-common-
  
 sensors-detect sensors-detect
Ligne 51: Ligne 51:
 # Créer VM chd-stg2 via virt-manager over SSH # Créer VM chd-stg2 via virt-manager over SSH
 ln -s /​etc/​libvirt/​qemu/​chd-stg2.xml /​etc/​libvirt/​qemu/​autostart/​ ln -s /​etc/​libvirt/​qemu/​chd-stg2.xml /​etc/​libvirt/​qemu/​autostart/​
 +
 +# Récupérer une version de lldpd qui gère plus de 4 voisins par ports
 +dpkg -i /​opt/​lldpd/​lldpd_0.9.6-1.1~lpo1_amd64.deb
 +echo "lldpd hold" | dpkg --set-selections
 +
 </​code>​ </​code>​
  
Ligne 58: Ligne 63:
  
 <file bash /​etc/​default/​lldpd>​ <file bash /​etc/​default/​lldpd>​
-# Active l'​écoute CDP, désactive LLDP +# Active l'​écoute CDP, désactive LLDP, admet 500 voisin par port 
-DAEMON_ARGS="​-c -ll"+DAEMON_ARGS="​-c -ll -n500"
 </​file>​ </​file>​
  
Ligne 79: Ligne 84:
 adduser genconf adduser genconf
 passwd -dl genconf passwd -dl genconf
-/​home/​genconf/​.ssh/​authorized_keys 
 </​code>​ </​code>​
 +
 +<file text /​home/​genconf/​.ssh/​authorized_keys>​
 +command="​~/​.ssh/​check",​no-agent-forwarding,​no-port-forwarding,​no-pty,​no-user-rc,​no-X11-forwarding ssh-rsa ... www-data@chd-tls1
 +</​file>​
 +
 +<file bash /​home/​genconf/​.ssh/​check>​
 +#!/bin/sh
 +if [ "xsudo genconf_prod"​ = "​x$SSH_ORIGINAL_COMMAND"​ ]
 +then $SSH_ORIGINAL_COMMAND;​
 +else echo "​Rejected"​
 +fi
 +</​file>​
 +
 +<file text /​etc/​sudoers>​
 +Defaults ​       env_reset
 +Defaults ​       mail_badpass
 +Defaults ​       secure_path="/​usr/​local/​sbin:/​usr/​local/​bin:/​usr/​sbin:/​usr/​bin:/​sbin:/​bin"​
 +root    ALL=(ALL:​ALL) ALL
 +genconf ALL=(ALL:​ALL) NOPASSWD:/​usr/​local/​bin/​genconf_prod
 +%sudo   ​ALL=(ALL:​ALL) ALL
 +</​file>​
  
 <file bash /​etc/​modules>​ <file bash /​etc/​modules>​
Ligne 91: Ligne 116:
 jc42 jc42
 w83627ehf w83627ehf
 +</​file>​
 +
 +<file text /​etc/​sensors.d/​local.conf>​
 +chip "​w83627dhg-*"​
 +    ignore fan1
 +    ignore fan3
 +    ignore fan4
 +    ignore fan5
 </​file>​ </​file>​
  
Ligne 217: Ligne 250:
 <file text /​etc/​fstab>​ <file text /​etc/​fstab>​
 none /​var/​log/​bind9 tmpfs uid=bind,​gid=bind,​mode=0750,​size=30m 0 0 none /​var/​log/​bind9 tmpfs uid=bind,​gid=bind,​mode=0750,​size=30m 0 0
 +/       /​mnt/​rootfs ​    ​ext4 ​   bind                                    0       0
 +# Attention à l'​ordre,​ le mount --bind doit être à la fin
 </​file>​ </​file>​
  
Ligne 315: Ligne 350:
 </​file>​ </​file>​
  
-<file text /​root/​iftoprc>​+<file text /root/.iftoprc>
 interface: br1 interface: br1
 max-bandwidth:​ 10M max-bandwidth:​ 10M
Ligne 365: Ligne 400:
 </​file>​ </​file>​
  
 +===== Compilation lldpd modifié =====
  
 +https://​www.debian.org/​doc/​manuals/​maint-guide/​modify.fr.html
 +
 +<file bash .bash_aliases>​
 +alias dquilt="​quilt --quiltrc=${HOME}/​.quiltrc-dpkg"​
 +complete -F _quilt_completion -o filenames dquilt
 +</​file>​
 +
 +<code bash>
 +source ~/​.bash_aliases
 +sudo apt install devscripts
 +sudo apt build-dep lldpd
 +apt source lldpd
 +cd lldpd-0.9.6/​
 +mkdir debian/​patches
 +dquilt new add-max-neighbors-arg.patch
 +dquilt add src/​daemon/​lldpd.c
 +editor src/​daemon/​lldpd.c ​
 +dch
 +# Version : 0.9.6-1.1~lpo1
 +# Commentaire:​ reprendre celui du patch (1ère ligne)
 +dpkg-buildpackage -us -uc
 +</​code>​
 +
 +<file diff /​opt/​lldpd/​lldpd-0.9.6/​debian/​patches/​add-max-neighbors-arg.patch>​
 +Add -n <​max_neighbors>​ getopt'​ion
 +--- a/​src/​daemon/​lldpd.c
 ++++ b/​src/​daemon/​lldpd.c
 +@@ -1451,8 +1451,9 @@
 +  * unless there is a very good reason. Most command-line options will
 +  * get deprecated at some point. */
 +  char *popt, opts[] =
 +- "​H:​vhkrdD:​p:​xX:​m:​u:​4:​6:​I:​C:​p:​M:​P:​S:​iL:​@ ​                   ";
 ++ "​n:​H:​vhkrdD:​p:​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;
 +@@ -1492,6 +1493,9 @@
 +  }
 + ​ while ((ch = getopt(argc,​ argv, opts)) != -1) {
 + ​ switch (ch) {
 ++ case '​n':​
 ++ max_neighbors = atoi(optarg);​
 ++ break;
 + ​ case '​h':​
 + ​ usage();​
 + ​ break;​
 +@@ -1758,7 +1762,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;​
 +</​file>​
 +
 +===== Accéder au disque qcow2 d'une VM éteinte =====
 +Attention : toujours éteindre la VM, sinon corruption de données garantie
 +
 +<code bash>
 +modprobe nbd max_part=8
 +qemu-nbd --connect=/​dev/​nbd0 /​var/​lib/​libvirt/​images/​chd-stg2.qcow2 ​
 +fdisk /dev/nbd0 -l 
 +partprobe ​
 +mount -o ro /dev/nbd0p1 /mnt/loop
 +cd /​mnt/​loop/​var/​log
 +ls
 +cd /mnt/
 +umount /mnt/loop
 +qemu-nbd --disconnect /​dev/​nbd0 ​
 +dmesg | tail
 +</​code>​
 ===== TODO ===== ===== TODO =====
 <​code>​ <​code>​
 +Remplir vraiment les fichiers ~genconf/​.ssh/​*
 configurer munin/​multiping configurer munin/​multiping
-VM chd-stg2 en d9 "​vierge"​ +tester interfaces, max nfconntrack,​ fail2ban, nullmailer, lldpd
-tester interfaces, max nfconntrack, genconf, fail2ban, nullmailer+
 voir si cpufreq par défaut est ok ou pas voir si cpufreq par défaut est ok ou pas
 netconsole config netconsole config
 apt remove --purge isc-dhcp-dhclient isc-dhcp-common apt remove --purge isc-dhcp-dhclient isc-dhcp-common
-lldp a recompiler 
 backup borg backup borg
 +côté serveur de backup : command="​borg serve --restrict-to-path /​var/​backups/​borg",​restrict ssh-rsa [...]
 +côté client : command="/​usr/​local/​bin/​borg-save.sh"​ ssh-rsa [...]
 +
 mailer + mail alert (smartmontools/​logcheck ?) mailer + mail alert (smartmontools/​logcheck ?)
 Point de montage pour /​var/​lib/​libvirt/​images/​ Point de montage pour /​var/​lib/​libvirt/​images/​
 </​code>​ </​code>​
 +
 +===== Log association MAC ⟷ IP =====
 +
 +L'​objectif est de détecter l'IP spoofing en gardant une trace de la
 +MAC usuelle associée à une IP donnée.
 +
 +<file bash /​var/​log/​mac/​update.sh>​
 +#!/bin/bash
 +ip n | sort | sed \
 + -e '​s/​\(REACHABLE\|STALE\|DELAY\)/​normal/'​ \
 + -e '​s/​\(INCOMPLETE\|FAILED\|PROBE\)/​lost/'​ > ip-n-sort-sed
 +git add ip-n-sort-sed
 +git commit -m "​update via $0 $*"
 +</​file>​
 +
 +<​code>​
 +chown -R nobody: /​var/​log/​mac
 +</​code>​
 +
 +<file cron /​etc/​cron.d/​log-mac>​
 +*/4 * * * *     ​nobody if [ -x /​var/​log/​mac/​update.sh ]; then cd /​var/​log/​mac/;​ ./update.sh
 +</​file>​
  
technique/referentiel/chd-stg1-ng.1523127277.txt.gz · Dernière modification: 2018/04/07 20:54 par admin