I want to incorporate consul DNS into host resolution on amazon linux 2 (centos 7 series)

Asked 2 years ago, Updated 2 years ago, 164 views

consul is a service discovery tool, and one of its features is the dns feature.

[email protected] my-macbook.local.node.consul
# My-macbook.local.node.consul Resolved to 127.0.0.1 Wind Reply

Now that I think about deploying consul to aws, I wanted to do "host resolution on the server, (xxxxxx.consul) asks consul dns about the host name that consul can resolve, and everything else will be normal host resolution as before."

However, in order to achieve this, I think it's unclear what kind of configuration you'll have to configure on the ec2 server to achieve this.

In principle, I think I can do this by installing the consul itself on the ec2 server (and setting up the consul itself) and then fiddling around the ec2 OS configuration, but I wonder where it is set up in the first place.

Question

What is the configuration on Amazon linux 2 (i.e., about centos 7) to get part of its host resolution (xxxx.consul) from consul dns?

  • Consul itself will be installed on the server itself
  • Motivation to allow other apps to resolve as host URLs, such as db_host:mysql.service.consul.

linux centos dns amazon-linux

2022-09-29 20:27

1 Answers

As for CentOS7, which is not on EC2, I set resolv.conf to ask dnsmasq in localhost, and if it is .consul, I will go ask consul.

/etc/resolv.conf

nameserver 127.0.0.1
nameserver xxx.xxx.xxx.xxx
nameserver xxx.xxx.xxx.xxx

/etc/dnsmasq.d/consul.conf

 server=/consul/xxx.xxx.xxx.xxx#8600

That's right.


2022-09-29 20:27

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.