Skip to content

Commit

Permalink
Add dnsmasq
Browse files Browse the repository at this point in the history
  • Loading branch information
taoky committed Jan 9, 2025
1 parent d7a5dd6 commit a2605ac
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
32 changes: 32 additions & 0 deletions docs/infrastructure/dnscache.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# DNS 缓存

本部分介绍使用 dnsmasq 配置本地 DNS 缓存的方式,适用于不便于使用 nscd 的场景,例如:

- 容器
- Nginx `proxy_pass`

安装后创建配置文件 `/etc/dnsmasq.d/ustclug`,内容如下:

``` title="/etc/dnsmasq.d/ustclug"
no-resolv
expand-hosts
listen-address=127.0.0.1
bind-interfaces
domain=s.ustclug.org
server=原来的 DNS 第一个服务器
server=原来的 DNS 第二个服务器
```

建议进行以下操作之前,启动一个 root shell。

**重启** `dnsmasq` 服务(`reload` 无效),之后确认解析工作,特别是自己的名字的解析:

```shell
dig @127.0.0.1 +short ustc.edu.cn
dig @127.0.0.1 +short 你的主机名
```

确认后修改 `/etc/resolv.conf``nameserver` 处仅包含 `127.0.0.1`。诸如 nginx 等程序可能需要单独设置。

如果更改了 `/etc/hosts` 设置,需要手动 `systemctl reload dnsmasq`
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ nav:
- Docker Hub: infrastructure/dockerhub.md
- Mail Agent: infrastructure/mail.md
- RAID: infrastructure/raid.md
- DNS Caching: infrastructure/dnscache.md
- Discontinued Infrastructure:
- infrastructure/discontinued/index.md
- G Suite: infrastructure/google.md
Expand Down

0 comments on commit a2605ac

Please sign in to comment.