Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add -bind-iface to bind consul to a specific interface #1110

Closed
cruatta opened this issue Jul 14, 2015 · 5 comments
Closed

Add -bind-iface to bind consul to a specific interface #1110

cruatta opened this issue Jul 14, 2015 · 5 comments
Labels
thinking More time is needed to research by the Consul Contributors

Comments

@cruatta
Copy link
Contributor

cruatta commented Jul 14, 2015

💭 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?

@ryanuber
Copy link
Member

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.

@ryanuber ryanuber added the thinking More time is needed to research by the Consul Contributors label Jul 14, 2015
@cruatta
Copy link
Contributor Author

cruatta commented Jul 15, 2015

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

@jness
Copy link

jness commented Jul 24, 2015

This would be a great addition, and would help greatly during our packer base box provisions.

@bof
Copy link

bof commented Aug 10, 2015

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.

@sean-
Copy link
Contributor

sean- commented Dec 2, 2016

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
thinking More time is needed to research by the Consul Contributors
Projects
None yet
Development

No branches or pull requests

5 participants