在树莓派是安装并配置NTP服务
我们都知道树莓派的小巧和省电节省空间等太多的优势,这里就不一一列举了,那么树莓派就需要长时间的运行,可以7×24的方式运行,那么我们就把树莓派当作一个小的服务器来运行,可以跑一些小的应用,例如可以在局域网中当作NTP服务器,哈哈,这个想法不错!
初步设想:
1)树莓派连接网络之后,时间通过网络自动同步,那么树莓派本身的时间就正常了。(不会的自己上网查,类似的文章一堆,不是本文重点)
2)在内部局域网中的其他计算机(包含win,Linux,mac等)都可以以树莓派作为ntp服务器进行时间同步了。
一、配置局域网NTP服务器
1.安装ntp服务
通过如下命令安装ntp服务
sudo apt-get install ntp
2.修改配置文件ntp.conf
安装完成后,打开/etc/ntp.conf文件,在命令处输入:
cd / cd etc/ sudo nano ntp.conf
显示内容如下:
# /etc/ntp.conf, configuration for ntpd; see ntp.conf(5) for helpdriftfile /var/lib/ntp/ntp.drift# Enable this if you want statistics to be logged. #statsdir /var/log/ntpstats/statistics loopstats peerstats clockstats filegen loopstats file loopstats type day enable filegen peerstats file peerstats type day enable filegen clockstats file clockstats type day enable# You do need to talk to an NTP server or two (or three). #server ntp.your-provider.example# pool.ntp.org maps to about 1000 low-stratum NTP servers. Your server will # pick a different set every time it starts up. Please consider joining the # pool: <http://www.pool.ntp.org/join.html> server 0.debian.pool.ntp.org iburst server 1.debian.pool.ntp.org iburst server 2.debian.pool.ntp.org iburst server 3.debian.pool.ntp.org iburst# Access control configuration; see /usr/share/doc/ntp-doc/html/accopt.html for # details. The web page <http://support.ntp.org/bin/view/Support/AccessRestrictions> # might also be helpful. # # Note that "restrict" applies to both servers and clients, so a configuration # that might be intended to block requests from certain clients could also end # up blocking replies from your own upstream servers.# By default, exchange time with everybody, but don't allow configuration. restrict -4 default kod notrap nomodify nopeer noquery restrict -6 default kod notrap nomodify nopeer noquery# Local users may interrogate the ntp server more closely. restrict 127.0.0.1 restrict ::1# Clients from this (example!) subnet have unlimited access, but only if # cryptographically authenticated. #restrict 192.168.123.0 mask 255.255.255.0 notrust# If you want to provide time to your local subnet, change the next line. # (Again, the address is an example only.) #broadcast 192.168.123.255# If you want to listen to time broadcasts on your local subnet, de-comment the # next lines. Please do this only if you trust everybody on the network! #disable auth #broadcastclient
以上是安装ntp服务完成后的默认配置。
我自己参考了网上其他人的配置参数,修改成了如下的样子,参考文章在最后给出了地址:
# /etc/ntp.conf, configuration for ntpd; see ntp.conf(5) for helpdriftfile /var/lib/ntp/ntp.drift# Enable this if you want statistics to be logged. #statsdir /var/log/ntpstats/statistics loopstats peerstats clockstats filegen loopstats file loopstats type day enable filegen peerstats file peerstats type day enable filegen clockstats file clockstats type day enable# You do need to talk to an NTP server or two (or three). #server ntp.your-provider.example# pool.ntp.org maps to about 1000 low-stratum NTP servers. Your server will # pick a different set every time it starts up. Please consider joining the # pool: <http://www.pool.ntp.org/join.html> server 0.debian.pool.ntp.org iburst server 1.debian.pool.ntp.org iburst server 2.debian.pool.ntp.org iburst server 3.debian.pool.ntp.org iburst server time.asia.apple.com prefer server ntp.sjtu.edu.cn prefer server 127.127.1.0 fudge 127.127.1.0 stratum 10# Access control configuration; see /usr/share/doc/ntp-doc/html/accopt.html for # details. The web page <http://support.ntp.org/bin/view/Support/AccessRestrictions> # might also be helpful. # # Note that "restrict" applies to both servers and clients, so a configuration # that might be intended to block requests from certain clients could also end # up blocking replies from your own upstream servers.# By default, exchange time with everybody, but don't allow configuration. restrict -4 default kod notrap nomodify nopeer noquery restrict -6 default kod notrap nomodify nopeer noquery #restrictdefault nomodify# Local users may interrogate the ntp server more closely. restrict 127.0.0.1 restrict ::1# Clients from this (example!) subnet have unlimited access, but only if # cryptographically authenticated. #restrict 192.168.123.0 mask 255.255.255.0 notrust# If you want to provide time to your local subnet, change the next line. # (Again, the address is an example only.) #broadcast 192.168.123.255# If you want to listen to time broadcasts on your local subnet, de-comment the # next lines. Please do this only if you trust everybody on the network! #disable auth #broadcastclient
根据自己的网络情况,以及使用情况,请自行修改ntp配置,本文章末尾处给出了配置的参考连接。
3.重启NTP服务
使用命令重启ntp服务:sudo service ntp restart
4.本地测试
1)先确认ntp是否已启动,命令:ps -ef | grep ntp,应该可以看到两行内容(如果一行太长显示不完,会显示成两行,注意分辨!)
2)命令行输入:ntpq -p
结果如下,说明NTP服务器进程存在
pi@raspberrypi36:/ $ ntpq -premote refid st t when poll reach delay offset jitter ============================================================================== +cn.ntp.faelix.n 185.134.196.169 2 u 1 64 377 253.107 -7.402 23.282 +d.hnd.pobot.net 255.254.0.27 2 u 15 64 155 249.128 41.977 8.036static-5-103-13 .INIT. 16 u - 64 0 0.000 0.000 0.000 *time5.aliyun.co 10.137.38.86 2 u 9 64 377 30.167 3.322 3.654
重启系统
重启命令:reboot
5.在其它PC同步树莓派上的时间
在其它PC端填入我的树莓派IP。
在Windows下即设置时间时选择Internet时间,并填入树莓派的IP。
=========================================================
参考:
https://blog.csdn.net/rk2900/article/details/8658110
https://www.linuxidc.com/Linux/2016-10/135945.htm
https://blog.csdn.net/gsls200808/article/details/51057359
https://www.cnblogs.com/quchunhui/p/7658853.html
https://blog.csdn.net/yjgithub/article/details/54613172
https://www.cnblogs.com/rongpmcu/p/7662141.html
转载于:https://www.cnblogs.com/mq0036/p/9362706.html
在树莓派是安装并配置NTP服务相关推荐
- 怎样用u盘linux安装ntp协议,电脑中怎么配置NTP服务
NTP服务器是用来使计算机时间同步化的一种协议,可提供高精准度的时间校正,而且能通过加密确认来防止恶毒的协议攻击.下面让学习啦小编为大家介绍如何在电脑中配置NTP服务来实现局域网内设备的时间同步. 电 ...
- 树莓派3b+安装openwrt 配置wan lan和wifi
树莓派3b+安装openwrt 配置wan lan和wifi 1.配置网络 修改/etc/config/network 注释掉option ifname 'eth0'一行,为防止与路由器地址冲突,将其 ...
- Kali Linux常用服务配置教程安装及配置DHCP服务
Kali Linux常用服务配置教程安装及配置DHCP服务 在Kali Linux中,默认没有安装DHCP服务.下面将介绍安装并配置DHCP服务的方法. 1.安装DHCP服务 在Kali Linux中 ...
- 在RedHat Linux系统中安装和配置snmp服务
在RedHat Linux系统中安装和配置snmp服务 检查系统是否安装snmp服务 # rpm -qa|grep snmp net-snmp-5.3.2.2-17.el5 net-snmp-perl ...
- OpenVAS破绽扫描根底教程之OpenVAS概述及安装及配置OpenVAS服务
OpenVAS根底学问 OpenVAS(Open Vulnerability Assessment System)是开放式破绽评价系统,其中心局部是一个服务器.该服务器包括一套网络破绽测试程序,能够检 ...
- 如何在 Windows 10 上安装和配置 SNMP 服务并通过组策略配置 SNMP 设置
简单网络管理协议或 SNMP用于企业网络上的监控.事件通知和网络设备管理.该协议由一组网络管理标准组成,包括应用层协议.数据库模式和一组数据对象.SNMP 可以从任何网络设备接收各种类型的信息(正常运 ...
- 学习安装与配置DNS服务
安装与配置DNS服务 首先,基础环境 1.改主机名 我的主服务器是192.168.200.80 从服务器是 192.168.200.70 main节点 [root@localhost ~]# host ...
- 华为路由器配置NTP服务端和客户端
华为路由器配置NTP服务端和客户端 基础配置 R1: <Huawei>sys-view #进入系统配置模式 Enter system view, return user view with ...
- linux dhcp 服务失败,Centos7安装及配置DHCP服务,安装程序配置服务失败
Centos7安装及配置DHCP服务,安装程序配置服务失败 DHCP服务概述: 名称:DHCP - Dynamic Host Configuration Protocol 动态主机配置协议. 功能 ...
最新文章
- 业余实现一个统计A股数据工具
- 华硕笔记本如何锁定计算机,我的华硕电脑开机密码被锁定了怎么办
- 安装Oracle 10g sys,system 密码忘记设置解决办法
- 【Web安全】关于PHP-文件上传的探索(看不懂你来打我)
- Leetcode 25.K个一组翻转链表
- 虚拟服务器设置upnp,TP-Link路由器如何设置UPNP开启【设置步骤】
- CssVariables_01
- JS之字符串分割方法split
- 日期setMinutes()方法以及JavaScript中的示例
- typecho独一无二的后台美化主题模板
- vue UI框架比较
- linux 低功耗模式,stm32的低功耗模式:
- 在Windows server 2019 Core 版本上安装SQL2016
- 2022 软件库APP源码前端 后端整套独立后台+搭建教程
- 如何做将两张图片合二为一
- 使用Unity3D编写ARPG游戏——角色属性的定义与实现(一)
- Mixamo使用笔记
- java方面的文献综述怎么写_javaweb开发文献综述
- ROS系统之安装系列(一):安装步骤
- 五脚18.8数码管显示
热门文章
- 谷歌云请更正这张卡片的信息_如何识别和更正Google Analytics(分析)报告中的(未设置)值
- 上市公司降价200万卖房仍然无人接手,有的甚至降价1900万
- AD制图相关问题总结
- 收到几本书,顺便热热身
- 希望我不会“伤心至死”
- 使用CAtlRegExp正则表达式检查浮点数输入
- 身体好不是锻炼出来的
- 所属的用户_关于chmod(变更用户对此文件的相关权限)超详细说明,小白秒懂
- vbs打开软件光标停在第一个输入框_三维设计软件,3DMAX最全快捷键大全,赶快收藏哦...
- ByteArray、16进制、字符串之间的转换