11/mai/2012 Posté dans Software | 2 commentaires Monit a pour fonction de « surveiller » service et/ou les ressources système et d’exécuter une ou plusieurs actions en fonction de condition. Par exemple, il peut redémarrer Nginx si celui ci ne répond plus.
Configuration de base épuré
set daemon 60
set logfile syslog facility log_daemon
## Interface web de monit
#set httpd port 2812 and
# allow login:motdepasse
include /etc/monit/conf.d/*
Configuration des services
Dans /etc/monit/conf.d/, j’y ai placé un fichier de configuration par service :
apache2
check process apache with pidfile /var/run/apache2.pid
start program = "/etc/init.d/apache2 start"
stop program = "/etc/init.d/apache2 stop"
if children > 149 then restart
if totalmem > 4096 MB for 5 cycles then restart
if 3 restarts within 5 cycles then timeout
clamd
check process clamd with pidfile /var/run/clamav/clamd.pid
group clamav
start program = "/etc/init.d/clamav-daemon start"
stop program = "/etc/init.d/clamav-daemon stop"
if failed unixsocket /var/run/clamav/clamd.ctl then restart
if 5 restarts within 5 cycles then timeout
dovecot
check process dovecot with pidfile /var/run/dovecot/master.pid
group dovecot
start program = "/etc/init.d/dovecot start"
stop program = "/etc/init.d/dovecot stop"
if failed host 127.0.0.1 port 143 protocol imap then restart
if failed host 127.0.0.1 port 993 type tcpssl sslauto protocol imap then restart
if 5 restarts within 5 cycles then timeout
freshclam
check process freshclam with pidfile /var/run/clamav/freshclam.pid
group clamav
start program = "/etc/init.d/clamav-freshclam start"
stop program = "/etc/init.d/clamav-freshclam stop"
if 5 restarts within 5 cycles then timeout
mysql
check process mysql with pidfile /var/lib/mysql/mysql.pid
group mysql
start program = "/etc/init.d/mysql start"
stop program = "/etc/init.d/mysql stop"
if failed host localhost port 3306 then restart
if 5 restarts within 5 cycles then timeout
named
check process named with pidfile /var/run/named/named.pid
start program = "/etc/init.d/bind9 start"
stop program = "/etc/init.d/bind9 stop"
if failed host 127.0.0.1 port 53 type tcp protocol dns then restart
if failed host 127.0.0.1 port 53 type udp protocol dns then restart
if 5 restarts within 5 cycles then timeout
postfix
check process postfix with pidfile /var/spool/postfix/pid/master.pid
group mail
start program = "/etc/init.d/postfix start"
stop program = "/etc/init.d/postfix stop"
if failed host localhost port 25 protocol smtp then restart
if 5 restarts within 5 cycles then timeout
sshd
check process sshd with pidfile /var/run/sshd.pid
start program "/etc/init.d/ssh start"
stop program "/etc/init.d/ssh stop"
if failed port 22 protocol ssh then restart
if 5 restarts within 5 cycles then timeout
3/avr/2012 Posté dans Software | 0 commentaire sender_dependent_default_transport_maps va permettre, en fonction de l’émetteur de l’email sur votre serveur de spécifier une IP précise.
echo "/@domain-src-1\.ltd$/ domain_src_1:" > /usr/local/etc/postfix/outgoingips.regexp
echo "/@domain-src-2\.ltd$/ domain_src_2:" >> /usr/local/etc/postfix/outgoingips.regexp
echo "/@domain-src-3\.ltd$/ domain_src_3:" >> /usr/local/etc/postfix/outgoingips.regexp
Création des routes, ajouter dans master.cf les « entrées » suivante
domain_src_1 unix - - n - - smtp
-o smtp_bind_address=192.168.0.1
-o smtp_helo_name=domain-src-1.ltd
-o syslog_name=postfix-domain_src_1
domain_src_2 unix - - n - - smtp
-o smtp_bind_address=192.168.0.2
-o smtp_helo_name=domain-src-2.ltd
-o syslog_name=postfix-domain_src_2
domain_src_3 unix - - n - - smtp
-o smtp_bind_address=192.168.0.3
-o smtp_helo_name=domain-src-3.ltd
-o syslog_name=postfix-domain_src_3
Puis ajouter dans main.cf :
sender_dependent_default_transport_maps = regexp:/usr/local/etc/postfix/outgoingips.regexp
19/mar/2010 Posté dans Linux/Unix | 0 commentaire Ajoutez dans le fichier de configuration main.cf :
smtp_generic_maps = hash:/etc/postfix/generic
Dans ce fichier, vous y indiquerez ce qui doit être réécrit
@domaine.local @domaine.net
root@domaine.local noreply@domaine.net
- Le premier exemple remplace domaine.local par domaine.net
- Le deuxième exemple remplace l’adresse root@domaine.local par noreply@domaine.net
Postfix utilisera le hash de ce fichier, générez le avec postmap
postmap /etc/postfix/generic
16/mar/2010 Posté dans Linux/Unix | 0 commentaire master.cf
2525 inet n - n - - smtpd
-o smtpd_sender_restrictions=hash:/etc/postfix/anti-spoofing
-o smtpd_helo_restrictions=hash:/etc/postfix/anti-spoofing
- 2525 : port supplémentaire postfix pour les mails entrant avec antispoofing
- Anti-spoofing : Base d’ « ACL » voir description ci-dessous
anti-spoofing
votredomain.fr REJECT do-not-spoof-my-domain
190.127.10.0/24 PERMIT serveurs-de-mailing
- REJECT : Refuse le reseau/domaine avec le code d’erreur « do-not-spoof-my-domain »
- PERMIT : Autorise le reseau/domaine
11/mar/2009 Posté dans Linux/Unix | 0 commentaire Exemple de spoofing d’email émit depuis un autre serveur que celui qui gere la messagerie de votre domaine :
- Expéditeur : toto@votredomaine.com
- Destinataires : toto@votredomaine.com
Main.cf
- Notez le domaine de messagerie de votre Postfix : mydomain
- Vérifiez que Postfix ne gère pas d’autre domaines de messagerie : mydestination
anti-spoofing
Créer le fichier anti-spoofing et ajoutez y
votredomaine.com REJECT ANTI-SPOOFING
autredomaine.fr REJECT ANTI-SPOOFING
Générez le hash avec la commande :
postmap anti-spoofing
master.cf
Vous devez avoir une ligne comme cela :
smtp inet n - n - - smtpd
Ajoutez en dessous
2525 inet n – n – – smtpd
-o smtpd_sender_restrictions=hash:/etc/postfix/anti-spoofing
-o smtpd_helo_restrictions=hash:/etc/postfix/anti-spoofing
Cela configure Postfix pour écouter sur le port 25 et 2525
- Port 2525, rejeter tous les messages en provenance d’Internet qui se présenteront avec un HELO/EHLO ou MAIL FROM qui contiendra l’un de vos domaines.
- Port 25, pour l’émission de mail.
Vous pouvez spécifier une ip et/ou changer les ports. la syntaxes pour spécifier une ip est par exemple :
192.168.1.1:2525 inet n – n – – smtpd