笔记笔记
  • Home
  • AI&ML
  • Example
  • Zoo
  • 关于
⌘ K
macOS - 返回
常用命令
Shell 软件
iTerm
Homebrew
macOS 制作 U 盘 启动
DNS
系统工具
Python 环境
桌面软件
VMware Fusion
最后更新时间:
Copyright © 2023-2024 | Powered by dumi | GuoDapeng | 冀ICP备20004032号-1 | 冀公网安备 冀公网安备 13024002000293号

TABLE OF CONTENTS

‌
‌
‌
‌

Mac 上安装 DNS 服务

安装 Dnsmasq

➜ ~ brew install dnsmasq
== >Downloading https://homebrew.bintray.com/bottles/dnsmasq-2.80.mojave.bottle.
== >Downloading from https://akamai.bintray.com/4d/4d150c19c5c856435f9d38307c4b9
######################################################################## 100.0%
== >Pouring dnsmasq-2.80.mojave.bottle.1.tar.gz
== >Caveats
To have launchd start dnsmasq now and restart at startup:
sudo brew services start dnsmasq
== >Summary
🍺 /usr/local/Cellar/dnsmasq/2.80: 8 files, 531.3KB

产生了一些文件

/usr/local/sbin/dnsmasq
/usr/local/etc/dnsmasq.conf
/usr/local/etc/dnsmasq.d

配置 Dnsmasq

创建一个目录,放乱七八糟的。

➜ etc pwd
/usr/local/etc
➜ etc mkdir dnsmasq

编辑 /usr/local/etc/dnsmasq.conf 文件。

添加下面的配置:

# 上游DNS服务配置
resolv-file=/usr/local/etc/dnsmasq/resolv.dnsmasq.conf
# 严格按照上述文件中的配置顺序执行
strict-order
# 监听请求的地址(127.0.0.1:仅本机,0.0.0.0:任何人)
listen-address=127.0.0.1
# 一些你需要的解析结果
addn-hosts=/usr/local/etc/dnsmasq/dnsmasq.hosts
# 其他配置路径
conf-dir=/usr/local/etc/dnsmasq.d
# 缓存大小
cache-size=10000

编辑 /usr/local/etc/dnsmasq/resolv.dnsmasq.conf 文件。

nameserver 8.8.8.8
nameserver 8.8.4.4
nameserver 114.114.114.114
nameserver 1.1.1.1
nameserver 1.0.0.1

插入解析

编辑 /usr/local/etc/dnsmasq/dnsmasq.hosts 文件。

192.168.6.201 wp.l

启动服务

➜ ~ sudo brew services start dnsmasq
Password:
==> Successfully started `dnsmasq` (label: homebrew.mxcl.dnsmasq)
## 停止服务
sudo brew services stop dnsmasq
## 重新启动服务
sudo brew services restart dnsmasq

配置本机的 DNS 为 127.0.0.1

sudo killall -HUP mDNSResponder

检查 DNS 的

http://tool.chinaz.com/dns