安装dnsmasq
$ sudo apt install dnsmasq
创建配置文件:dnsmasq.conf
port=0
dhcp-range=192.168.0.10,192.168.0.254,255.255.255.0
dhcp-leasefile=/run/dnsmasq/dnsmasq.leases
port是设置dns的监听端口,0表示完全禁止dns功能。
启动:
sudo dnsmasq -C dnsmasq.conf
注意,还需要将接口的ip地址修改为192.168.0.x,否则dnsmasq无法使用ip地址恢复DHCP包。
openwrt的配置:
==============================
# ps ww
/usr/sbin/dnsmasq --user=root -C /var/etc/dnsmasq.conf.cfg01411c -k -x /var/run/dnsmasq/dnsmasq.cfg01411c.pid
# cat /var/etc/dnsmasq.conf.cfg01411c
# auto-generated config file from /etc/config/dhcp
conf-file=/etc/dnsmasq.conf
address=/workforme.stat.localdomain/127.0.0.1
dhcp-authoritative
domain-needed
localise-queries
read-ethers
enable-ubus
expand-hosts
bind-dynamic
local-service
all-servers
server=/lan/
dhcp-leasefile=/tmp/dhcp.leases
resolv-file=/tmp/resolv.conf.auto
intercept-ip-address=192.168.10.1
intercept-white-list=/etc/intercept_wlist
addn-hosts=/tmp/hosts
conf-dir=/tmp/dnsmasq.d
dhcp-range=set:lan,192.168.10.5,192.168.10.254,255.255.255.0,12h
dhcp-option-force=12,MiWiFi-WR30M-srv
dhcp-option-force=43,miwifi-WR30M-6.0.49-101
no-dhcp-interface=eth1
dhcp-range=set:miot,192.168.32.10,192.168.32.209,255.255.255.0,1h
dhcp-option-force=12,MiWiFi-WR30M-srv
dhcp-option-force=43,miwifi-WR30M-6.0.49-101
address=/XiaoQiang/192.168.10.1
ptr-record=1.10.168.192.in-addr.arpa,XiaoQiang