Browse the Repo

file-type-icon.circleci
file-type-icon_ci
file-type-icon_docs
file-type-iconexamples
file-type-iconmodules
file-type-iconconsul-client-security-group-rules
file-type-iconconsul-cluster
file-type-iconconsul-iam-policies
file-type-iconconsul-security-group-rules
file-type-iconinstall-consul
file-type-iconinstall-dnsmasq
file-type-iconREADME.md
file-type-iconinstall-dnsmasq
file-type-iconrun-consul
file-type-iconsetup-systemd-resolved
file-type-iconREADME.md
file-type-icontest
file-type-icon.gitignore
file-type-icon.pre-commit-config.yaml
file-type-iconCODEOWNERS
file-type-iconCONTRIBUTING.md
file-type-iconLICENSE
file-type-iconNOTICE
file-type-iconREADME.md
file-type-iconmain.tf
file-type-iconoutputs.tf
file-type-iconvariables.tf

Browse the Repo

file-type-icon.circleci
file-type-icon_ci
file-type-icon_docs
file-type-iconexamples
file-type-iconmodules
file-type-iconconsul-client-security-group-rules
file-type-iconconsul-cluster
file-type-iconconsul-iam-policies
file-type-iconconsul-security-group-rules
file-type-iconinstall-consul
file-type-iconinstall-dnsmasq
file-type-iconREADME.md
file-type-iconinstall-dnsmasq
file-type-iconrun-consul
file-type-iconsetup-systemd-resolved
file-type-iconREADME.md
file-type-icontest
file-type-icon.gitignore
file-type-icon.pre-commit-config.yaml
file-type-iconCODEOWNERS
file-type-iconCONTRIBUTING.md
file-type-iconLICENSE
file-type-iconNOTICE
file-type-iconREADME.md
file-type-iconmain.tf
file-type-iconoutputs.tf
file-type-iconvariables.tf
HashiCorp Consul

HashiCorp Consul

Deploy a Consul cluster. Supports automatic bootstrapping, DNS, Consul UI, and auto healing.

Code Preview

Preview the Code

mobile file icon

README.md

down

Dnsmasq Install Script

This folder contains a script for installing Dnsmasq and configuring it to forward requests for a specific domain to Consul. This way, you can easily use Consul as your DNS server for domain names such as foo.service.consul, where foo is a service registered with Consul (see the Registering Services docs for instructions on registering your services with Consul). All other domain names will continue to be resolved via the default resolver on your OS. See the Consul DNS Forwarding Guide for more info, including trade-offs between using this module and systemd-resolved for DNS forwarding.

This script has been tested on the following operating systems:

  • Ubuntu 16.04
  • Amazon Linux 2

There is a good chance it will work on other flavors of Debian, CentOS, and RHEL as well.

Quick start

To install Dnsmasq, use git to clone this repository at a specific tag (see the releases page for all available tags) and run the install-dnsmasq script:

git clone --branch <VERSION> https://github.com/hashicorp/terraform-aws-consul.git
terraform-aws-consul/modules/install-dnsmasq/install-dnsmasq

Note: by default, the install-dnsmasq script assumes that a Consul agent is already running locally and connected to a Consul cluster. After the install completes, restart dnsmasq (e.g. sudo /etc/init.d/dnsmasq restart) and queries to the .consul domain will be resolved via Consul:

dig foo.service.consul

We recommend running the install-dnsmasq script as part of a Packer template to create an Amazon Machine Image (AMI) (see the consul-ami example for sample code).

Command line Arguments

The install-dnsmasq script accepts the following arguments:

  • consul-domain DOMAIN: The domain name to point to Consul. Optional. Default: consul.
  • consul-ip IP: The IP address to use for Consul. Optional. Default: 127.0.0.1. This assumes a Consul agent is running locally and connected to a Consul cluster.
  • consul-dns-port PORT: The port Consul uses for DNS requests. Optional. Default: 8600.
  • dnsmasq-listen-address IP: The IP address for dnsmasq to listen on. Optional. Defaults to the value of consul-ip. Make sure that the network interface you provide for the IP has already been configured before you pass it to dnsmasq.

Example:

install-dnsmasq

Troubleshooting

Add the +trace argument to dig commands to more clearly see what's going on:

dig vault.service.consul +trace

Questions? Ask away.

We're here to talk about our services, answer any questions, give advice, or just to chat.

Ready to hand off the Gruntwork?