centos7安装dnsmasq 配置内网域名解析
时间: 2023-08-13 10:04:10 浏览: 179
CentOS7-hadoop安装配置.pdf
要在CentOS 7上安装和配置dnsmasq来进行内网域名解析,可以按照以下步骤进行操作:
1. 使用yum命令安装dnsmasq:`yum install dnsmasq -y` \[1\]
2. 修改dnsmasq配置文件:`vim /etc/dnsmasq.conf`,确保以下配置项正确设置:
- 指定上游DNS服务器:`resolv-file=/etc/resolv.dnsmasq.conf`
- 严格按照resolv-file文件中的顺序进行DNS解析:`strict-order`
- 开启本地hosts文件和缓存的域名解析:`no-resolv`
- 设置当前服务器的IP地址:`listen-address=192.168.119.12`
- 指定解析记录文件的目录:`conf-dir=/etc/dnsmasq.d`
- 添加自定义的DNS记录文件:`addn-hosts=/etc/dnsmasq.hosts` \[1\] \[2\] \[3\]
3. 创建并编辑上游DNS服务器配置文件:`vim /etc/resolv.dnsmasq.conf`,写入上游DNS服务器的IP地址,每行一个:
```
nameserver 119.29.29.29
nameserver 114.114.114.114
nameserver 8.8.8.8
nameserver 1.1.1.1
```
4. 创建并编辑自定义的DNS解析记录文件:`vim /etc/dnsmasq.hosts`,写入需要解析的域名和对应的IP地址,每行一个:
```
123.206.16.61 pyyugo.cn
123.206.16.61 goyugo.cn
```
5. 修改当前服务器的DNS域名服务器配置文件:`vim /etc/resolv.conf`,将nameserver指定为自建的dnsmasq服务器的IP地址:`nameserver 192.168.119.12`
6. 重启dnsmasq服务:`systemctl restart dnsmasq`
7. 确认域名解析是否生效:可以使用`nslookup`或`dig`命令来查询指定域名的解析结果,例如:`nslookup pyyugo.cn` \[1\]
通过以上步骤,你应该能够在CentOS 7上成功安装和配置dnsmasq来进行内网域名解析。
#### 引用[.reference_title]
- *1* [centos7安装dnsmasq局域网dns](https://blog.csdn.net/weixin_30642267/article/details/99929828)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item]
- *2* [centos7配置dnsmasq](https://blog.csdn.net/qq_39689711/article/details/129271125)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item]
- *3* [CentOS安装配置DNSMasq](https://blog.csdn.net/tiger57/article/details/129594344)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]
阅读全文