温馨提示×

centos dnsmasq如何添加本地解析

小樊
90
2024-12-31 21:48:31
栏目: 智能运维
Centos服务器限时活动,0元免费领,库存有限,领完即止! 点击查看>>

在CentOS上配置dnsmasq以添加本地解析非常简单。请按照以下步骤操作:

  1. 首先,确保您已经安装了dnsmasq。如果没有,请使用以下命令安装:
sudo yum install dnsmasq
  1. 打开dnsmasq的配置文件。通常,它位于/etc/dnsmasq.conf/etc/dnsmasq/dnsmasq.conf。如果您的配置文件位于其他位置,请相应地修改。
sudo vi /etc/dnsmasq.conf
  1. 在配置文件中,添加一个新的域名解析条目。例如,如果您想要将example.local解析为本地IP地址192.168.1.100,则添加以下行:
address=/example.local/192.168.1.100

如果您想要为多个域名指定相同的IP地址,可以用逗号分隔它们,如下所示:

address=/example.local,example2.local,example3.local/192.168.1.100
  1. 保存并关闭配置文件。

  2. 重启dnsmasq服务以使更改生效:

sudo systemctl restart dnsmasq

现在,dnsmasq应该已经根据您指定的配置解析相应的域名。您可以使用nslookupdig命令来测试域名解析是否正常工作:

nslookup example.local

dig example.local

亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>

推荐阅读:如何用centos dnsmasq进行域名解析

0