有两台服务器,一台有可以连接外网,其余都是内网机。如何让那个其他服务器的时间对齐这台有外网的服务器呢?
前置要求
- 一个可以连接外网的机器
- 内网机器已经安装了ntp服务
配置
外网服务器的操作
首先在有外网的服务器上安装ntp:
sudo yum install ntp安装完成后开启ntp:
systemctl start ntpd看看123端口有没有在监听:
netstat -anp | grep 123
内网服务器的操作
vim /etc/ntp.conf
原有:
server 0.centos.pool.ntp.org iburstserver 1.centos.pool.ntp.org iburstserver 2.centos.pool.ntp.org iburstserver 3.centos.pool.ntp.org iburst修改为:
server 外网IP服务器的内网IP iburst重启一下:
sudo systemctl restart ntpd执行下:
ntpq -p看看是不是有另一台服务器的主机名或者IP,如果有代表成功!