Всем доброго времени суток!
В сегменте DMZ у меня возникла необходимость развернуть кеширующий сервер DNS и сервер времени NTP. Причем разрешение имен было с определенных IP адресов.Разбираемся
За основу я взял CentOS 7.
Устанавливаем CentOS7 и присваиваем ей статический адрес.
Далее обновляем ее
#yum update -y
#yum install mc -y
Отключаем Selinux (Знаю что неправильно)
#mcedit /etc/selinux/config
Изменяем строку
SELINUX=disabled
Перезагружаемся
#reboot
Открываем порты для работы DNS и NTP
#firewall-cmd --zone=public --add-service=dns --permanent
#firewall-cmd --zone=public --add-service=ntp --permanent
#firewall-cmd --reload
Устанавливаем кеширующий DNS
#yum install -y caching-nameserver
После установки создадим папку в которой будут находится логи DNS
#mkdir /etc/log/named
Настроим соответствующие права доступа для службы
#chmod 0777 -R /etc/log/named
#chown named:named -R /etc/log/named
Теперь можно перейти к настройке. Я изучил много статей и основой для моего файла конфигурации стали следующие статьи
https://ars69.wordpress.com/2014/12/24/%D0%BA%D0%B5%D1%88%D0%B8%D1%80%D1%83%D1%8E%D1%89%D0%B8%D0%B9-dns-%D1%81%D0%B5%D1%80%D0%B2%D0%B5%D1%80-%D0%BD%D0%B0-centos/
https://serveradmin.ru/nastroyka-dns-servera-bind-v-centos-7/
Открываем первый файл конфигурации:
#mcedit /etc/resolv.conf
Удаляем все и добавляем строчку
nameserver 127.0.0.1
В необходимости это делать я ничего сказать не могу. У меня работало и с оригинальным файлом resolv.conf и только с этой строкой. В некоторых просмотренных мануалах рекомендуют это делать а в некоторых упоминания о нем нет нигде. Поэтому изменять или нет каждый решает сам.
Теперь открываем основной конфиг файл bind
#mcedit /etc/named.conf
И вносим следующие настройки
//
// named.conf
//
// Provided by Red Hat bind package to configure the ISC BIND named(8) DNS
// server as a caching only nameserver (as a localhost DNS resolver only).
//
// See /usr/share/doc/bind*/sample/ for example named configuration files.
//
// See the BIND Administrator's Reference Manual (ARM) for details about the
// configuration located in /usr/share/doc/bind-{version}/Bv9ARM.html
options {
listen-on port 53 { any; };
listen-on-v6 port 53 { none; };
directory "/var/named";
dump-file "/var/named/data/cache_dump.db";
statistics-file "/var/named/data/named_stats.txt";
memstatistics-file "/var/named/data/named_mem_stats.txt";
recursing-file "/var/named/data/named.recursing";
secroots-file "/var/named/data/named.secroots";
/*
- If you are building an AUTHORITATIVE DNS server, do NOT enable recursion.
- If you are building a RECURSIVE (caching) DNS server, you need to enable
recursion.
- If your recursive DNS server has a public IP address, you MUST enable access
control to limit queries to your legitimate users. Failing to do so will
cause your server to become part of large scale DNS amplification
attacks. Implementing BCP38 within your network would greatly
reduce such attack surface
*/
recursion yes;
dnssec-enable no;
dnssec-validation no;
forwarders { 8.8.8.8; 77.88.8.8; };
forward first;
auth-nxdomain no;
allow-query { localhost; 10.0.0.0/8; };
allow-recursion { localhost; 10.0.0.0/8; };
allow-query-cache { localhost; 10.0.0.0/8; };
/* Path to ISC DLV key */
bindkeys-file "/etc/named.root.key";
managed-keys-directory "/var/named/dynamic";
pid-file "/run/named/named.pid";
session-keyfile "/run/named/session.key";
};
//logging {
// channel default_debug {
// file "/var/log/named/general.log";
// severity dynamic;
//
// };
//};
logging {
channel default {
file "/var/log/named/default.log" versions 3 size 5m;
severity dynamic;
print-time yes;
};
channel general {
file "/var/log/named/general.log" versions 3 size 5m;
severity dynamic;
print-time yes;
};
channel database {
file "/var/log/named/database.log" versions 3 size 5m;
severity dynamic;
print-time yes;
};
channel security {
file "/var/log/named/security.log" versions 3 size 5m;
severity dynamic;
print-time yes;
};
channel config {
file "/var/log/named/config.log" versions 3 size 5m;
severity dynamic;
print-time yes;
};
channel resolver {
file "/var/log/named/resolver.log" versions 3 size 5m;
severity dynamic;
print-time yes;
};
channel xfer-in {
file "/var/log/named/xfer-in.log" versions 3 size 5m;
severity dynamic;
print-time yes;
};
channel xfer-out {
file "/var/log/named/xfer-out.log" versions 3 size 5m;
severity dynamic;
print-time yes;
};
channel notify {
file "/var/log/named/notify.log" versions 3 size 5m;
severity dynamic;
print-time yes;
};
channel client {
file "/var/log/named/client.log" versions 3 size 5m;
severity dynamic;
print-time yes;
};
channel unmatched {
file "/var/log/named/unmatched.log" versions 3 size 5m;
severity dynamic;
print-time yes;
};
channel network {
file "/var/log/named/network.log" versions 3 size 5m;
severity dynamic;
print-time yes;
};
channel update {
file "/var/log/named/update.log" versions 3 size 5m;
severity dynamic;
print-time yes;
};
channel update-security {
file "/var/log/named/update-security.log" versions 3 size 5m;
severity dynamic;
print-time yes;
};
channel queries {
file "/var/log/named/queries.log" versions 3 size 5m;
severity dynamic;
print-time yes;
};
channel query-errors {
file "/var/log/named/query-errors.log" versions 3 size 5m;
severity dynamic;
print-time yes;
};
channel dispatch {
file "/var/log/named/dispatch.log" versions 3 size 5m;
severity dynamic;
print-time yes;
};
channel dnssec {
file "/var/log/named/dnssec.log" versions 3 size 5m;
severity dynamic;
print-time yes;
};
channel lame-servers {
file "/var/log/named/lame-servers.log" versions 3 size 5m;
severity dynamic;
print-time yes;
};
channel delegation-only {
file "/var/log/named/delegation-only.log" versions 3 size 5m;
severity dynamic;
print-time yes;
};
channel edns-disabled {
file "/var/log/named/edns-disabled.log" versions 3 size 5m;
severity dynamic;
print-time yes;
};
channel rpz {
file "/var/log/named/rpz.log" versions 3 size 5m;
severity dynamic;
print-time yes;
};
channel rate-limit {
file "/var/log/named/rate-limit.log" versions 3 size 5m;
severity dynamic;
print-time yes;
};
category default { default; };
category general { general; };
category database { database; };
category security { security; };
category config { config; };
category resolver { resolver; };
category xfer-in { xfer-in; };
category xfer-out { xfer-out; };
category notify { notify; };
category client { client; };
category unmatched { unmatched; };
category network { network; };
category update { update; };
category update-security { update-security; };
category queries { queries; };
category query-errors { query-errors; };
category dispatch { dispatch; };
category dnssec { dnssec; };
category lame-servers { lame-servers; };
category delegation-only { delegation-only; };
category edns-disabled { edns-disabled; };
category rpz { rpz; };
category rate-limit { rate-limit; };
};
//
zone "." IN {
type hint;
file "named.ca";
};
include "/etc/named.rfc1912.zones";
include "/etc/named.root.key";
Комментарии к конфигурационному файлу.
То что нужно изменить я выделил жирным шрифтом.
forwarders { 8.8.8.8; 77.88.8.8; }; - указываем на какие выше стоящие сервера будут пересылаться запросы
forwarders { 8.8.8.8; 77.88.8.8; }; - указываем на какие выше стоящие сервера будут пересылаться запросы
allow-query { localhost; 10.0.0.0/8; };
allow-recursion { localhost; 10.0.0.0/8; };
allow-query-cache { localhost; 10.0.0.0/8; }; - здесь через ; указываем адреса сетевых устройств, которым разрешено разрешать имена. Если устройство не в списке ему в разрешении имен будет отказано
Теперь прописываем службу в автозагрузку и запускаем.
#systemctl enable named
#systemctl start named
Настройка сервера NTP
При настройке службы я руководствовался
https://denisitpro.wordpress.com/2016/05/14/install-ntp-server-centos-7/
allow-recursion { localhost; 10.0.0.0/8; };
allow-query-cache { localhost; 10.0.0.0/8; }; - здесь через ; указываем адреса сетевых устройств, которым разрешено разрешать имена. Если устройство не в списке ему в разрешении имен будет отказано
Теперь прописываем службу в автозагрузку и запускаем.
#systemctl enable named
#systemctl start named
Настройка сервера NTP
При настройке службы я руководствовался
https://denisitpro.wordpress.com/2016/05/14/install-ntp-server-centos-7/
Устанавливаем сервис NTP
#yum -y install ntp
Теперь отредактируем файл конфигурации /etc/ntp.conf
#mcedit /etc/ntp.conf
Комментируем default настройки и добавляем свои.
Привожу свой файл конфигурации
# For more information about this file, see the man pages
# ntp.conf(5), ntp_acc(5), ntp_auth(5), ntp_clock(5), ntp_misc(5), ntp_mon(5).
driftfile /var/lib/ntp/drift
# Permit time synchronization with our time source, but do not
# permit the source to query or modify the service on this system.
restrict default nomodify notrap nopeer noquery
# Permit all access over the loopback interface. This could
# be tightened as well, but to do so would effect some of
# the administrative functions.
restrict 127.0.0.1
restrict ::1
# Hosts on local network are less restricted.
#restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
#server 0.centos.pool.ntp.org iburst
#server 1.centos.pool.ntp.org iburst
#server 2.centos.pool.ntp.org iburst
#server 3.centos.pool.ntp.org iburst
server server 0.pool.ntp.org iburst
server 1.pool.ntp.org iburst
server 2.pool.ntp.org iburst
server 3.pool.ntp.org iburst
restrict default nomodify notrap nopeer noquery
restrict 127.0.0.1
restrict ::1
restrict 10.0.0.0 mask 255.0.0.0 nomodify notrap
#broadcast 192.168.1.255 autokey # broadcast server
#broadcastclient # broadcast client
#broadcast 224.0.1.1 autokey # multicast server
#multicastclient 224.0.1.1 # multicast client
#manycastserver 239.255.254.254 # manycast server
#manycastclient 239.255.254.254 autokey # manycast client
# Enable public key cryptography.
#crypto
includefile /etc/ntp/crypto/pw
# Key file containing the keys and key identifiers used when operating
# with symmetric key cryptography.
keys /etc/ntp/keys
# Specify the key identifiers which are trusted.
#trustedkey 4 8 42
# Specify the key identifier to use with the ntpdc utility.
#requestkey 8
# Specify the key identifier to use with the ntpq utility.
#controlkey 8
# Enable writing of statistics records.
#statistics clockstats cryptostats loopstats peerstats
# Disable the monitoring facility to prevent amplification attacks using ntpdc
# monlist command when default restrict does not include the noquery flag. See
# CVE-2013-5211 for more details.
# Note: Monitoring will not be disabled with the limited restriction flag.
disable monitor
logfile /var/log/ntp.log
Комментарии к конфигурационному файлу
server server 0.pool.ntp.org iburst
server 1.pool.ntp.org iburst
server 2.pool.ntp.org iburst
server 3.pool.ntp.org iburst - список NTP серверов, откуда будет идти синхронизация времени
server 1.pool.ntp.org iburst
server 2.pool.ntp.org iburst
server 3.pool.ntp.org iburst - список NTP серверов, откуда будет идти синхронизация времени
restrict 10.0.0.0 mask 255.0.0.0 nomodify notrap - адреса устройств, которые будут синхронизироваться с сервером.
Прописываем сервис в автозагрузку и запускаем
#systemctl enable ntpd
#systemctl start ntpd
# netstat -tulnp | grep 123
Все в порядке, служба слушает положенный порт 123. Проверим еще на всякий случай системные логи centos:
# cat /var/log/messages | grep ntpd
# cat /var/log/ntp.log
Наблюдать за работой службы ntp можно с помощью команды
#ntpq -p
Пояснения к выводимым данным:
remote Адрес удаленного эталона времени, с которого была синхронизация
refid Указывает, откуда каждый эталон получает точное время. Это могут быть другие сервера времени, система GPS и другое
st Stratum (уровень) это число от 1 до 16, которое указывает на точность эталона. 1- максимальная точность, 16 — сервер недоступен. Уровень вашего сервера будет равен уровню наименее точного удаленного эталона плюс 1.
poll Интервал в секундах между опросами
reach Восьмеричное представление массива из 8 бит, отражающего результаты последних восьми попыток соединения с эталоном. Бит выставлен, если удаленный сервер ответил.
delay Время задержки ответа на запрос о точном времени
offset Разница между вашим и удаленным сервером
jitter Дисперсия (Jitter) — это мера статистических отклонений от значения смещения (поле offset) по нескольким успешным парам запрос-ответ. Чем меньше значение дисперсии, тем лучше, поскольку позволяет точнее синхронизировать время.
ВАЖНО — после настройки клиенты сразу не смогут получать время. Как и после перезагрузки – сервер начнет выдавать корректно время примерно через 20-30 минут.
Вот в принципе и все.
Комментариев нет:
Отправить комментарий