Config options with comments -

consul agent -dev           # run agent

consul members              # show members
                -detailed   # show additional details

consul join <ip>            # join member to server (on server: client ip;  on client: server ip)

curl localhost:8500/v1/catalog/nodes            # check nodes
curl localhost:8500/v1/catalog/service/web
curl localhost:8500/v1/health/state/critical    # check health cheks

Consul agent options:

consul agent
    -server                     # act node at server mode
    -bootstrap-expect=1         # hints to the Consul server the number of additional server nodes we are expecting to join
    -node=<name>                # override unique name of node. By default, Consul uses the hostname
    -bind=<ip>                  # address that Consul listens on. It must be accessible by all other nodes in the cluster
    -config-dir=/etc/consul.d   # marking where service and check definitions can be found
    -join=<ip>                  # auto join in cluster (connect to server)
    -ui                         # enable web ui (port:8500)
    -client=             # listen ip
    -http-port=<port>           # http port (default:8500)


Consul Server:

./consul agent -ui -server -bootstrap-expect=1 -enable-script-checks=true -data-dir=/tmp/consul -client -config-dir=consul.d -bind=<public_ip> -datacenter=dc1


# Start server
consul agent -server -bootstrap-expect=1 -data-dir=/tmp/consul -node=agent-one -bind= -config-dir=/etc/consul.d

# Add node to server
consul join

# Query for the address of the node "agent-two"
dig @ -p 8600 agent-two.node.consul


# Start agent
consul agent -data-dir=/tmp/consul -node=agent-two -bind= -config-dir=/etc/consul.d

# Definition files in the Consul configuration directory (restart agent after add definition)
sudo nano /etc/consul.d/ping.json
        "check": {
            "name": "ping",
            "script": "ping -c1 >/dev/null",
            "interval": "30s"

sudo nano /etc/consul.d/web.json
        "service": {
            "name": "web",
            "tags": ["rails"],
            "port": 80,
            "check": {
                "script": "curl localhost >/dev/null 2>&1",
                "interval": "10s"

dig @ -p 8600 web.service.consul