Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentesRévision précédente | |||
sysadmin:linux:serveur-ntp [2022/01/08 13:59] – yoann | sysadmin:linux:serveur-ntp [2022/01/08 18:48] (Version actuelle) – yoann | ||
---|---|---|---|
Ligne 131: | Ligne 131: | ||
===== Paramétrage du pare-feu ===== | ===== Paramétrage du pare-feu ===== | ||
- | Si l'on souhaite contrôler précisément le trafic NTP au tarvers | + | Si l'on souhaite contrôler précisément le trafic NTP au travers d'un pare-feu restrictif, il est possible de créer des règles exploitant les ensembles (ipsets). |
- | creation | + | création |
<code bash> | <code bash> | ||
Ligne 144: | Ligne 144: | ||
dig +short 2.fr.pool.ntp.org | xargs --max-args=1 ipset add set_ntp_servers | dig +short 2.fr.pool.ntp.org | xargs --max-args=1 ipset add set_ntp_servers | ||
dig +short 3.fr.pool.ntp.org | xargs --max-args=1 ipset add set_ntp_servers | dig +short 3.fr.pool.ntp.org | xargs --max-args=1 ipset add set_ntp_servers | ||
+ | |||
</ | </ | ||
- | Création/ | + | Création/ |
<code bash> | <code bash> | ||
# Journalise le trafic NTP sortant | # Journalise le trafic NTP sortant | ||
Ligne 155: | Ligne 156: | ||
</ | </ | ||
- | Lorsque les règles fonctionnent comme prévu, on peut les inclure | + | Si le système utilise **UFW**, on ne peut pas créer directement de règle exploitant |
- | < | + | |
- | # . . . | + | <code bash> |
- | # Journalise et autorise le trafic NTP a destination des serveurs des pools *.fr.pool.ntp.org | + | # Rendre le script exécutable pour qu'il soit automatiquement appelé par ufw-init |
- | -A ufw-after-output -o wan -m set --match-set set_ntp_servers dst -p udp --dport 123 -j ufw-logging-allow -m comment --comment " | + | chmod ug+x / |
- | -A ufw-after-output -o wan -m set --match-set set_ntp_servers dst -p udp --dport 123 -j ACCEPT -m comment --comment " | + | |
- | # . . . | + | # Sauvegarder les ensembles existants pour qu'ils puissent être rechargés |
+ | ipset save > / | ||
+ | </ | ||
+ | |||
+ | Modifier | ||
+ | |||
+ | < | ||
+ | # | ||
+ | # Copyright 2013 Canonical Ltd. | ||
+ | # | ||
+ | # This program is free software: you can redistribute it and/or modify | ||
+ | # it under the terms of the GNU General Public License version 3, | ||
+ | # as published by the Free Software Foundation. | ||
+ | # | ||
+ | # This program is distributed in the hope that it will be useful, | ||
+ | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
+ | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
+ | # GNU General Public License for more details. | ||
+ | # | ||
+ | # You should have received a copy of the GNU General Public License | ||
+ | # along with this program. | ||
+ | # | ||
+ | set -e | ||
+ | |||
+ | case " | ||
+ | start) | ||
+ | # typically required | ||
+ | if [ -r / | ||
+ | then | ||
+ | ipset -f / | ||
+ | # Journalise et autorise le trafic NTP a destination des serveurs des pools *.fr.pool.ntp.org | ||
+ | | ||
+ | | ||
+ | fi | ||
+ | ;; | ||
+ | stop) | ||
+ | | ||
+ | ipset destroy | ||
+ | ;; | ||
+ | status) | ||
+ | # optional | ||
+ | ;; | ||
+ | flush-all) | ||
+ | # optional | ||
+ | ;; | ||
+ | *) | ||
+ | echo "' | ||
+ | echo " | ||
+ | ;; | ||
+ | esac | ||
</ | </ | ||
+ | |||
+ | |||
===== Troubleshooting ===== | ===== Troubleshooting ===== |