<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Terminal on NetUtil</title>
    <link>https://www.netutil.app/zh-hans/tags/terminal/</link>
    <description>Recent content in Terminal on NetUtil</description>
    <generator>Hugo</generator>
    <language>zh-Hans</language>
    <lastBuildDate>Sat, 16 May 2026 00:00:00 +0000</lastBuildDate>
    <atom:link href="https://www.netutil.app/zh-hans/tags/terminal/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>如何在macOS上刷新DNS缓存（Sequoia、Sonoma、Ventura）</title>
      <link>https://www.netutil.app/zh-hans/blog/flush-dns-cache-mac/</link>
      <pubDate>Sat, 16 May 2026 00:00:00 +0000</pubDate>
      <guid>https://www.netutil.app/zh-hans/blog/flush-dns-cache-mac/</guid>
      <description>&lt;p&gt;DNS缓存问题很容易被误诊。您更新了域名记录，等待传播完成，然后打开浏览器，旧网站仍然加载。或者曾经能正常访问的网站突然拒绝连接。服务器没问题，您的网络没问题，问题是您的Mac缓存了一个过时的DNS答案，并且仍然在使用它。&lt;/p&gt;&#xA;&lt;p&gt;刷新DNS缓存会告诉macOS忘记那些存储的答案，重新从头开始查询。只需一条命令，大约五秒钟。&lt;/p&gt;&#xA;&lt;h2 id=&#34;为什么mac要缓存dns记录&#34;&gt;为什么Mac要缓存DNS记录&lt;/h2&gt;&#xA;&lt;p&gt;每次您访问网站时，Mac都需要将域名（如&lt;code&gt;example.com&lt;/code&gt;）转换为IP地址。这个转换过程是这样的：Mac首先检查本地DNS缓存，然后询问DNS解析器（通常是您ISP的服务器或公共解析器如1.1.1.1），如果两者都没有答案，解析器会联系该域名的权威名称服务器。&lt;/p&gt;&#xA;&lt;figure class=&#34;blog-svg&#34; role=&#34;img&#34; aria-labelledby=&#34;dns-flow-title dns-flow-desc&#34;&gt;&#xA;  &lt;svg viewBox=&#34;0 0 720 180&#34; xmlns=&#34;http://www.w3.org/2000/svg&#34;&#xA;       style=&#34;max-width: 100%; height: auto;&#34;&gt;&#xA;    &lt;title id=&#34;dns-flow-title&#34;&gt;DNS resolution flow on macOS&lt;/title&gt;&#xA;    &lt;desc id=&#34;dns-flow-desc&#34;&gt;A four-step diagram showing DNS resolution: Mac checks local cache, then queries DNS resolver, then resolver contacts authoritative server, then IP address is returned to the Mac.&lt;/desc&gt;&#xA;    &lt;style&gt;&#xA;      .dns-label { font-family: -apple-system, system-ui, sans-serif; font-size: 13px; fill: #1d1d1f; text-anchor: middle; }&#xA;      .dns-sublabel { font-family: -apple-system, system-ui, sans-serif; font-size: 11px; fill: #6e6e73; text-anchor: middle; }&#xA;      .dns-box { fill: #F5F5F7; stroke: #D2D2D7; stroke-width: 1.5; }&#xA;      .dns-box-highlight { fill: #E8F4FF; stroke: #007AFF; stroke-width: 1.5; }&#xA;      .dns-arrow { stroke: #8E8E93; stroke-width: 2; fill: none; marker-end: url(#dns-arrow-head); }&#xA;      .dns-return { stroke: #34C759; stroke-width: 1.5; fill: none; stroke-dasharray: 5,3; marker-end: url(#dns-arrow-green); }&#xA;      @media (prefers-color-scheme: dark) {&#xA;        .dns-label { fill: #F5F5F7; }&#xA;        .dns-sublabel { fill: #98989D; }&#xA;        .dns-box { fill: #2C2C2E; stroke: #48484A; }&#xA;        .dns-box-highlight { fill: #1C3A5E; stroke: #0A84FF; }&#xA;      }&#xA;      @media (prefers-reduced-motion: reduce) {&#xA;        .dns-animated { animation: none !important; }&#xA;      }&#xA;      @keyframes fadeIn {&#xA;        from { opacity: 0; transform: translateY(4px); }&#xA;        to { opacity: 1; transform: translateY(0); }&#xA;      }&#xA;      .dns-step1 { animation: fadeIn 0.4s ease-out 0.1s both; }&#xA;      .dns-step2 { animation: fadeIn 0.4s ease-out 0.5s both; }&#xA;      .dns-step3 { animation: fadeIn 0.4s ease-out 0.9s both; }&#xA;      .dns-step4 { animation: fadeIn 0.4s ease-out 1.3s both; }&#xA;      .dns-return-line { animation: fadeIn 0.4s ease-out 1.7s both; }&#xA;    &lt;/style&gt;&#xA;    &lt;defs&gt;&#xA;      &lt;marker id=&#34;dns-arrow-head&#34; markerWidth=&#34;9&#34; markerHeight=&#34;7&#34; refX=&#34;9&#34; refY=&#34;3.5&#34; orient=&#34;auto&#34;&gt;&#xA;        &lt;polygon points=&#34;0 0, 9 3.5, 0 7&#34; fill=&#34;#8E8E93&#34; /&gt;&#xA;      &lt;/marker&gt;&#xA;      &lt;marker id=&#34;dns-arrow-green&#34; markerWidth=&#34;9&#34; markerHeight=&#34;7&#34; refX=&#34;9&#34; refY=&#34;3.5&#34; orient=&#34;auto&#34;&gt;&#xA;        &lt;polygon points=&#34;0 0, 9 3.5, 0 7&#34; fill=&#34;#34C759&#34; /&gt;&#xA;      &lt;/marker&gt;&#xA;    &lt;/defs&gt;&#xA;    &lt;!-- Box 1: Mac --&gt;&#xA;    &lt;g class=&#34;dns-step1&#34;&gt;&#xA;      &lt;rect x=&#34;20&#34; y=&#34;50&#34; width=&#34;120&#34; height=&#34;70&#34; rx=&#34;10&#34; class=&#34;dns-box-highlight&#34; /&gt;&#xA;      &lt;text x=&#34;80&#34; y=&#34;82&#34; class=&#34;dns-label&#34; font-weight=&#34;600&#34;&gt;Your Mac&lt;/text&gt;&#xA;      &lt;text x=&#34;80&#34; y=&#34;99&#34; class=&#34;dns-sublabel&#34;&gt;local DNS cache&lt;/text&gt;&#xA;    &lt;/g&gt;&#xA;    &lt;!-- Arrow 1→2 --&gt;&#xA;    &lt;g class=&#34;dns-step2&#34;&gt;&#xA;      &lt;line x1=&#34;141&#34; y1=&#34;85&#34; x2=&#34;189&#34; y2=&#34;85&#34; class=&#34;dns-arrow&#34; /&gt;&#xA;    &lt;/g&gt;&#xA;    &lt;!-- Box 2: DNS Resolver --&gt;&#xA;    &lt;g class=&#34;dns-step2&#34;&gt;&#xA;      &lt;rect x=&#34;190&#34; y=&#34;50&#34; width=&#34;140&#34; height=&#34;70&#34; rx=&#34;10&#34; class=&#34;dns-box&#34; /&gt;&#xA;      &lt;text x=&#34;260&#34; y=&#34;82&#34; class=&#34;dns-label&#34; font-weight=&#34;600&#34;&gt;DNS Resolver&lt;/text&gt;&#xA;      &lt;text x=&#34;260&#34; y=&#34;99&#34; class=&#34;dns-sublabel&#34;&gt;1.1.1.1 or ISP&lt;/text&gt;&#xA;    &lt;/g&gt;&#xA;    &lt;!-- Arrow 2→3 --&gt;&#xA;    &lt;g class=&#34;dns-step3&#34;&gt;&#xA;      &lt;line x1=&#34;331&#34; y1=&#34;85&#34; x2=&#34;379&#34; y2=&#34;85&#34; class=&#34;dns-arrow&#34; /&gt;&#xA;    &lt;/g&gt;&#xA;    &lt;!-- Box 3: Authoritative NS --&gt;&#xA;    &lt;g class=&#34;dns-step3&#34;&gt;&#xA;      &lt;rect x=&#34;380&#34; y=&#34;50&#34; width=&#34;150&#34; height=&#34;70&#34; rx=&#34;10&#34; class=&#34;dns-box&#34; /&gt;&#xA;      &lt;text x=&#34;455&#34; y=&#34;82&#34; class=&#34;dns-label&#34; font-weight=&#34;600&#34;&gt;Authoritative NS&lt;/text&gt;&#xA;      &lt;text x=&#34;455&#34; y=&#34;99&#34; class=&#34;dns-sublabel&#34;&gt;holds real records&lt;/text&gt;&#xA;    &lt;/g&gt;&#xA;    &lt;!-- Arrow 3→4 (IP back) --&gt;&#xA;    &lt;g class=&#34;dns-step4&#34;&gt;&#xA;      &lt;line x1=&#34;531&#34; y1=&#34;85&#34; x2=&#34;579&#34; y2=&#34;85&#34; class=&#34;dns-arrow&#34; /&gt;&#xA;    &lt;/g&gt;&#xA;    &lt;!-- Box 4: IP result --&gt;&#xA;    &lt;g class=&#34;dns-step4&#34;&gt;&#xA;      &lt;rect x=&#34;580&#34; y=&#34;50&#34; width=&#34;120&#34; height=&#34;70&#34; rx=&#34;10&#34; class=&#34;dns-box&#34; /&gt;&#xA;      &lt;text x=&#34;640&#34; y=&#34;82&#34; class=&#34;dns-label&#34; font-weight=&#34;600&#34;&gt;IP Address&lt;/text&gt;&#xA;      &lt;text x=&#34;640&#34; y=&#34;99&#34; class=&#34;dns-sublabel&#34;&gt;returned to Mac&lt;/text&gt;&#xA;    &lt;/g&gt;&#xA;    &lt;!-- Return path (dashed green) --&gt;&#xA;    &lt;g class=&#34;dns-return-line&#34;&gt;&#xA;      &lt;path d=&#34;M 640 120 Q 640 155 360 155 Q 80 155 80 121&#34; class=&#34;dns-return&#34; /&gt;&#xA;      &lt;text x=&#34;360&#34; y=&#34;170&#34; class=&#34;dns-sublabel&#34; fill=&#34;#34C759&#34;&gt;cached for future lookups&lt;/text&gt;&#xA;    &lt;/g&gt;&#xA;  &lt;/svg&gt;&#xA;  &lt;figcaption&gt;macOS在本地缓存DNS答案，以便在重复访问时跳过整个查询链。当记录更改时，缓存可能会提供过时的数据。&lt;/figcaption&gt;&#xA;&lt;/figure&gt;&#xA;&lt;p&gt;缓存通常是好事。它能加快浏览速度，因为您的Mac可以跳过最近访问过的网站的整个查询链。问题出现在DNS记录更改时，Mac缓存的答案仍然指向旧目的地。DNS记录上的TTL（存活时间）告诉解析器缓存多长时间，但macOS并不总是精确遵守它。&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
