97人妻精品一区二区三区软件,人妻偷拍在线,插丝袜美女小穴视频,美女午夜福利在线

      • <i id="89dc3"></i>
        當(dāng)前位置: 首頁 >應(yīng)用方案 >技術(shù)應(yīng)用 >

        DNS解析服務(wù)systemd-resolved的常用命令

        1.關(guān)于DNS解析服務(wù)

        DNS(Domain Name System),即域名系統(tǒng)。一句話總結(jié)DNS解析服務(wù)功能就是,將域名轉(zhuǎn)換為IP地址。

        DNS解析服務(wù)過程中有如下幾個(gè)角色參與:

        DNS解析大致過程:

        1. 用戶在應(yīng)用程序中使用域名

        2. 應(yīng)用程序調(diào)用DNS客戶端申請(qǐng)域名解析

        3. DNS客戶端向DNS服務(wù)器發(fā)送待解析的域名(本地有解析緩存則不用再請(qǐng)求)

        4. DNS服務(wù)器將解析出的IP地址返回給客戶端 (服務(wù)端可能會(huì)緩存DNS解析結(jié)果,避免重復(fù)查詢)

        5. 應(yīng)用程序使用域名對(duì)應(yīng)的IP地址 (客戶端可能會(huì)緩存DNS解析結(jié)果,加快響應(yīng)速度)

        Windows和Linux系統(tǒng)中都有常用的DNS解析服務(wù),例如Windows中的DNS Client,Linux中的systemd-resolvedBIND等。

        而其中systemd-resolved是現(xiàn)代Linux發(fā)行版(基于systemd)中最常用的默認(rèn)DNS解析服務(wù),今天本文將分享systemd-resolved這款DNS解析服務(wù)。


        2.systemd-resolved 的常用命令

        2.1 查看當(dāng)前systemd-resolved的運(yùn)行狀態(tài)

        systemctl status systemd-resolved

        該服務(wù)在基于systemd的系統(tǒng)中是默認(rèn)開啟的,也可以將status字段更換為start或stop來控制該服務(wù)的開啟和關(guān)閉,因?yàn)楸疚闹饕獓@systemd-resolved展開,所以systemdctl的操作命令不再詳細(xì)展開。

        2.2 查看systemd-resolved的統(tǒng)計(jì)信息,在輸出中可以查看緩存命中率、緩存大小、DNSSEC 驗(yàn)證情況。

        systemd-resolve --statistics

        2.3 檢查當(dāng)前DNS配置

        resolvectl status  或  systemd-resolve --status(舊版本兼容)

        2.4 清理DNS緩存,systemd-resolved會(huì)緩存在內(nèi)存上,并不進(jìn)行持久化保存,若緩存過大可以使用該命令清理本地緩存

        systemd-resolve --flush-caches

        2.5 手動(dòng)進(jìn)行域名解析測試,輸出中可以查看解析出來的IP、解析耗時(shí)等

        systemd-resolve www.xxx.com

        2.6 臨時(shí)給端口配置DNS服務(wù)器,該配置重啟會(huì)失效,若想永久固定需修改/etc/systemd/resolved.conf等相關(guān)配置文件

        resolvectl dns eth0 8.8.8.8


        3. systemd-resolved相關(guān)配置文件

        3.1、 /etc/resolv.conf配置文件

        /etc/resolv.conf是最表面的DNS配置文件,systemd-resolved執(zhí)行DNS解析時(shí),會(huì)讀取該文件來獲取DNS服務(wù)器IP,從而進(jìn)行DNS解析。

        所以不難看出,/etc/resolv.confsystemd-resolved服務(wù)中最重要的文件,因此/etc/resolv.conf會(huì)被多方控制,從而達(dá)到配置DNS解析服務(wù)的目的。

        若用戶想要臨時(shí)配置系統(tǒng)的DNS解析服務(wù)器,可以直接修改該文件,寫入對(duì)應(yīng)的服務(wù)器IP:

        nameserver 114.114.114.114
        nameserver 8.8.8.8

        不過以上修改操作只能是臨時(shí)的,因?yàn)?/span>/etc/resolv.conf正常情況下是動(dòng)態(tài)生成的,當(dāng)查看它的詳細(xì)信息時(shí)會(huì)發(fā)現(xiàn)是一個(gè)軟連接,它的狀態(tài)會(huì)隨著配置和用戶的動(dòng)作而變化。

        lrwxrwxrwx 1 root root 37 Dec  5 14:24 /etc/resolv.conf -> /run/systemd/resolve/stub-resolv.conf

        這里所指向的stub-resolv.conf文件后面再詳細(xì)解釋。

        3.2、/etc/systemd/resolved.conf配置文件

        該文件是systemd-resolved的主要配置文件,通常用于設(shè)置DNS 服務(wù)器、DNS 解析策略等。修改這個(gè)文件后,需要重新啟動(dòng)systemd-resolved服務(wù)才能生效。

        [Resolve]
        DNS=8.8.8.8 8.8.4.4          # DNS服務(wù)器列表
        FallbackDNS=114.114.114.114   # 當(dāng)主要DNS不可用時(shí),使用備用DNS
        Domains=example.com           # 域名搜索拓展列表
        LLMNR=no                      # LLMNR(本地鏈路多播名稱解析)啟用設(shè)置
        DNSSEC=no                     # 是否啟用DNSSEC(域名系統(tǒng)安全擴(kuò)展)
        Cache=yes                     # 啟用DNS緩存

        3.3、/run/systemd/resolve/stub-resolv.conf/run/systemd/resolve/resolv.conf配置文件

        3.1中可以發(fā)現(xiàn),/etc/resolv.conf就是指向了/run/systemd/resolve/stub-resolv.conf,所以/etc/resolv.conf同樣也能指向/run/systemd/resolve/resolv.conf,也證明這兩個(gè)文件才是真正的DNS服務(wù)器指定文件。

        這兩個(gè)文件實(shí)際由systemd-resolved服務(wù)直接管理和生成,其中:

        /run/systemd/resolve/resolv.conf文件:由systemd-resolved服務(wù)生成,其內(nèi)容由3.2提到的/etc/systemd/resolved.conf配置文件進(jìn)行指定,如下:

        # This file is managed by man:systemd-resolved(8). Do not edit.
        #
        # This is a dynamic resolv.conf file for connecting local clients directly to
        # all known uplink DNS servers. This file lists all configured search domains.
        #
        # Third party programs must not access this file directly, but only through the
        # symlink at /etc/resolv.conf. To manage man:resolv.conf(5) in a different way,
        # replace this symlink by a static file or a different symlink.
        #
        # See man:systemd-resolved.service(8) for details about the supported modes of
        # operation for /etc/resolv.conf.
        nameserver 8.8.8.8
        nameserver 8.8.4.4
        search example.com

        /run/systemd/resolve/stub-resolv.conf文件:由systemd-resolved服務(wù)生成,配置使用DNS stub解析器,這種情況下應(yīng)用程序不會(huì)與systemd-resolved直接通信,而是由stub解析器轉(zhuǎn)發(fā),一般情況下應(yīng)用程序只需要向127.0.0.53查詢即可,由stub解析器轉(zhuǎn)發(fā)給systemd-resolved,避免了緊耦合:

        # This file is managed by man:systemd-resolved(8). Do not edit.
        #
        # This is a dynamic resolv.conf file for connecting local clients to the
        # internal DNS stub resolver of systemd-resolved. This file lists all
        # configured search domains.
        #
        # Run "resolvectl status" to see details about the uplink DNS servers
        # currently in use.
        #
        # Third party programs must not access this file directly, but only through the
        # symlink at /etc/resolv.conf. To manage man:resolv.conf(5) in a different way,
        # replace this symlink by a static file or a different symlink.
        #
        # See man:systemd-resolved.service(8) for details about the supported modes of
        # operation for /etc/resolv.conf.
        nameserver 127.0.0.53
        options edns0 trust-ad
        search example.com

        在實(shí)際使用過程中,可以只關(guān)注/etc/resolv.conf文件即可:

        在操作上,了解systemd-resolved是如何管理DNS請(qǐng)求,了解配置文件如何影響DNS解析行為,已經(jīng)足以完成日常的配置和故障排查。

        在理論上,若想要使用DNS解析服務(wù)更高級(jí)的功能可以深入了解DNS工作原理以及DNS協(xié)議的高級(jí)特性,并深入學(xué)習(xí)systemd-resolved服務(wù)相關(guān)的高級(jí)命令和安全防護(hù)等。



        今天的分享就到這里啦,EBYTE每一天都致力于更好的助力物聯(lián)化、智能化、自動(dòng)化的發(fā)展,提升資源利用率,更多通信技術(shù)資料,感興趣的小伙伴可以登錄我們的億佰特官網(wǎng)進(jìn)行了解,也可以直接撥打400電話咨詢技術(shù)專員!


        相關(guān)閱讀:

        1、【服務(wù)器】Nginx Proxy Manager申請(qǐng)cloudflare泛域名教程

        2、Dell服務(wù)器PowerEdge R730xd部署ESXI服務(wù)器部署教程

        3、如何在本地搭建代碼托管平臺(tái)Gitea案例教程

        4、Chirpstack服務(wù)器簡介和搭建教程


        點(diǎn)擊撥打: 億佰特官網(wǎng) 4000-330-990