dnsmasq
dnsmasq 部署与使用
编译安装
从 http://www.thekelleys.org.uk/dnsmasq/ 下载源码包, 安装编译环境, 然后直接使用root
身份运行make install
命令即可, 默认安装的二进制文件位置为/usr/local/sbin/dnsmasq
.
install dnsmasq on ubuntu
Step 1: Installing Dnsmasq on Ubuntu 18.04
Ubuntu 18.04 comes with systemd-resolve which you need to disable since it binds to port 53 which will conflict with Dnsmasq port.
Run the following commands to disable the resolved service:
Also, remove the symlinked resolv.conf
file
Then create new resolv.conf file.
Dnsmasq is available on the apt repository, easy installation can be done by running:
The main configuration file for Dnsmasq is /etc/dnsmasq.conf
. Configure Dnsmasq by modifying this file.
Here is minimal configuration
If you want to enable DNSSEC validation and caching, uncomment
Make any other changes you see relevant and restart dnsmasq when done:
Step 2: Adding DNS records to Dnsmasq
Add DNS records in the file./etc/hosts
. Dnsmasq will reply to queries from clients using these records.
You need to restart dnsmasq service after adding the records.
Step 3: Testing Dnsmasq DNS functionality
To verify that Dnsmasq responds to the records we added, point DNS server of your servers to Dnsmasq server. Edit /etc/network/interfaces
for persistent configuration, or the file /etc/netplan/
on Ubuntu 18.04 servers.
Since this is a test, I’ll modify runtime file /etc/resolv.conf
Test using dig:
Here is another example:
You can confirm that we’re getting responses as configured.
Configure Dnsmasq as DHCP Server (Optional)
You can use Dnsmasq to assign IP addresses to clients, either static or dynamic.
Edit the file a/etc/dnsmasq.conf
and provide DHCP options. You need to provide:
- Default gateway IP address
- DNS server IP address (Probably Dnsmasq or different DNS server)
- Network Subnet mask
- DHCP Addresses range
- NTP server
See below example
Restart dnsmasq and configure clients to obtain an IP address from this server.
Conclusion
Dnsmasq is an easy to configure DNS cache which can speed up internet browsing and the resolving of domain records on your systems. You can also enjoy its DHCP subsystem which is easy to configure and use for a small network.
来源: https://computingforgeeks.com/install-and-configure-dnsmasq-on-ubuntu-18-04-lts/
install dnsmasq on CentOS
参考: https://www.tecmint.com/setup-a-dns-dhcp-server-using-dnsmasq-on-centos-rhel/
参考链接
- dnsmasq docs: http://www.thekelleys.org.uk/dnsmasq/doc.html