5分钟入门dnsmasq

Dnsmasq 提供 DNS 缓存和 DHCP 服务功能

dnsmasq install

yum install -y dnsmasq
systemctl enable dnsmasq

dnsmasq config

# vi /etc/dnsmasq.conf

listen-address=192.168.1.132,127.0.0.1

## 转发域名解析
server=/cn/114.114.114.114
server=/taobao.com/114.114.114.114

## 指定域名解析
address=/ad.iqiyi.com/127.0.0.1
address=/ad.iqiyi.com/127.0.0.1

## DHCP设定
dhcp-range=192.168.1.50,192.168.1.150,48h

dhcp-host=00:0C:29:5E:F2:6F,192.168.1.201,os02
dhcp-host=00:0C:29:15:63:CF,192.168.1.202,os03

local=/ic.lo/
domain=ic.lo

dhcp-option=3,192.168.0.1

# restart service
systemctl restart dnsmasq

dnsmasq check

dig www.baidu.com