{"id":121815,"date":"2023-02-01T22:04:25","date_gmt":"2023-02-01T14:04:25","guid":{"rendered":"http:\/\/www.idc.net\/help\/121815\/"},"modified":"2023-02-01T22:04:25","modified_gmt":"2023-02-01T14:04:25","slug":"linux%e4%bb%a3%e7%90%86%e6%9c%8d%e5%8a%a1%e5%99%a8%e6%90%ad%e5%bb%ba%e8%af%a6%e8%a7%a3-linuxproxy%e6%9c%8d%e5%8a%a1%e5%99%a8%e6%90%ad%e5%bb%ba","status":"publish","type":"post","link":"https:\/\/idc.net\/help\/121815\/","title":{"rendered":"Linux\u4ee3\u7406\u670d\u52a1\u5668\u642d\u5efa\u8be6\u89e3 (linuxproxy\u670d\u52a1\u5668\u642d\u5efa)"},"content":{"rendered":"<p>\u5728\u5f53\u4eca\u7684\u7f51\u7edc\u73af\u5883\u4e0b\uff0c\u4fdd\u62a4\u7528\u6237\u7684\u9690\u79c1\u548c\u786e\u4fdd\u5176\u5b89\u5168\u975e\u5e38\u91cd\u8981\u3002\u8fd9\u5bf9\u4e8e\u90a3\u4e9b\u5728\u7f51\u7edc\u4e0a\u8fdb\u884c\u654f\u611f\u6d3b\u52a8\u7684\u4eba\u6765\u8bf4\u5c24\u4e3a\u91cd\u8981\uff0c\u5982\u4e92\u8054\u7f51\u94f6\u884c\u3001\u5728\u7ebf\u8d2d\u7269\u3001\u793e\u4ea4\u5a92\u4f53\u7b49\u3002\u5176\u4e2d\u4e00\u79cd\u975e\u5e38\u6d41\u884c\u800c\u5b9e\u7528\u7684\u7f51\u7edc\u5de5\u5177\u662f\u4ee3\u7406\u670d\u52a1\u5668\u3002\u4f7f\u7528\u4ee3\u7406\u670d\u52a1\u5668\u53ef\u4ee5\u5728\u4e0d\u66b4\u9732\u81ea\u5df1IP\u5730\u5740\u7684\u60c5\u51b5\u4e0b\uff0c\u5728Internet\u4e0a\u533f\u540d\u6d4f\u89c8\uff0c\u9632\u6b62\u9ed1\u5ba2\u653b\u51fb\uff0c\u4ee5\u53ca\u66f4\u5feb\u7684\u8bbf\u95ee\u901f\u5ea6\u3002\u672c\u6587\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528Linux\u642d\u5efa\u4e00\u4e2a\u4ee3\u7406\u670d\u52a1\u5668\u3002<\/p>\n<p>\u4e4b\u4e00\u6b65\uff1a\u68c0\u67e5\u7cfb\u7edf<\/p>\n<p>\u5728\u5f00\u59cb\u4e4b\u524d\uff0c\u60a8\u9700\u8981\u767b\u5f55\u5230\u6b63\u5728\u8fd0\u884c\u7740Linux\u7cfb\u7edf\u7684\u673a\u5668\u4e0a\uff0c\u5e76\u786e\u4fdd\u60a8\u6240\u9700\u8981\u7684\u5de5\u5177\u548c\u8f6f\u4ef6\u5df2\u7ecf\u5b89\u88c5\u3002\u5982\u679c\u60a8\u5c1a\u672a\u5b89\u88c5\uff08\u6216\u8005\u4e0d\u786e\u5b9a\uff09\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u68c0\u67e5\u7cfb\u7edf\uff1a<\/p>\n<p>$ uname -a<\/p>\n<p>\u6b64\u547d\u4ee4\u663e\u793a\u673a\u5668\u7684\u4e00\u4e9b\u57fa\u672c\u4fe1\u606f\uff0c\u5982\u5f53\u524d\u8fd0\u884c\u7684Linux\u5185\u6838\u7248\u672c\u3001\u786c\u4ef6\u67b6\u6784\u548c\u64cd\u4f5c\u7cfb\u7edf\u540d\u79f0\u3002\u901a\u5e38\uff0cLinux\u5185\u6838\u7248\u672c\u548c\u786c\u4ef6\u67b6\u6784\u5bf9\u4e8e\u642d\u5efa\u4ee3\u7406\u670d\u52a1\u5668\u6765\u8bf4\u5e76\u4e0d\u91cd\u8981\uff0c\u4f46\u64cd\u4f5c\u7cfb\u7edf\u6807\u8bc6\u7b26\u975e\u5e38\u91cd\u8981\uff0c\u56e0\u4e3a\u60a8\u9700\u8981\u4f7f\u7528\u7279\u5b9a\u7684\u8f6f\u4ef6\u5305\u7ba1\u7406\u5668\u6765\u5b89\u88c5\u6240\u9700\u7684\u8f6f\u4ef6\u3002\u5bf9\u4e8e\u57fa\u4e8eDebian\u7684\u7cfb\u7edf\uff0c\u5982Ubuntu\u548cDebian\u81ea\u5e26\u7684\u8f6f\u4ef6\u5305\u7ba1\u7406\u5668\u662fAPT\uff1b\u800c\u5bf9\u4e8e\u57fa\u4e8eRed Hat\u7684\u7cfb\u7edf\uff0c\u5982Fedora\u548cCentOS\u5219\u4f7f\u7528YUM\u8f6f\u4ef6\u5305\u7ba1\u7406\u5668\u3002\u786e\u4fdd\u60a8\u5df2\u7ecf\u4e86\u89e3\u4e86\u60a8\u6240\u4f7f\u7528\u7684\u64cd\u4f5c\u7cfb\u7edf\uff0c\u5e76\u76f8\u5e94\u5730\u4f7f\u7528apt\u6216yum\u6765\u5b89\u88c5\u4ee5\u4e0b\u8f6f\u4ef6\u5305\uff1a<\/p>\n<p>$ sudo apt-get update<\/p>\n<p>$ sudo apt-get install squid<\/p>\n<p>$ sudo yum update<\/p>\n<p>$ sudo yum install squid<\/p>\n<p>SUID\u662f\u4e00\u4e2a\u975e\u5e38\u6d41\u884c\u7684\u4ee3\u7406\u670d\u52a1\u5668\u8f6f\u4ef6\uff0c\u5b83\u80fd\u591f\u901a\u8fc7\u6574\u5408\u7f13\u5b58\u548c\u8bbf\u95ee\u63a7\u5236\u5e2e\u52a9\u7ec4\u7ec7\u548c\u7ba1\u7406\u8bb8\u591a\u7f51\u7edc\u5185\u7684\u5bbd\u5e26\u5b58\u53d6\u3002\u5728\u6210\u529f\u5b89\u88c5Squid\u540e\uff0c\u60a8\u9700\u8981\u7f16\u8f91\u53ef\u7528\u4e8e\u914d\u7f6e\u5b83\u7684\u6587\u4ef6 \u201c\/etc\/squid\/squid.conf\u201d \u6587\u4ef6\u3002\u548c\u8bb8\u591a\u5176\u4ed6Linux\u914d\u7f6e\u6587\u4ef6\u4e00\u6837\uff0csquid.conf\u662f\u4e00\u4e2a\u6587\u672c\u6587\u4ef6\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u4efb\u4f55\u6587\u672c\u7f16\u8f91\u5668\u6765\u6253\u5f00\u548c\u7f16\u8f91\u5b83\u3002<\/p>\n<p>\u7b2c\u4e8c\u6b65\uff1a\u66f4\u6539\u914d\u7f6e<\/p>\n<p>\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u6253\u5f00\u6587\u4ef6\uff0c\u67e5\u627e\u4ee5\u4e0b\u884c\u5e76\u66f4\u6539\u8fd9\u4e9b\u884c\uff0c\u914d\u7f6eSquid\u5bf9\u51fa\u7ad9\u7f51\u7ad9\u7684\u8bbf\u95ee\uff1a<\/p>\n<p>$ sudo nano \/etc\/squid\/squid.conf<\/p>\n<p>http_access allow all<\/p>\n<p># This line makes sure that accesses are allowed<\/p>\n<p>http_port 3128<\/p>\n<p># This specifies the port number that our proxy server will listen to. For most purposes, 3128 is a good default<\/p>\n<p>acl mynet src 192.168.0.0\/16<\/p>\n<p># This line specifies the IP range our proxy server will serve<\/p>\n<p>http_access allow mynet<\/p>\n<p># This line allows users within our IP range to access the proxy server<\/p>\n<p>\u5c06\u6ce8\u91ca\u7b26\u53f7\u201c#\u201d\u5728\u884c\u9996\u5220\u9664\uff0c\u7136\u540e\u66f4\u6539\u8fd9\u4e9b\u884c\u4ee5\u6ee1\u8db3\u60a8\u7684\u9700\u6c42\u3002\u5728\u6b64\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u5141\u8bb8\u5bf9\u51fa\u7ad9\u7f51\u7ad9\u7684\u8bbf\u95ee\uff0c\u5e76\u8bbe\u7f6e\u4e86\u9ed8\u8ba4\u7aef\u53e3\u4e3a3128\uff0c\u60a8\u53ef\u4ee5\u6839\u636e\u9700\u8981\u66f4\u6539\u6b64\u7aef\u53e3\u3002\u6b64\u5916\uff0c\u6211\u4eec\u6307\u5b9a\u4e86192.168.0.0\/16\u7684IP\u5730\u5740\u8303\u56f4\uff0c\u4ee5\u6307\u5b9a\u5141\u8bb8\u7684\u7528\u6237\u3002\u60a8\u53ef\u4ee5\u4fee\u6539\u4e3a\u9002\u7528\u4e8e\u60a8\u7684\u7f51\u7edc\u73af\u5883\u3002<\/p>\n<p>\u7b2c\u4e09\u6b65\uff1a\u542f\u52a8\u4ee3\u7406\u670d\u52a1\u5668<\/p>\n<p>\u4fdd\u5b58\u5e76\u9000\u51fa\u914d\u7f6e\u6587\u4ef6\u540e\uff0c\u60a8\u9700\u8981\u91cd\u65b0\u542f\u52a8SUID\u4ee3\u7406\u670d\u52a1\u5668\u3002\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5141\u8bb8Squid\u5728\u7cfb\u7edf\u542f\u52a8\u65f6\u81ea\u52a8\u542f\u52a8\uff1a<\/p>\n<p>$ sudo systemctl enable squid<\/p>\n<p>\u7136\u540e\uff0c\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\u4ee5\u542f\u52a8Squid\u4ee3\u7406\u670d\u52a1\u5668\uff1a<\/p>\n<p>$ sudo systemctl start squid<\/p>\n<p>\u73b0\u5728\uff0cLinux\u5b89\u88c5\u5e76\u914d\u7f6e\u5b8c\u6210\u4ee3\u7406\u670d\u52a1\u5668\uff0c\u60a8\u53ef\u4ee5\u5f00\u59cb\u4f7f\u7528\u5b83\u4e86\u3002<\/p>\n<p>\u7b2c\u56db\u6b65\uff1a\u914d\u7f6e\u6d4f\u89c8\u5668<\/p>\n<p>\u4e3a\u4e86\u4f7f\u7528\u4ee3\u7406\u670d\u52a1\u5668\uff0c\u60a8\u9700\u8981\u914d\u7f6e\u6d4f\u89c8\u5668\u4e2d\u7684\u4ee3\u7406\u8bbe\u7f6e\u3002\u8fd9\u4e2a\u8bbe\u7f6e\u53ef\u4ee5\u5728\u6d4f\u89c8\u5668\u7684Internet\u9009\u9879\u4e2d\u627e\u5230\u3002\u901a\u5e38\u8fd9\u4e2a\u9009\u9879\u4f4d\u4e8e\u201c\u9ad8\u7ea7\u201d\u6216\u201c\u7f51\u7edc\u201d\u9009\u9879\u5361\u4e0b\u3002<\/p>\n<p>\u5728\u6b64\u8bbe\u7f6e\u6846\u4e2d\uff0c\u60a8\u9700\u8981\u6307\u5b9a\u4ee3\u7406\u670d\u52a1\u5668IP\u548c\u7aef\u53e3\u3002\u5728\u524d\u8ff0\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u5c06Proxy\u670d\u52a1\u5668IP\u914d\u7f6e\u4e3alocalhost\u6216127.0.0.1\uff0c\u7aef\u53e3\u4e3a3128\u3002\u5982\u679c\u60a8\u6b63\u5728\u8fd0\u884c\u53e6\u4e00\u53f0\u673a\u5668\u4e0a\u7684\u4ee3\u7406\u670d\u52a1\u5668\uff0c\u5219\u5e94\u4f7f\u7528\u5176IP\u5730\u5740\u3002<\/p>\n<p>\u4f7f\u7528\u4ee3\u7406\u670d\u52a1\u5668\u7684\u597d\u5904\u662f\u663e\u800c\u6613\u89c1\u7684\uff0c\u4f46\u4f7f\u7528\u4e0d\u5f53\u53ef\u80fd\u4f1a\u5bfc\u81f4\u4e00\u4e9b\u95ee\u9898\uff0c\u5982\u8bbf\u95ee\u7f13\u6162\u3001\u7f51\u7edc\u4e0a\u7684\u6570\u636e\u6cc4\u6f0f\u7b49\u7b49\u3002\u4e3a\u4e86\u786e\u4fdd\u66f4\u4f73\u6027\u80fd\u548c\u5b89\u5168\uff0c\u8bf7\u786e\u4fdd\u4f7f\u7528\u5f3a\u5927\u7684\u5bc6\u7801\u4fdd\u62a4Proxy\u670d\u52a1\u5668\uff0c\u5e76\u8bbe\u7f6e\u8bbf\u95ee\u63a7\u5236\u89c4\u5219\uff0c\u4ee5\u4fbf\u53ea\u5141\u8bb8\u60a8\u4fe1\u4efb\u7684\u7528\u6237\u4f7f\u7528\u3002<\/p>\n<p><strong>\u76f8\u5173\u95ee\u9898\u62d3\u5c55\u9605\u8bfb\uff1a<\/strong><\/p>\n<ul>\n<li>Linux \u642d\u5efa Nginx \uff08\u56fe\u7247\u670d\u52a1\u5668\uff09<\/li>\n<li>\u600e\u6837\u8bbe\u7f6e Linux \u865a\u62df\u673a\u901a\u8fc7\u4ee3\u7406\u670d\u52a1\u5668\u4e0a\u7f51<\/li>\n<li>linux\u4e0antp\u65f6\u949f\u670d\u52a1\u5668\u642d\u5efa<\/li>\n<\/ul>\n<h3>Linux \u642d\u5efa Nginx \uff08\u56fe\u7247\u670d\u52a1\u5668\uff09<\/h3>\n<p>\u6253\u5f00nginx\u5b98\u7f51 <\/p>\n<\/p>\n<p> yum -y install gcc zlib zlib-devel pcre-devel openssl openssl-devel<\/p>\n<p> cd \/usr\/local\/<\/p>\n<p> tar -zxvf nginx-1.20.1.tar.gz<\/p>\n<p> .\/configure \u2013with-http_ssl_module<\/p>\n<p> \u7f16\u8bd1\u53c2\u6570\u6709\u5f88\u591a\uff0c\u8fd9\u8fb9\u6211\u53ea\u589e\u52a0\u4e86SSL\u6a21\u5757\uff0c\u5c0f\u4f19\u4f34\u53ef\u4ee5\u6839\u636e\u81ea\u8eab\u60c5\u51b5\u8c03\u6574<\/p>\n<p> \u2013prefix=PATH\uff1a\u6307\u5b9a nginx \u7684\u5b89\u88c5\u76ee\u5f55<\/p>\n<p> \u2013conf-path=PATH\uff1a\u6307\u5b9a nginx.conf \u914d\u7f6e\u6587\u4ef6\u8def\u5f84<\/p>\n<p> \u2013user=NAME\uff1anginx \u5de5\u4f5c\u8fdb\u7a0b\u7684\u7528\u6237<\/p>\n<p> \u2013with-pcre\uff1a\u5f00\u542f PCRE \u6b63\u5219\u8868\u8fbe\u5f0f\u7684\u652f\u6301<\/p>\n<p> \u2013with-http_ssl_module\uff1a\u542f\u52a8 SSL \u7684\u652f\u6301<\/p>\n<p> \u2013with-http_stub_status_module\uff1a\u7528\u4e8e\u76d1\u63a7 Nginx \u7684\u72b6\u6001<\/p>\n<p> \u2013with-http-realip_module\uff1a\u5141\u8bb8\u6539\u53d8\u5ba2\u6237\u7aef\u8bf7\u6c42\u5934\u4e2d\u5ba2\u6237\u7aef IP \u5730\u96f9\u69d0\u5219\u5740<\/p>\n<p> \u2013with-file-aio\uff1a\u542f\u7528 File AIO<\/p>\n<p> \u2013add-module=PATH\uff1a\u6dfb\u52a0\u7b2c\u4e09\u65b9\u5916\u90e8\u6a21\u5757<\/p>\n<p> make<\/p>\n<p> \u6267\u884c\u5b8c\u4e0a\u8ff0\u547d\u4ee4\u540e\uff0c\u5728\u89e3\u538b\u76ee\u5f55\u4e0b\uff0c\u591a\u51fa\u4e00\u4e2aMakefile\u6587\u4ef6<\/p>\n<p> make install<\/p>\n<p> \u56e0\u7f16\u8bd1\u65f6\u672a\u6307\u5b9a\u5b89\u88c5\u76ee\u5f55\uff0c\u6267\u884cmake install \u547d\u4ee4\u540e\u770b\u5230\u53cd\u9988\u65e5\u5fd7\u4fe1\u606f\uff0c\u5b9e\u9645\u5b89\u88c5\u76ee\u5f55\u4e3a\/usr\/local\/nginx<\/p>\n<p> \u8fdb\u5165\u5b9e\u9645\u5b89\u88c5\u76ee\u5f55\uff0c\u770b\u770b\uff0c\u5e76\u5728\u5176in\u76ee\u5f55\u4e0b\u6267\u884c\u542f\u52a8nginx<\/p>\n<p> cd \/usr\/local\/nginx\/<\/p>\n<p> \u6d4f\u89c8\u5668\u8bbf\u95ee <\/p>\n<\/p>\n<p> , \u663e\u793a\u5982\u4e0b\u56fe\u5219\u4ee3\u8868\u90e8\u7f72\u6210\u529f<\/p>\n<\/p>\n<p> \u8fdb\u5165 \/usr\/local\/\u660e\u9547nginx\/conf\/ \u6587\u4ef6\u5939\uff0c\u627e\u5230nginx.conf \u6587\u4ef6<\/p>\n<p> worker_processes 1;<\/p>\n<p> events {<\/p>\n<p> worker_connections 1024;<\/p>\n<p> }<\/p>\n<p> http {<\/p>\n<p> includemime.types;<\/p>\n<p> default_type application\/octet-stream;<\/p>\n<p> sendfileon;<\/p>\n<p> keepalive_timeout 65;<\/p>\n<p> server {<\/p>\n<p> listen;<\/p>\n<p> server_name localhost;<\/p>\n<p> location ~ .*.(gif|jpg|jpeg|png|apk|pdf)$ {<\/p>\n<p> expires 24h;<\/p>\n<p> root \/usr\/local\/img\/;#\u6307\u5b9a\u56fe\u7247\u5b58\u653e\u8def\u5f84<\/p>\n<p> access_log \/usr\/local\/nginx\/logs\/images.log;#\u65e5\u5fd7\u8def\u5f84<\/p>\n<p> proxy_store on;<\/p>\n<p> proxy_store_access user:rw group:rw all:rw;<\/p>\n<p> proxy_temp_path\/usr\/local\/img\/;#\u4ee3\u7406\u4e34\u65f6\u8def\u5f84<\/p>\n<p> proxy_redirectoff;<\/p>\n<p> }<\/p>\n<p> \u4fee\u6539\u914d\u7f6e\u6587\u4ef6\uff0c\u6e90\u68da\u5185\u5bb9\u5982\u4e0a<\/p>\n<\/p>\n<p> cd \/usr\/local\/nginx\/in<\/p>\n<p> .\/nginx -s reload<\/p>\n<p> \u6d4f\u89c8\u5668\u8f93\u5165 <\/p>\n<\/p>\n<p>88\/1.png ,\u67e5\u770b\u662f\u5426\u80fd\u6b63\u5e38\u663e\u793a\u56fe\u7247<\/p>\n<h3>\u600e\u6837\u8bbe\u7f6e Linux \u865a\u62df\u673a\u901a\u8fc7\u4ee3\u7406\u670d\u52a1\u5668\u4e0a\u7f51<\/h3>\n<p>\u9996\u5148\u4f7f\u7528\u4e3b\u673a\u7684\u672c\u5730\u8fde\u63a5\u6709\u7ebf\u7f51\u5361\u8fde\u63a5\u5185\u7f51\u4ea4\u6362\u673a\u6216\u65e0\u7ebf\u7f51\u5361\u8fde\u63a5\u5185\u7f51WiFi<\/p>\n<p>\u8bbe\u7f6e\u865a\u62df\u673a\u7f51\u7edc\u9002\u914d\u5668\u4e3a\u4e24\u5757\u7f51\u5361\uff0c\u4e00\u5757\u7f51\u5361\u4e3a\u6865\u63a5\u6a21\u5f0f\uff0c\u81ea\u52a8\u6865\u63a5\u5bf9\u5e94\u7684\u6709\u7ebf\u6216\u65e0\u7ebf\u7f51\u5361\uff0c\u5728\u7cfb\u7edf\u4e2d\u5b89\u88c5\u5b89\u5168\u5de5\u5177\uff0c\u5e76\u8ba4\u8bc1\u6210\u529f\uff0c\u786e\u4fdd\u865a\u62df\u673a\u80fd\u4e0a\u7f51<\/p>\n<p>\u53e6\u4e00\u5757\u7f51\u5361\u8bbe\u7f6e\u4e3ahostonly\uff08\u4ec5\u4e3b\u673a\u6a21\u5f0f\uff09\uff0c\u540c\u65f6\u5728\u865a\u62df\u673a\u4e2d\u5728\u4e4b\u4e00\u5757\u7f51\u5361\u4e0a\u53f3\u952e\u5c5e\u6027\u2014\u2014\u9ad8\u7ea7\uff0c\u542f\u7528ICS\uff08internet \u8fde\u63a5\u5171\u4eab\uff09\uff0c\u4f5c\u7528\u7f51\u5361\u4e3a\u7b2c\u4e8c\u5757\u5bf9\u5e94\u4ec5\u4e3b\u673a\u7a57\u4eae\u9547\u6a21\u5f0f\u7684\u7f51\u5361\uff08\u9ed8\u8ba4\u7cfb\u7edf\u4f1a\u4fee\u6539\u8fd9\u5757\u952e\u5e76\u7f51\u5361\u7684ip\u5730\u5740\u4e3a192.168.0.1\uff09<\/p>\n<p>\u5728\u4e3b\u673a\u731c\u7c97\u7f51\u7edc\u8fde\u63a5\u4e2d\u628avmnet1\u8fd9\u5757\u865a\u62df\u7f51\u5361\uff0c\u8bbe\u7f6e\u4e3aDHCP\u5373\u53ef\uff08\u6216\u8005\u624b\u52a8\u6307\u5b9a\u4e3a192.168.0.2\/255.255.255.0\uff0c\u7f51\u5173192.168.0.1\uff0c\u8bbe\u7f6e\u5bf9\u5e94dns\u5373\u53ef\uff09<\/p>\n<p>\u5728\u4e3b\u673a\u4e2d\uff0c\u5176\u5b9e\u53ea\u6709vmnet1\u662f\u80fd\u4e0a\u7f51\u7684\u3002<\/p>\n<h3>linux\u4e0antp\u65f6\u949f\u670d\u52a1\u5668\u642d\u5efa<\/h3>\n<p>\u914d\u7f6e\u7684\u65f6\u949f\u670d\u52a1\u5668\u7684ip\u5730\u5740\u4e3a192.168.100.116<\/p>\n<p> \u4e4b\u4e00\u6b65&nbsp; \u4e3a\u670d\u52a1\u5668\u548c\u5ba2\u6237\u673a\u5b89\u88c5ntp&nbsp; ntpdate<\/p>\n<p> #yum install ntp ntpdate -y\u7b2c\u4e8c\u6b65 \u67e5\u627e\u65f6\u95f4\u540c\u6b65\u670d\u52a1\u5668<\/p>\n<\/p>\n<p> #\u5728\u91cc\u9762\u53ef\u4ee5\u627e\u5230\u4e2d\u56fd\u7b2c\u4e09\u6b65&nbsp; \u7f16\u8f91 \/etc\/ntp.conf<\/p>\n<p> #vim \/etc\/ntp.conf server 0.cn.pool.ntp.org<\/p>\n<\/p>\n<p> server 1.cn.pool.ntp.org<\/p>\n<p> server 2.cn.pool.ntp.org<\/p>\n<p> server 3.cn.pool.ntp.org #\u4ee5\u4e0a\u56db\u4e2a\u662f\u65f6\u95f4\u540c\u6b65\u670d\u52a1\u5668server 127.127.1.0 iburst local clock #\u5f53\u5916\u90e8\u65f6\u95f4\u4e0d\u53ef\u7528\u65f6\uff0c\u4f7f\u7528\u672c\u5730\u65f6\u95f4restrict 192.168.10.1 mask 255.255.255.0 nomodify #\u5141\u8bb8\u66f4\u65b0\u7684IP\u5730\u5740\u6bb5\u7b2c\u56db\u6b65&nbsp; \u542f\u52a8ntp\u670d\u52a1<\/p>\n<p> #systemctl start ntpd\u7b2c\u4e94\u6b65&nbsp; \u9a8c\u8bc1\u670d\u52a1<\/p>\n<\/p>\n<p> #ntpq -p&nbsp; &nbsp; remoterefid&nbsp; &nbsp; &nbsp; st t when poll reach&nbsp; delay&nbsp; offset&nbsp; jitter<\/p>\n<\/p>\n<p> ==============================================================================<\/p>\n<p> 120.25.115.19&nbsp; .INIT.u0&nbsp; &nbsp; 0\u2026000<\/p>\n<p> ntp6.flashdance .INIT.u0&nbsp; &nbsp; 0\u2026000<\/p>\n<p> time5.aliyun.co .INIT.u0&nbsp; &nbsp; 0\u2026000<\/p>\n<p> 85.199.214.101&nbsp; .INIT.u0&nbsp; &nbsp; 0\u2026000<\/p>\n<p> biisoni.miuku.n .INIT.u0&nbsp; &nbsp; 0\u2026000<\/p>\n<p> ntp5.flashdance .INIT.u0&nbsp; &nbsp; 0\u2026000<\/p>\n<p> leontp.ccgs.wa. .INIT.u0&nbsp; &nbsp; 0\u2026000<\/p>\n<p> ntp1.ams1.nl.le .INIT.u0&nbsp; &nbsp; 0\u2026000<\/p>\n<p> *LOCAL(0).LOCL.&nbsp; &nbsp;\u4e1b\u660e\u6ca1l1&nbsp; &nbsp; 0\u2026000<\/p>\n<p> \u7b2c\u516d\u6b65&nbsp; \u8fdc\u7a0b\u5ba2\u6237\u7aef\u65f6\u95f4\u540c\u6b65\u6d4b\u8bd5<\/p>\n<p> #ntpdate 192.168.10.Dec 20:55:08 ntpdate: adjust time server 172.18.68.31 offset -0.sec<\/p>\n<\/p>\n<p> \u7b2c\u4e03\u6b65 \u5ba2\u6237\u7aef\u6e17\u7eb3\u8bbe\u7f6e\u8ba1\u5212\u4efb\u52a1\uff0c\u6bcf\u5929\u665a\u4e0a1\u70b9\u540c\u6b65\u65f6\u95f4<\/p>\n<p> crontab -e<\/p>\n<p>* * * root \/usr\/in\/ntpdate 192.168.10.116; \/usr\/in\/clock -w<\/p>\n<p> EDT \u65f6\u95f4\u5373\u7f8e\u56fd\u4e1c\u90e8\u65f6\u95f4\u3002\u8fd9\u91cc\u8981\u6539\u4e3a\u5317\u4eac\u65f6\u95f4\u5373\u53ef\uff1a<\/p>\n<p> \u547d\u4ee4\u5982\u4e0b\uff1a<\/p>\n<p> root@ubuntu# mv \/etc\/localtime \/etc\/localtime.bak&nbsp;<\/p>\n<p> root@ubuntu# ln -s \/usr\/share\/zoneinfo\/Asia\/Shanghai&nbsp; \/etc\/localtime&nbsp;<\/p>\n<p> root@ubuntu# date&nbsp;<\/p>\n<p> \u4fee\u6539116\u670d\u52a1\u5668\u672c\u673a\u7684ntp\u65f6\u95f4\u69d0\u6e17\u540c\u6b65<\/p>\n<p> systemctl stop ntpd<\/p>\n<p> ntpdate cn.pool.ntp.org<\/p>\n<p> systemctl start ntpd<\/p>\n<p>rpm -qa |grep ntp&nbsp; &nbsp; &nbsp;#\u68c0\u67e5ntp\u7248\u672c<\/p>\n<p> service ntpd status&nbsp; &nbsp; #\u67e5\u8be2ntp\u670d\u52a1\u72b6\u6001<\/p>\n<p> service ntpd start&nbsp; &nbsp; &nbsp; #\u542f\u52a8<\/p>\n<p> service ntpd stop&nbsp; &nbsp; &nbsp; #\u505c\u6b62<\/p>\n<p> service ntpd restart&nbsp; &nbsp;#\u91cd\u542f<\/p>\n<p>\u5173\u4e8elinuxproxy\u670d\u52a1\u5668\u642d\u5efa\u7684\u4ecb\u7ecd\u5230\u6b64\u5c31\u7ed3\u675f\u4e86\uff0c\u4e0d\u77e5\u9053\u4f60\u4ece\u4e2d\u627e\u5230\u4f60\u9700\u8981\u7684\u4fe1\u606f\u4e86\u5417 \uff1f\u5982\u679c\u4f60\u8fd8\u60f3\u4e86\u89e3\u66f4\u591a\u8fd9\u65b9\u9762\u7684\u4fe1\u606f\uff0c\u8bb0\u5f97\u6536\u85cf\u5173\u6ce8\u672c\u7ad9\u3002<\/p>\n<p><a href=\"http:https:\/\/idc.net\/\">\u9999\u6e2f\u670d\u52a1\u5668<\/a>\u9996\u9009\u540e\u6d6a\u4e91\uff0c2H2G\u9996\u670810\u5143\u5f00\u901a\u3002<br \/>\u540e\u6d6a\u4e91\uff08www.IDC.Net\uff09\u63d0\u4f9b\u7b80\u5355\u597d\u7528\uff0c\u4ef7\u683c\u539a\u9053\u7684\u9999\u6e2f\/\u7f8e\u56fd\u4e91\u670d\u52a1\u5668\u548c\u72ec\u7acb\u670d\u52a1\u5668\u3002IDC+ISP+ICP\u8d44\u8d28\u3002ARIN\u548cAPNIC\u4f1a\u5458\u3002\u6210\u719f\u6280\u672f\u56e2\u961f15\u5e74\u884c\u4e1a\u7ecf\u9a8c\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728\u5f53\u4eca\u7684\u7f51\u7edc\u73af\u5883\u4e0b\uff0c\u4fdd\u62a4\u7528\u6237\u7684\u9690\u79c1\u548c\u786e\u4fdd\u5176\u5b89\u5168\u975e\u5e38\u91cd\u8981\u3002\u8fd9\u5bf9\u4e8e\u90a3\u4e9b\u5728\u7f51\u7edc\u4e0a\u8fdb\u884c\u654f\u611f\u6d3b\u52a8\u7684\u4eba\u6765\u8bf4\u5c24\u4e3a\u91cd\u8981\uff0c\u5982\u4e92\u8054 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[34],"tags":[],"class_list":["post-121815","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts\/121815","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/comments?post=121815"}],"version-history":[{"count":0,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts\/121815\/revisions"}],"wp:attachment":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/media?parent=121815"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/categories?post=121815"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/tags?post=121815"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}