W
W
wadomon2019-04-26 15:55:54
Domain Name System
wadomon, 2019-04-26 15:55:54

How to force dns consul to give live ip?

How to make the internal dns of the consul give only a live ip on which the service is running, well, postgres for example. Did so

spoiler
postgres.json
consul.d# cat postgres.json 
{
   "services":[
      {
         "id":"pg_dbmaster",
         "name":"postgres",
         "address":"8.8.8.8",
         "tags":[
            "master"
         ],
         "port":5432
      },
      {
         "id":"pg_dbread",
         "name":"postgres",
         "address":"127.0.0.1",
         "tags":[
            "slave"
         ],
         "port":5432,
         "check":{
            "name":"pg_dbread_check",
            "tcp":"localhost:5432",
            "interval":"10s",
            "timeout":"1s"
         }
      }
   ]
}

on 127.0.0.1, the PG is specially dead, in theory, it should give only 8.8.8.8 to the request
dig @127.0.0.1 -p 8600 postgres.service.consul A +short
8.8.8.8

and he, a radish, gives both
dig @127.0.0.1 -p 8600 postgres.service.consul A +short
8.8.8.8
127.0.0.1

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question