linux 搭建 NTP 时间服务器

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了linux 搭建 NTP 时间服务器相关的知识,希望对你有一定的参考价值。

1搭建DNS 主 从服务器。

1.1环境要求:

Centos 6.5 x86_64

1.2硬件配置:

名称

IP规划

cpu

内存

硬盘

主服务器

192.168.0.24

4核

8G

80G

从服务器

192.168.0.34

4核

8G

80G

1.3软件包安装:

[[email protected] ~]# yum install -y bind bind-chroot bind-utlis

1.4配置文件:

/etc/named.conf bind 服务主配置文件。

/var/named/ zone 文件。

1.5复制配置文件模板:

[[email protected] ~]# cp -rv /usr/share/doc/bind-9.8.2/sample/etc/* /var/named/chroot/etc/

[[email protected] ~]# cp -rv /usr/share/doc/bind-9.8.2/sample/var/*

1.6修改主配置文件:

[[email protected] ~]# vi /var/named/chroot/etc/named.conf

options

{

    // Put files that named is allowed to write in the data/ directory:

    directory               "/var/named";           // "Working" directory

    dump-file               "data/cache_dump.db";

    statistics-file         "data/named_stats.txt";

    memstatistics-file      "data/named_mem_stats.txt";

    //listen-on port 53     { any; };

    listen-on port 53       { any; };

    //listen-on-v6 port 53  { any; };

    listen-on-v6 port 53    { ::1; };

    allow-query             { any; };

    allow-query-cache       { any; };

    forwarders             { 10.0.0.1;114.114.114.114; };

    recursion yes;

    dnssec-enable yes;

    dnssec-validation yes;

};

zone "zabbix.73go.cn"{

  type  master;

  file "zabbix.73go.cn.zone";

};

1.7修改zone 文件:

[[email protected] named]# cd /var/named/chroot/var/named

[[email protected] named]# cat zabbix.73go.cn.zone

$TTL 1D

@ IN SOA @ rname.invalid. (

                                    0       ; serial

                                    1D      ; refresh

                                    1H      ; retry

                                    1W      ; expire

                                    3H )    ; minimum

    NS      @

    A       127.0.0.1

    AAAA    ::1

    IN    A  192.168.0.236

1.8语法检查:

[[email protected] named]# named-checkconf /var/named/chroot/etc/named.conf

[[email protected] named]# named-checkzone linuxcast.net linuxcast.net.zone

1.9重启服务:

[[email protected] named]# service named reload

[[email protected] named]# service named restart

2从服务器配置:

2.1软件包安装:

[[email protected] ~]# yum install -y bind bind-chroot bind-utlis

2.2复制配置文件模板:

[[email protected] ~]# cp -rv /usr/share/doc/bind-9.8.2/sample/etc/* /var/named/chroot/etc/

2.3更改服务器从配置文件

[[email protected] etc]# vi /var/named/chroot/etc/named.conf

options

{

    // Put files that named is allowed to write in the data/ directory:

    directory               "/var/named";           // "Working" directory

    dump-file               "data/cache_dump.db";

    statistics-file         "data/named_stats.txt";

    memstatistics-file      "data/named_mem_stats.txt";

    //listen-on port 53     { any; };

    listen-on port 53       { any; };

    //listen-on-v6 port 53  { any; };

    listen-on-v6 port 53    { ::1; };

    allow-query             { any; };

    allow-query-cache       { any; };

    forwarders             { 10.0.0.1;114.114.114.114; };

    recursion yes;

    dnssec-enable yes;

    dnssec-validation yes;

};

zone "zabbix.73go.cn"{

  type  slave;

 masters{ 192.168.0.24; };

  file "slaves/zabbix.73go.cn.zone";

};

2.4重启服务:

[[email protected]lhost named]# service named reload

[[email protected] named]# service named restart

2.5保证目录权限:

[[email protected] named]# ll

drwxrwxrwx. 2 named named 4096 7月 5 17:55 slaves

2.6查看同步zone 文件。

[[email protected] slaves]# cat /var/named/chroot/var/named/slaves

2.7验证:

C:\Users\admin>nslookup zabbix.73go.cn

服务器: UnKnown

Address: 192.168.0.24

名称: zabbix.73go.cn

Addresses: ::1

      127.0.0.1

      192.168.0.236

以上是关于linux 搭建 NTP 时间服务器的主要内容,如果未能解决你的问题,请参考以下文章

Linux 搭建NTP时间同步服务器

Linux NTP 服务器搭建

Linux下的NTP服务搭建

linux ntp服务搭建

linux上ntp时钟服务器搭建

linux 搭建 NTP 时间服务器