Configuring ServBay's DNS Service (dnsmasq)
ServBay leverages a built-in dnsmasq service to provide developers with robust and flexible local DNS resolution capabilities. This is crucial for managing local development domains (such as domains with the .servbay.demo
suffix) and controlling the forwarding of other DNS requests.
This article provides a detailed guide on how to configure dnsmasq within ServBay, with a focus on making changes via the recommended user interface and an explanation of the related configuration file locations.
Important Notice
ServBay automatically manages the dnsmasq configuration files (such as dnsmasq.conf
and domains.conf
). You should not modify these files manually. ServBay will periodically update and overwrite these files based on your user interface settings or internal logic, and any manual changes may be lost or cause unexpected behavior.
All recommended dnsmasq configurations should be made through the ServBay user interface.
dnsmasq Configuration File Locations (Managed by ServBay)
The dnsmasq configuration files generated by ServBay are located in the /Applications/ServBay/etc/dnsmasq
directory. Understanding where these files reside can help you see how ServBay manages DNS, but remember not to edit them manually:
dnsmasq.conf
: The primary configuration file auto-generated by ServBay based on your overall settings.domains.conf
: This file is managed by ServBay and is specifically used to store local domain resolution records that you add via the user interface.
Configuring dnsmasq via the ServBay User Interface
ServBay provides an intuitive user interface that allows you to manage critical dnsmasq settings with ease.
Setting Upstream DNS Servers
By configuring upstream DNS servers, you can control how dnsmasq handles domain requests that cannot be resolved locally by ServBay (i.e., domains other than your configured local development domains). Such requests will be forwarded to the specified upstream DNS servers for resolution.
- Open the ServBay management interface.
- Click on
Settings
in the top menu bar. - Select the
DNS Forwarding
tab. - Here, you can add, edit, or remove upstream DNS server addresses.
By default, ServBay automatically acquires the upstream DNS servers from your current network environment (usually assigned via DHCP), such as 192.168.0.1
or 10.0.0.1
. You can change this to public DNS services (like Google DNS 8.8.8.8
/8.8.4.4
or Cloudflare DNS 1.1.1.1
/1.0.0.1
), or use other internal DNS servers as needed.
Managing Local Domain Resolution
ServBay makes it easy to configure custom domains for your local development projects and map them to local IP addresses (typically 127.0.0.1
). ServBay automatically writes these configurations to the domains.conf
file.
For instance, you can resolve myproject.servbay.demo
to 127.0.0.1
, allowing you to access your local project in the browser using this domain.
For detailed steps on managing local domain resolution, please refer to the following documentation:
Please note: The method illustrated in the Manage Local DNS Service documentation is the correct and recommended way to configure local domain resolution. Please avoid editing the domains.conf
file directly.
Restarting the dnsmasq Service
Whenever you make any dnsmasq-related changes through the ServBay user interface—such as modifying upstream DNS servers or adding local domains—you'll need to restart the dnsmasq service for your new settings to take effect.
You can restart dnsmasq via the ServBay management interface or by using the servbayctl
command-line tool.
Restarting via the ServBay Management Interface
- Open the ServBay management interface.
- In the left navigation bar, locate and click on
Packages
. - In the package list, find
dnsmasq
and click theRestart
button next to it.
Restarting with the servbayctl Command-line Tool
Open your Terminal application and use the servbayctl
command to conveniently restart the dnsmasq service:
servbayctl restart dnsmasq -all
The -all
parameter ensures any dependent services (if applicable) are also considered, but for a standalone dnsmasq service restart, it mainly just restarts the dnsmasq process itself.
Summary
ServBay provides core local DNS resolution functionality through its integrated dnsmasq service, playing a vital role in efficient local web development workflows. It's highly recommended to always configure essential dnsmasq settings—such as specifying upstream DNS servers and managing local development domain resolution—via the ServBay user interface. Avoid manually editing dnsmasq configuration files, as they are managed automatically by ServBay. After making any configuration changes, be sure to restart the dnsmasq service via the ServBay user interface or the servbayctl
command-line tool to ensure your changes take effect.