{"id":49034,"date":"2025-07-30T14:51:48","date_gmt":"2025-07-30T06:51:48","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/49034.html"},"modified":"2025-07-30T14:51:48","modified_gmt":"2025-07-30T06:51:48","slug":"%e9%85%8d%e7%bd%ae%e8%87%aa%e5%b7%b1%e7%9a%84ntp-%e6%9c%8d%e5%8a%a1%e5%99%a8%e5%81%9a%e6%97%b6%e9%97%b4%e5%90%8c%e6%ad%a5","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/49034.html","title":{"rendered":"\u914d\u7f6e\u81ea\u5df1\u7684NTP \u670d\u52a1\u5668\u505a\u65f6\u95f4\u540c\u6b65"},"content":{"rendered":"<h3>\u2705 \u63a8\u8350\u65b9\u6848&#xff1a;\u4f7f\u7528 chrony \u642d\u5efa NTP \u670d\u52a1\u5668&#xff08;\u9002\u7528\u4e8e CentOS 7\/8\/9&#xff09;<\/h3>\n<p>chrony \u662f CentOS \u63a8\u8350\u7684 NTP \u5b9e\u73b0&#xff0c;\u7cbe\u5ea6\u9ad8\u3001\u8d44\u6e90\u5360\u7528\u4f4e\u3001\u540c\u6b65\u5feb&#xff0c;\u9ed8\u8ba4\u5728 CentOS 8&#043; \u4e2d\u53d6\u4ee3\u4e86 ntpd\u3002<\/p>\n<hr \/>\n<h4>&#x1f527; \u4e00\u3001\u5b89\u88c5 chrony<\/h4>\n<p>sudo yum install -y chrony<\/p>\n<hr \/>\n<h4>&#x1f4c1; \u4e8c\u3001\u4fee\u6539\u914d\u7f6e \/etc\/chrony.conf<\/h4>\n<p>sudo vi \/etc\/chrony.conf<\/p>\n<p>\u627e\u5230\u5e76\u4fee\u6539\u6216\u6dfb\u52a0\u4ee5\u4e0b\u5185\u5bb9&#xff1a;<\/p>\n<h5>1. \u914d\u7f6e\u4e0a\u6e38 NTP \u670d\u52a1\u5668&#xff08;\u53ef\u7528\u516c\u7f51 NTP&#xff09;<\/h5>\n<p>\u4f8b\u5982&#xff1a;<\/p>\n<p>server ntp.aliyun.com iburst server ntp.tencent.com iburst<\/p>\n<h5>2. \u5141\u8bb8\u5185\u7f51\u5ba2\u6237\u7aef\u8bbf\u95ee\u672c NTP \u670d\u52a1\u5668&#xff1a;<\/h5>\n<p>&#xff08;\u5047\u8bbe\u5ba2\u6237\u7aef\u5728 192.168.1.0\/24 \u7f51\u6bb5&#xff09;<\/p>\n<p>allow 192.168.1.0\/24<\/p>\n<p>\u4e5f\u53ef\u4ee5\u4f7f\u7528 allow 0.0.0.0\/0 \u8868\u793a\u5141\u8bb8\u6240\u6709\u5730\u5740\u8bbf\u95ee&#xff08;\u4e0d\u5b89\u5168&#xff0c;\u614e\u7528&#xff09;<\/p>\n<hr \/>\n<h4>&#x1f503; \u4e09\u3001\u542f\u52a8\u5e76\u8bbe\u7f6e\u5f00\u673a\u81ea\u542f<\/h4>\n<p>sudo systemctl enable chronyd sudo systemctl start chronyd<\/p>\n<hr \/>\n<h4>&#x1f525; \u56db\u3001\u653e\u901a\u9632\u706b\u5899 UDP 123 \u7aef\u53e3<\/h4>\n<p>sudo firewall-cmd &#8211;add-service&#061;ntp &#8211;permanent sudo firewall-cmd &#8211;reload<\/p>\n<p>\u5982\u679c\u4f60\u6ca1\u6709\u4f7f\u7528 firewalld&#xff0c;\u7528 iptables&#xff1a;<\/p>\n<p>sudo iptables -A INPUT -p udp &#8211;dport 123 -j ACCEPT sudo service iptables save<\/p>\n<hr \/>\n<h4>&#x1f50d; \u4e94\u3001\u9a8c\u8bc1\u672c\u5730\u662f\u5426\u5728\u540c\u6b65<\/h4>\n<p>chronyc tracking chronyc sources -v<\/p>\n<h4>\u67e5\u770b\u662f\u5426\u76d1\u542c 123 \u7aef\u53e3&#xff1a;<\/h4>\n<p>sudo netstat -unlp | grep 123<\/p>\n<p>\u5e94\u770b\u5230 chronyd \u6b63\u5728\u76d1\u542c UDP 123\u3002<\/p>\n<hr \/>\n<h3>&#x1f9ea; \u516d\u3001\u5ba2\u6237\u7aef\u5982\u4f55\u4f7f\u7528\u4f60\u7684\u670d\u52a1\u5668\u540c\u6b65\u65f6\u95f4&#xff1f;<\/h3>\n<h4>1. \u786e\u4fdd systemd-timesyncd \u5df2\u5b89\u88c5\u5e76\u542f\u7528<\/h4>\n<h5>Ubuntu \/ Debian<\/h5>\n<p>sudo systemctl enable systemd-timesyncd<br \/>\nsudo systemctl start systemd-timesyncd<\/p>\n<h5>CentOS&#xff08;\u9ed8\u8ba4\u65e0 timesyncd&#xff0c;\u5efa\u8bae\u6539\u7528 chrony&#xff09;<\/h5>\n<hr \/>\n<h4>2. \u7f16\u8f91 timesyncd \u914d\u7f6e<\/h4>\n<p>sudo vi \/etc\/systemd\/timesyncd.conf<\/p>\n<p>\u4fee\u6539\u6216\u6dfb\u52a0&#xff1a;<\/p>\n<p>[Time] NTP&#061;\u4f60\u7684\u670d\u52a1\u5668IP\u6216\u57df\u540d<\/p>\n<p>\u793a\u4f8b&#xff1a;<\/p>\n<p>[Time] NTP&#061;192.168.1.100<\/p>\n<p>\u7136\u540e\u91cd\u542f\u670d\u52a1&#xff1a;<\/p>\n<p>sudo systemctl restart systemd-timesyncd<\/p>\n<p>\u542f\u7528 NTP \u81ea\u52a8\u540c\u6b65&#xff1a;<\/p>\n<p>sudo timedatectl set-ntp true<\/p>\n<hr \/>\n<h4>3. \u9a8c\u8bc1\u662f\u5426\u540c\u6b65\u6210\u529f<\/h4>\n<p>timedatectl status<\/p>\n<p>\u5e94\u770b\u5230&#xff1a;<\/p>\n<p>NTP service: active System clock synchronized: yes<\/p>\n<p>\u8fd8\u53ef\u4ee5\u67e5\u770b\u8be6\u7ec6\u4fe1\u606f&#xff1a;<\/p>\n<p>timedatectl show-timesync &#8211;all<\/p>\n<hr \/>\n<h3>&#x1f4cc; \u4e03\u3001\u8865\u5145\u8bf4\u660e&#xff1a;\u4f7f\u7528 ntpd&#xff08;\u65e7\u65b9\u6cd5&#xff0c;\u4e0d\u63a8\u8350&#xff09;<\/h3>\n<p>\u82e5\u4f60\u575a\u6301\u4f7f\u7528\u4f20\u7edf ntpd&#xff1a;<\/p>\n<p>sudo yum install ntp<br \/>\nsudo vi \/etc\/ntp.conf<\/p>\n<p>\u4fee\u6539&#xff1a;<\/p>\n<p>server ntp.aliyun.com iburst<br \/>\nrestrict 192.168.1.0 mask 255.255.255.0 nomodify notrap<\/p>\n<p>\u7136\u540e\u542f\u52a8\u670d\u52a1\u5e76\u5f00\u542f\u7aef\u53e3&#xff1a;<\/p>\n<p>sudo systemctl enable ntpd<br \/>\nsudo systemctl start ntpd<\/p>\n<hr \/>\n<h3>\u2705 \u603b\u7ed3&#xff1a;\u642d\u5efa NTP \u670d\u52a1\u5668\u6b65\u9aa4&#xff08;Chrony\u7248&#xff09;<\/h3>\n<table>\n<tr>\u6b65\u9aa4\u547d\u4ee4\u6216\u8bf4\u660e<\/tr>\n<tbody>\n<tr>\n<td>\u5b89\u88c5\u670d\u52a1<\/td>\n<td>yum install chrony<\/td>\n<\/tr>\n<tr>\n<td>\u7f16\u8f91\u914d\u7f6e<\/td>\n<td>\/etc\/chrony.conf&#xff0c;\u914d\u7f6e\u4e0a\u6e38\u65f6\u95f4\u6e90 &#043; allow \u7f51\u6bb5<\/td>\n<\/tr>\n<tr>\n<td>\u542f\u52a8\u670d\u52a1<\/td>\n<td>systemctl start chronyd<\/td>\n<\/tr>\n<tr>\n<td>\u5f00\u673a\u81ea\u542f<\/td>\n<td>systemctl enable chronyd<\/td>\n<\/tr>\n<tr>\n<td>\u653e\u901a\u9632\u706b\u5899<\/td>\n<td>firewall-cmd &#8211;add-service&#061;ntp &#8211;permanent<\/td>\n<\/tr>\n<tr>\n<td>\u5ba2\u6237\u7aef\u8fde\u63a5<\/td>\n<td>server &lt;\u670d\u52a1\u5668IP&gt; iburst<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb622\u6b21\uff0c\u70b9\u8d5e6\u6b21\uff0c\u6536\u85cf5\u6b21\u3002\u6b65\u9aa4\u547d\u4ee4\u6216\u8bf4\u660e\u5b89\u88c5\u670d\u52a1\u7f16\u8f91\u914d\u7f6e\uff0c\u914d\u7f6e\u4e0a\u6e38\u65f6\u95f4\u6e90 +allow \u7f51\u6bb5\u542f\u52a8\u670d\u52a1\u5f00\u673a\u81ea\u542f\u653e\u901a\u9632\u706b\u5899\u5ba2\u6237\u7aef\u8fde\u63a5server  iburst\u3002_ntp server<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[58,43,44],"topic":[],"class_list":["post-49034","post","type-post","status-publish","format-standard","hentry","category-server","tag-linux","tag-43","tag-44"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u914d\u7f6e\u81ea\u5df1\u7684NTP \u670d\u52a1\u5668\u505a\u65f6\u95f4\u540c\u6b65 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/49034.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u914d\u7f6e\u81ea\u5df1\u7684NTP \u670d\u52a1\u5668\u505a\u65f6\u95f4\u540c\u6b65 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb622\u6b21\uff0c\u70b9\u8d5e6\u6b21\uff0c\u6536\u85cf5\u6b21\u3002\u6b65\u9aa4\u547d\u4ee4\u6216\u8bf4\u660e\u5b89\u88c5\u670d\u52a1\u7f16\u8f91\u914d\u7f6e\uff0c\u914d\u7f6e\u4e0a\u6e38\u65f6\u95f4\u6e90 +allow \u7f51\u6bb5\u542f\u52a8\u670d\u52a1\u5f00\u673a\u81ea\u542f\u653e\u901a\u9632\u706b\u5899\u5ba2\u6237\u7aef\u8fde\u63a5server iburst\u3002_ntp server\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/49034.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-07-30T06:51:48+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/49034.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/49034.html\",\"name\":\"\u914d\u7f6e\u81ea\u5df1\u7684NTP \u670d\u52a1\u5668\u505a\u65f6\u95f4\u540c\u6b65 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-07-30T06:51:48+00:00\",\"dateModified\":\"2025-07-30T06:51:48+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/49034.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/49034.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/49034.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u914d\u7f6e\u81ea\u5df1\u7684NTP \u670d\u52a1\u5668\u505a\u65f6\u95f4\u540c\u6b65\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u914d\u7f6e\u81ea\u5df1\u7684NTP \u670d\u52a1\u5668\u505a\u65f6\u95f4\u540c\u6b65 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/49034.html","og_locale":"zh_CN","og_type":"article","og_title":"\u914d\u7f6e\u81ea\u5df1\u7684NTP \u670d\u52a1\u5668\u505a\u65f6\u95f4\u540c\u6b65 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb622\u6b21\uff0c\u70b9\u8d5e6\u6b21\uff0c\u6536\u85cf5\u6b21\u3002\u6b65\u9aa4\u547d\u4ee4\u6216\u8bf4\u660e\u5b89\u88c5\u670d\u52a1\u7f16\u8f91\u914d\u7f6e\uff0c\u914d\u7f6e\u4e0a\u6e38\u65f6\u95f4\u6e90 +allow \u7f51\u6bb5\u542f\u52a8\u670d\u52a1\u5f00\u673a\u81ea\u542f\u653e\u901a\u9632\u706b\u5899\u5ba2\u6237\u7aef\u8fde\u63a5server iburst\u3002_ntp server","og_url":"https:\/\/www.wsisp.com\/helps\/49034.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-07-30T06:51:48+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"1 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/49034.html","url":"https:\/\/www.wsisp.com\/helps\/49034.html","name":"\u914d\u7f6e\u81ea\u5df1\u7684NTP \u670d\u52a1\u5668\u505a\u65f6\u95f4\u540c\u6b65 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-07-30T06:51:48+00:00","dateModified":"2025-07-30T06:51:48+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/49034.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/49034.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/49034.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u914d\u7f6e\u81ea\u5df1\u7684NTP \u670d\u52a1\u5668\u505a\u65f6\u95f4\u540c\u6b65"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/49034","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=49034"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/49034\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=49034"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=49034"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=49034"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=49034"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}