自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

如何在 Ubuntu 22.04 上安裝 Unbound DNS 解析器

系統(tǒng) Linux
我想向您展示如何在 Ubuntu 22.04 上安裝 Unbound。這可以安裝在 Ubuntu 服務器或桌面上,您將獲得比默認設(shè)置顯著的 DNS 解析速度。

Unbound 是一個免費的開源遞歸和驗證 DNS 緩存服務器,它使用 DNS-over-TLS 和 DNS-over-HTTPS 來加密連接。Unbound 比 Bind9 快得多,可以幫助減少網(wǎng)頁和其他需要 DNS 解析的調(diào)用的加載時間。Unbound 還支持 DNSSEC 驗證,因此它可以作為您網(wǎng)絡上的信任錨。

我想向您展示如何在 Ubuntu 22.04 上安裝 Unbound。這可以安裝在 Ubuntu 服務器或桌面上,您將獲得比默認設(shè)置顯著的 DNS 解析速度。

你需要什么

為此,您唯一需要的是一個正在運行的 Ubuntu 實例——盡管它也可以安裝在基于 RHEL 的發(fā)行版上——以及一個具有 sudo 權(quán)限的用戶。就是這樣:讓我們加快 DNS 解析速度。

如何安裝 Unbound

幸運的是,在默認存儲庫中找到了 Unbound,因此要安裝它,請登錄到您的 Ubuntu 機器并發(fā)出命令:

linuxmi@linuxmi:~/www.linuxmi.com$ sudo apt-get install unbound -y

如果您正在使用基于 RHEL 的發(fā)行版,則該安裝將是:

linuxmi@linuxmi:~/www.linuxmi.com$ sudo dnf install unbound -y

如何配置 Unbound

安裝 Unbound 后,我們需要創(chuàng)建一個新的配置文件。使用以下命令創(chuàng)建該文件:

linuxmi@linuxmi:~/www.linuxmi.com$ sudo nano /etc/unbound/unbound.conf.d/myunbound.conf

在該文件中,粘貼以下內(nèi)容: 您可以編輯上述配置,但要知道它應該按原樣工作。保存并關(guān)閉文件。

server:
port: 53
verbosity: 0
num-threads: 2
outgoing-range: 512
num-queries-per-thread: 1024
msg-cache-size: 32m
interface: 0.0.0.0
rrset-cache-size: 64m
cache-max-ttl: 86400
infra-host-ttl: 60
infra-lame-ttl: 120
access-control: 127.0.0.0/8 allow
access-control: 0.0.0.0/0 allow
username: unbound
directory: "/etc/unbound"
logfile: "/var/log/unbound.log"
use-syslog: no
hide-version: yes
so-rcvbuf: 4m
so-sndbuf: 4m
do-ip4: yes
do-ip6: no
do-udp: yes
do-tcp: yes
remote-control:
control-enable: yes
control-port: 953
control-interface: 0.0.0.0

接下來,我們需要使用以下命令為 Unbound 創(chuàng)建一個日志文件:

linuxmi@linuxmi:~/www.linuxmi.com$ sudo touch /var/log/unbound.log

通過以下方式為日志文件提供適當?shù)臋?quán)限:

linuxmi@linuxmi:~/www.linuxmi.com$ sudo chown unbound:unbound /var/log/unbound.log

最后,使用以下命令啟動 Unbound 服務:

linuxmi@linuxmi:~/www.linuxmi.com$ sudo systemctl enable --now unbound

輸出如下:

Synchronizing state of unbound.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable unbound

如何測試 Unbound

啟動服務后,立即發(fā)出命令:

linuxmi@linuxmi:~/www.linuxmi.com$ dig baidu.com @localhost

您應該會看到與此類似的輸出:

; <<>> DiG 9.18.1-1ubuntu1.1-Ubuntu <<>> baidu.com @localhost
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 12084
;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1232
;; QUESTION SECTION:
;baidu.com. IN A
;; ANSWER SECTION:
baidu.com. 600 IN A 220.181.38.148
baidu.com. 600 IN A 220.181.38.251
;; Query time: 630 msec
;; SERVER: 127.0.0.1#53(localhost) (UDP)
;; WHEN: Sun Jun 19 08:57:13 EDT 2022
;; MSG SIZE rcvd: 70

注意查詢時間為 603 毫秒。然后,讓我們再次運行該命令:

注意 108 毫秒的查詢時間。這相當快。但是,讓我們再次運行命令:

linuxmi@linuxmi:~/www.linuxmi.com$ dig baidu.com @localhost

您的查詢時間應該要少得多。我在第二次嘗試時收到了 0 毫秒的查詢時間,在第三次嘗試時還是收到了 0。

恭喜,由于開源的 Unbound DNS 解析器,您的 DNS 查詢現(xiàn)在更快了。如果您選擇,您甚至可以將該服務器用作基于 LAN 的 DNS 服務器。

責任編輯:龐桂玉 來源: Linux公社
相關(guān)推薦

2023-09-12 10:23:28

2014-05-06 09:27:54

2022-10-27 10:02:58

UbuntuLinux

2023-07-05 16:45:30

WiresharkLinux

2023-04-03 13:01:14

UbuntuCRI-O

2015-11-30 14:33:36

Intel GraphLinuxUbuntu

2019-08-02 15:30:42

UbuntuMongoDB命令

2023-05-27 16:27:25

2019-08-30 11:20:28

UbuntuVirtualBoxLinux

2018-10-15 15:23:50

UbuntupipPython

2023-08-08 12:38:52

2024-01-04 11:50:00

UbuntuDocker

2022-06-14 09:33:15

LinuxGNU Emacs命令

2022-07-28 15:10:34

UbuntuDocker

2015-10-16 10:07:22

Justniffer安裝Ubuntu

2013-07-29 13:49:23

UbuntuLAMP服務器

2021-09-11 15:41:55

UbuntuDropbox云服務

2017-03-29 16:18:11

LinuxUbuntuRedmine

2013-07-25 10:00:30

UbuntuVirtualBox

2021-07-12 14:47:16

UbuntuZlib代碼
點贊
收藏

51CTO技術(shù)棧公眾號