Skip to content

DnsMasq

Yurii Torbyk edited this page Jan 7, 2019 · 4 revisions

DnsMasq is used in order to proxy all requests on the *.test domain to point to sites installed on your local machine. While the .test domain can be changed on any other in config or added new one along with it, but it's it recommended to use .test since only for such domains Chrome & Firefox allow to use self-generated certificates for https.

DnsMasq installation and its leveraging use next configuration section:

    'dns' => [
        'formula' => 'dnsmasq',
        'domains' => [
            'test'
        ],
        'config_path' => '/Users/username/.sage/dnsmasq.conf',
        'brew_config_path' => '/usr/local/etc/dnsmasq.conf',
        'brew_config_dir_path' => '/usr/local/etc/dnsmasq.d',
        'resolver_path' => '/etc/resolver'
    ]

Installation

Installation can be triggered by sage dns:install command or as a step in sage env:install command.

DnsMasq installation actions:

  • install Brew formula dnsmasq (see ['dns']['formula'] config settings)
  • include /Users/username/.sage/dnsmasq.conf config (see ['dns']['config_path'] config settings) into /usr/local/etc/dnsmasq.conf Dnsmasq config.
  • adds domain .test (see ['dns']['domains'], could be more than one) into included config
  • creates resolver config in /etc/resolver directory (see ['dns']['resolver_path']) for .test domain

Uninstallation

In order to uninstall Dnsmasq run sage dns:uninstall command or sage env: uninstall command then DnsMasq will be deleted with all other sage's environment.

DnsMasq uninstallation actions:

  • uninstall Brew formula dnsmasq (see config settings ['dns']['formula'])
  • delete /etc/resolver directory (see ['dns']['resolver_path'])
  • delete /usr/local/etc/dnsmasq.conf config (see ['dns']['brew_config_path'])
  • delete /Users/username/.sage/dnsmasq.conf config (see ['dns']['config_path'])

Start, Stop and Restart

Sage uses Brew services in order to start|stop|restart DnsMasq service.

Available next commands:

  • sage dns:start alias for sudo brew services start dnsmasq
  • sage dns:stop alias for sudo brew services stop dnsmasq
  • sage dns:restart it stops services if it's running and starts it

It's possible to use Brew commands directly however be aware that DnsMasq services should be run as root user (starts with sudo)