Modify dnsmasq Settings
ServBay comes with the dnsmasq service and offers flexible configuration options. This article will detail how to modify the dnsmasq settings in ServBay, including the location of the dnsmasq.conf
file and common configuration items.
Important Note
Please do not manually modify the configuration files. All configuration files are automatically generated by ServBay, and manual modifications are at risk of being overwritten. Please make changes through the UI.
Overview
In ServBay, the dnsmasq configuration files are located in the /Applications/ServBay/etc/dnsmasq
directory. The detailed locations of these files are as follows:
dnsmasq.conf
:/Applications/ServBay/etc/dnsmasq/dnsmasq.conf
domains.conf
:/Applications/ServBay/etc/dnsmasq/domains.conf
Set Upstream Servers
Users can set upstream servers for dnsmasq in Settings
- DNS Forwarding
. After setting, all DNS requests except for locally added domain names will be forwarded to the upstream DNS servers.
The default upstream DNS server is obtained automatically from the user's current network gateway, typically issued by DHCP, such as 192.168.0.1
, 10.0.0.1
.
dnsmasq.conf Configuration
The dnsmasq.conf
file is the main configuration file for dnsmasq, used to set various DNS and DHCP options.
Common Configuration Items
Below are some common dnsmasq.conf
configuration items and how to modify them:
Set DNS Servers:
server=8.8.8.8 server=8.8.4.4
1
2Set Cache Size:
cache-size=1000
1Set Domain Name:
domain=local
1Enable DNS Query Logging:
log-queries
1Set DHCP Range:
dhcp-range=192.168.0.50,192.168.0.150,12h
1
Custom DNS Records
dnsmasq allows you to customize DNS records, which is useful for small networks or development environments. The configuration file is located in domains.conf
.
STOP
domains.conf
will be automatically overwritten by ServBay. Please use ServBay's Manage Local DNS Service to make changes.
Sample Configuration
Below are some examples of custom DNS records:
- Set Local Domain Resolution:
address=/servbay.host/127.0.0.1
1
Restart dnsmasq
After modifying the dnsmasq configuration files, you need to restart the service for the changes to take effect. You can restart through the ServBay management interface or use the servbayctl
command-line tool.
Restart Through ServBay Management Interface
- Open the ServBay management interface.
- Navigate to
Services
. - Locate the dnsmasq service and click the
Restart
button.
Restart via servbayctl
You can conveniently restart the dnsmasq service using the servbayctl
command-line tool:
servbayctl restart dnsmasq -all
Summary
In ServBay, the dnsmasq configuration files are located in the /Applications/ServBay/etc/dnsmasq
directory. By modifying this file, you can set DNS servers, cache size, domain names, enable logs, and configure DHCP ranges. Custom DNS records can also be configured through this file. After modifying these configuration files, you can restart the dnsmasq service through the ServBay management interface or using the servbayctl
command-line tool to apply the changes.