:thought_balloon: Add an option to bind consul to a specific interface and whatever the ip address of that interface is. For example, if I'm provisioning 100 servers, I might know I'll have a bond1 on my servers that I know I want consul to bind to. If it's not the first private interface, I won't be able to rely on 0.0.0.0 and I don't want to have to specify the IP addresses for 100 servers in my configs. Just a thought since a lot of people seem to be having issues with consul binding to interfaces it should not be binding to. Does that make sense?
In general the concept makes sense to me, but I wonder what we do in cases where we have multiple IP aliases on a single interface. I'll mark this as a thought ticket for now.
Ryan, good point. I was thinking about a use case specifically where this is not the case. I think it would be safe to assume if you're using this feature and there is more than one IP on a NIC, consul could issue a warning that it cannot bind reliably to the NIC and fall back on binding as it does to 0.0.0.0
This would be a great addition, and would help greatly during our packer base box provisions.
May I suggest an alternative configuration to the same end? Instead of specifying an interface name using a distinct option, I'd prefer specifying a network with the existing options, e.g. 10.1.2.0/24 - with the implementation then picking the local address found being inside that network.
For the deployment I'm planning, I have three types of boxes that all share the same network, but each type has a different interface naming convention.
@cruatta / @jness / @bof : Please give the latest code in master a twirl. The syntax for supporting IP addresses or getting the first "usable" IP address on an interface is included below and can be passed to any address parameter within Consul (e.g. -bind or bind_addr, or any other *_addr-like parameter):
-bind='{{ GetInterfaceIP "eth0" }}'
-bind='{{ GetAllInterfaces | include "network" "192.168.0.0/16" }}'
There is now a configurable template language for examples and docs) behind this that you can use to create a customizable heuristic that should allow you to get whatever it is that you need from your environment when using an immutable image (see hashicorp/go-sockaddr/template and cmd/sockaddr.
Most helpful comment
@cruatta / @jness / @bof : Please give the latest code in
mastera twirl. The syntax for supporting IP addresses or getting the first "usable" IP address on an interface is included below and can be passed to any address parameter within Consul (e.g.-bindorbind_addr, or any other*_addr-like parameter):There is now a configurable template language for examples and docs) behind this that you can use to create a customizable heuristic that should allow you to get whatever it is that you need from your environment when using an immutable image (see hashicorp/go-sockaddr/template and cmd/sockaddr.