{"id":6650,"date":"2025-05-19T11:42:13","date_gmt":"2025-05-19T02:42:13","guid":{"rendered":"https:\/\/blog.smartlight.co.jp\/?p=6650"},"modified":"2025-05-19T11:42:14","modified_gmt":"2025-05-19T02:42:14","slug":"raspberry-pi%e3%82%92ntp%e3%82%b5%e3%83%bc%e3%83%90%e3%83%bc%e3%81%a8%e3%81%97%e3%81%a6%e3%81%ae%e8%a8%ad%e5%ae%9a%e6%96%b9%e6%b3%95","status":"publish","type":"post","link":"https:\/\/blog.smartlight.co.jp\/?p=6650","title":{"rendered":"Raspberry Pi\u3092NTP\u30b5\u30fc\u30d0\u30fc\u3068\u3057\u3066\u306e\u8a2d\u5b9a\u65b9\u6cd5"},"content":{"rendered":"\n<p>\u4eca\u56de\u306f\u30e9\u30ba\u30d1\u30a4\u3092\u4f7f\u3063\u3066NTP\u30b5\u30fc\u30d0\u30fc\u3092\u8a2d\u5b9a\u3059\u308b\u624b\u9806\u3092\u66f8\u3044\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<p>NTP \u30b5\u30fc\u30d0\u30fc\uff08Network Time Protocol Server\uff09\u3068\u306f\u3001<mark>\u30a4\u30f3\u30bf\u30fc\u30cd\u30c3\u30c8\u306a\u3069\u306e\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u4e0a\u3067\u6642\u523b\u60c5\u5831\u3092\u5171\u6709\u3057\u3001\u5404\u6a5f\u5668\u306e\u6642\u8a08\u3092\u6b63\u78ba\u306b\u540c\u671f\u3055\u305b\u308b\u305f\u3081\u306e\u30b5\u30fc\u30d0\u30fc<\/mark>\u3067\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/h2>\n\n\n\n<p>\u4eca\u56de\u306f<strong>chrony<\/strong>\u3068\u3044\u3046<strong>\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u4e0a\u3067\u6642\u523b\u3092\u540c\u671f\u3059\u308b\u305f\u3081\u306e\u30c4\u30fc\u30eb<\/strong>\u3092\u4f7f\u3063\u3066NTP\u30b5\u30fc\u30d0\u30fc\u3092\u8a2d\u5b9a\u3057\u3066\u3044\u304d\u307e\u3059\u3002<br>\u521d\u3081\u306bchrony\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3092\u884c\u3063\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n\n\n<pre class=\"wp-block-code\"><span><code class=\"hljs\">sudo apt -y install chrony\n<\/code><\/span><\/pre>\n\n\n<p>\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u304c\u5b8c\u4e86\u3057\u305f\u3089\u30d0\u30fc\u30b8\u30e7\u30f3\u306e\u78ba\u8a8d\u3092\u884c\u3044\u307e\u3059<\/p>\n\n\n<pre class=\"wp-block-code\"><span><code class=\"hljs\">chronyd --version<\/code><\/span><\/pre>\n\n\n<p>chronyd\u3000version\u306a\u3069\u304c\u8fd4\u7b54\u3055\u308c\u305f\u3089\u6b63\u5e38\u306b\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u304c\u3067\u304d\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u6b21\u306bchrony\u306e\u30b9\u30c6\u30fc\u30bf\u30b9\u3092\u78ba\u8a8d\u3057\u307e\u3059\u3002\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u5f8c\u81ea\u52d5\u3067\u8d77\u52d5\u3057\u3066\u3044\u308b\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n\n\n<pre class=\"wp-block-code\"><span><code class=\"hljs\">systemctl status chrony<\/code><\/span><\/pre>\n\n\n<p>Active:\u3000active (running)\u3068\u306a\u3063\u3066\u3044\u305f\u3089\u8d77\u52d5\u3057\u3066\u3044\u307e\u3059\u3002\u78ba\u8a8d\u3067\u304d\u305f\u3089ctrl\uff0bC\u3067\u30bf\u30fc\u30df\u30ca\u30eb\u306b\u623b\u3063\u3066\u304f\u3060\u3055\u3044<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">NTP\u540c\u671f\u72b6\u6cc1\u78ba\u8a8d\u3068\u7de8\u96c6<\/h2>\n\n\n\n<p>\u6b21\u306bNTP\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u3068\u3057\u3066\u306e\u52d5\u4f5c\u78ba\u8a8d\u3092\u884c\u3063\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n\n\n<pre class=\"wp-block-code\"><span><code class=\"hljs\">chronyc sources<\/code><\/span><\/pre>\n\n\n<p>\u3068\u5165\u529b\u3057\u3066\u52d5\u4f5c\u78ba\u8a8d\u304c\u3067\u304d\u305f\u3089\u6b21\u306b\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u3092\u7de8\u96c6\u3057\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n\n\n<pre class=\"wp-block-code\"><span><code class=\"hljs\">sudo nano \/etc\/chrony\/chrony.conf\n<\/code><\/span><\/pre>\n\n\n<p>\u3068\u5165\u529b\u3057\u3066\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u3092\u958b\u3044\u3066\u304f\u3060\u3055\u3044<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\"><span class=\"hljs-comment\"># Welcome to the chrony configuration file. See chrony.conf(5) for more<\/span>\n<span class=\"hljs-comment\"># information about usable directives.<\/span>\n\n<span class=\"hljs-comment\"># Include configuration files found in \/etc\/chrony\/conf.d.<\/span>\nconfdir \/etc\/chrony\/conf.d\n\n<span class=\"hljs-comment\"># Use Debian vendor zone.<\/span>\n+ pool ntp.nict.jp iburst\n+ pool time.cloudflare.com iburst\n+ pool time.aws.com iburst\n+ pool time.google.com iburst\n- pool <span class=\"hljs-number\">2.<\/span>debian.pool.ntp.org iburst\n+ <span class=\"hljs-comment\">#pool 2.debian.pool.ntp.org iburst<\/span>\n\n<span class=\"hljs-comment\"># Use time sources from DHCP.<\/span>\nsourcedir \/run\/chrony-dhcp\n\n<span class=\"hljs-comment\"># Use NTP sources found in \/etc\/chrony\/sources.d.<\/span>\nsourcedir \/etc\/chrony\/sources.d\n\n<span class=\"hljs-comment\"># This directive specify the location of the file containing ID\/key pairs for<\/span>\n<span class=\"hljs-comment\"># NTP authentication.<\/span>\nkeyfile \/etc\/chrony\/chrony.keys\n\n<span class=\"hljs-comment\"># This directive specify the file into which chronyd will store the rate<\/span>\n<span class=\"hljs-comment\"># information.<\/span>\ndriftfile \/<span class=\"hljs-keyword\">var<\/span>\/lib\/chrony\/chrony.drift\n\n<span class=\"hljs-comment\"># Save NTS keys and cookies.<\/span>\nntsdumpdir \/<span class=\"hljs-keyword\">var<\/span>\/lib\/chrony\n\n<span class=\"hljs-comment\"># Uncomment the following line to turn logging on.<\/span>\n<span class=\"hljs-comment\">#log tracking measurements statistics<\/span>\n\n<span class=\"hljs-comment\"># Log files location.<\/span>\nlogdir \/<span class=\"hljs-keyword\">var<\/span>\/log\/chrony\n\n<span class=\"hljs-comment\"># Stop bad estimates upsetting machine clock.<\/span>\nmaxupdateskew <span class=\"hljs-number\">100.0<\/span>\n\n<span class=\"hljs-comment\"># This directive enables kernel synchronisation (every 11 minutes) of the<\/span>\n<span class=\"hljs-comment\"># real-time clock. Note that it can\u2019t be used along with the 'rtcfile' directive.<\/span>\nrtcsync\n\n<span class=\"hljs-comment\"># Step the system clock instead of slewing it if the adjustment is larger than<\/span>\n<span class=\"hljs-comment\"># one second, but only in the first three clock updates.<\/span>\nmakestep <span class=\"hljs-number\">1<\/span> <span class=\"hljs-number\">3<\/span>\n\n<span class=\"hljs-comment\"># Get TAI-UTC offset and leap seconds from the system tz database.<\/span>\n<span class=\"hljs-comment\"># This directive must be commented out when using time sources serving<\/span>\n<span class=\"hljs-comment\"># leap-smeared time.<\/span>\nleapsectz right\/UTC\n\n+ <span class=\"hljs-comment\"># Allow NTP client access from local network.<\/span>\n+ allow <span class=\"hljs-number\">192.168<\/span><span class=\"hljs-number\">.0<\/span><span class=\"hljs-number\">.0<\/span>\/<span class=\"hljs-number\">24<\/span>\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>\u3053\u306e\u30b3\u30fc\u30c9\u306e\uff0b\u306e\u90e8\u5206\u3092\u8ffd\u52a0\u3067\u5165\u529b\u3001-\u306e\u90e8\u5206\u306f\u30b3\u30e1\u30f3\u30c8\u30a2\u30a6\u30c8\u306a\u3069\u3092\u3057\u3066\u304f\u3060\u3055\u3044<br>\u4e0b\u306e\u65b9\u306eallow\u306eIP\u306fLAN\u5185\u306e\u4ed6\u306e\u6a5f\u5668\u304b\u3089\u3053\u306e\u30e9\u30ba\u30d1\u30a4\u306eNTP\u30b5\u30fc\u30d3\u30b9\uff08chronyd\uff09\u3078\u30a2\u30af\u30bb\u30b9\u3092\u8a31\u53ef\u3059\u308b\u8a2d\u5b9a\u306a\u306e\u3067<strong>allow 192.168.1.0\/24<\/strong>\u3053\u306e\u3088\u3046\u306a\u5f62\u3067LAN\u5185\u306e\u3059\u3079\u3066\u306e\u30c7\u30d0\u30a4\u30b9\u306b\u8a31\u53ef\u3059\u308b\u3088\u3046\u306b\u3057\u3066\u304f\u3060\u3055\u3044<br>\u8a2d\u5b9a\u304c\u5b8c\u4e86\u3057\u305f\u3089ctrl\uff0bo\u2192Enter\u3067\u4fdd\u5b58\u3092\u884c\u3044ctrl\uff0bx\u3067\u30bf\u30fc\u30df\u30ca\u30eb\u306b\u623b\u3063\u3066\u304f\u3060\u3055\u3044\u3002<br>\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u306e\u5909\u66f4\u304c\u5b8c\u4e86\u3057\u305f\u3089chrony\u306e\u518d\u8d77\u52d5\u3092\u884c\u3063\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n\n\n<pre class=\"wp-block-code\"><span><code class=\"hljs\">systemctl restart chrony<\/code><\/span><\/pre>\n\n\n<p>\u518d\u8d77\u52d5\u304c\u7d42\u308f\u3063\u305f\u3089<\/p>\n\n\n<pre class=\"wp-block-code\"><span><code class=\"hljs\">chronyc sources<\/code><\/span><\/pre>\n\n\n<p>\u3092\u5165\u529b\u3057\u3066^\uff0a\u304c\u3042\u308b\u306e\u3092\u78ba\u8a8d\u3057\u3066\u304f\u3060\u3055\u3044\u3001\u305d\u308c\u304cNTP\u30b5\u30fc\u30d0\u3067\u540c\u671f\u3057\u3066\u3044\u308b\u3082\u306e\u306b\u306a\u308a\u307e\u3059<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Firewall(ufw)\u8a31\u53ef\u3068\u540c\u671f<\/h2>\n\n\n<pre class=\"wp-block-code\"><span><code class=\"hljs\">sudo apt -y install ufw<\/code><\/span><\/pre>\n\n\n<p>\u3053\u306e\u30b3\u30fc\u30c9\u3067<strong>ufw<\/strong>\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/p>\n\n\n<pre class=\"wp-block-code\"><span><code class=\"hljs\">hostname -I\n<\/code><\/span><\/pre>\n\n\n<p>\u4e0a\u8a18\u306e\u30b3\u30fc\u30c9\u3067\u30e9\u30ba\u30d1\u30a4\u306eIP\u30a2\u30c9\u30ec\u30b9\u3092\u78ba\u8a8d\u3057<br>Windows\u306a\u3069\u306ePC\u5074\u3067\u7ba1\u7406\u8005\u6a29\u9650\u306e\u30bf\u30fc\u30df\u30ca\u30eb\u3092\u958b\u304dWindows\u306eNTP\u540c\u671f\u5148\u3092\u30e9\u30ba\u30d1\u30a4\u306b\u8a2d\u5b9a\u3057\u307e\u3059\u3002<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-2\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\">w32tm \/config \/manualpeerlist:<span class=\"hljs-string\">\"\u30e9\u30ba\u30d1\u30a4\u306eIP\u30a2\u30c9\u30ec\u30b9\"<\/span> \/syncfromflags:manual \/update\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-2\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>\u540c\u671f\u5f8cWindows\u306e\u6642\u9593\u30b5\u30fc\u30d3\u30b9\u306e\u518d\u8d77\u52d5\u3092\u884c\u3044\u3001\u540c\u671f\u306e\u78ba\u8a8d\u3092\u884c\u3063\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n\n\n<pre class=\"wp-block-code\"><span><code class=\"hljs\">net stop w32time\n\nnet start w32time\n\nw32tm \/query \/status\n<\/code><\/span><\/pre>\n\n\n<p>\u540c\u671f\u306e\u78ba\u8a8d\u307e\u3067\u3067\u304d\u305f\u3089\u30b5\u30f3\u30d7\u30eb\u3092\u53d6\u3063\u3066\u306e\u78ba\u8a8d\u3092\u884c\u3044\u307e\u3059\u3002<\/p>\n\n\n<pre class=\"wp-block-code\"><span><code class=\"hljs\">w32tm \/stripchart \/computer:\u30e9\u30ba\u30d1\u30a4\u306eIP\u30a2\u30c9\u30ec\u30b9 \/samples:5 \/dataonly<\/code><\/span><\/pre>\n\n\n<p>\u4e0a\u8a18\u306e\u30b3\u30fc\u30c9\u30675\u3064\u306e\u6642\u523b\u30b5\u30f3\u30d7\u30eb\u304c\u5e30\u3063\u3066\u304d\u305f\u3089\u6210\u529f\u3067\u3059\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1001\" height=\"207\" src=\"https:\/\/blog.smartlight.co.jp\/wp-content\/uploads\/2025\/05\/image-83.png\" alt=\"\" class=\"wp-image-6652\" srcset=\"https:\/\/blog.smartlight.co.jp\/wp-content\/uploads\/2025\/05\/image-83.png 1001w, https:\/\/blog.smartlight.co.jp\/wp-content\/uploads\/2025\/05\/image-83-300x62.png 300w, https:\/\/blog.smartlight.co.jp\/wp-content\/uploads\/2025\/05\/image-83-768x159.png 768w, https:\/\/blog.smartlight.co.jp\/wp-content\/uploads\/2025\/05\/image-83.png 856w\" sizes=\"auto, (max-width: 1001px) 100vw, 1001px\" \/><\/figure>\n\n\n\n<p>\u307e\u305f\u306f\u30e9\u30ba\u30d1\u30a4\u5074\u3067<\/p>\n\n\n<pre class=\"wp-block-code\"><span><code class=\"hljs\">sudo chronyc -a clients\n<\/code><\/span><\/pre>\n\n\n<p>\u4e0a\u8a18\u306e\u30b3\u30fc\u30c9\u3092\u9001\u308a\u3001PC\u5074\u306eIP\u30a2\u30c9\u30ec\u30b9\u306e\u8868\u8a18\u304c\u3042\u308c\u3070\u540c\u671f\u78ba\u8a8d\u304c\u3067\u304d\u307e\u3059<br>\uff08\u4f8b\uff09<\/p>\n\n\n<pre class=\"wp-block-code\"><span><code class=\"hljs\">Hostname                      NTP   Drop Int IntL Last     Cmd   Drop Int  Last\n===============================================================================\n192.168.1.101                  10     0   64  64     12      0     0   64    5\n<\/code><\/span><\/pre>\n\n\n<h2 class=\"wp-block-heading\">\u307e\u3068\u3081<\/h2>\n\n\n\n<p>NTP\u30b5\u30fc\u30d0\u8a2d\u5b9a\u306f\u521d\u3081\u3066\u884c\u3044\u307e\u3057\u305f\u304c\u691c\u7d22\u3059\u308b\u3068\u30b5\u30f3\u30d7\u30eb\u3082\u305f\u304f\u3055\u3093\u3042\u308a\u304b\u306a\u308a\u7c21\u5358\u306b\u8a2d\u5b9a\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3057\u305f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4eca\u56de\u306f\u30e9\u30ba\u30d1\u30a4\u3092\u4f7f\u3063\u3066NTP\u30b5\u30fc\u30d0\u30fc\u3092\u8a2d\u5b9a\u3059\u308b\u624b\u9806\u3092\u66f8\u3044\u3066\u3044\u304d\u307e\u3059\u3002 NTP \u30b5\u30fc\u30d0\u30fc\uff08Network Time Protocol Server\uff09\u3068\u306f\u3001\u30a4\u30f3\u30bf\u30fc\u30cd\u30c3\u30c8\u306a\u3069\u306e\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u4e0a\u3067\u6642\u523b\u60c5\u5831\u3092\u5171\u6709\u3057\u3001\u5404\u6a5f\u5668\u306e\u6642\u8a08\u3092<\/p>\n","protected":false},"author":19,"featured_media":6653,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jin_ogp_image_url":"https:\/\/blog.smartlight.co.jp\/wp-content\/uploads\/2025\/05\/thumbnails-ogp-6650.png","_jin_last_featured_id":6653,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[3],"tags":[],"class_list":["post-6650","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-intern"],"jetpack_featured_media_url":"https:\/\/blog.smartlight.co.jp\/wp-content\/uploads\/2025\/05\/thumbnails-featured-6650.png","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/blog.smartlight.co.jp\/index.php?rest_route=\/wp\/v2\/posts\/6650","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.smartlight.co.jp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.smartlight.co.jp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.smartlight.co.jp\/index.php?rest_route=\/wp\/v2\/users\/19"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.smartlight.co.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6650"}],"version-history":[{"count":2,"href":"https:\/\/blog.smartlight.co.jp\/index.php?rest_route=\/wp\/v2\/posts\/6650\/revisions"}],"predecessor-version":[{"id":6655,"href":"https:\/\/blog.smartlight.co.jp\/index.php?rest_route=\/wp\/v2\/posts\/6650\/revisions\/6655"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.smartlight.co.jp\/index.php?rest_route=\/wp\/v2\/media\/6653"}],"wp:attachment":[{"href":"https:\/\/blog.smartlight.co.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6650"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.smartlight.co.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6650"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.smartlight.co.jp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6650"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}