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

Allows use of broadcast IP as bind address. #1570

Closed
wants to merge 1 commit into from

Conversation

beornf
Copy link

@beornf beornf commented Jan 7, 2016

In consul options, a binding address of 0.0.0.0 is used to resolve a nodes private IP. However if there are multiple private IPs this broadcast address is too wide as I found testing in a Docker container.

This allows the use of a given subnet IP e.g. 10.99.0.0 which will return the first matching IP among the network 10.99.0.0/24 such as 10.99.0.5. It also address a couple issues raised #1110 and #1478. Let me know if this solves the use case and follows idiomatic Go.

@dcowden
Copy link

dcowden commented Mar 22, 2016

+1 for this. I have a different use case, but this would help me a lot.

I'm currently using consul in a multi-host cluster. in this case, my consul nodes have two private ip addresses: one for my overlay network ( 10.X.X.X) and another for the host bridge network .

consul will not start in this case, because there are multiple 'private' ip addresses available.

Currently, my only option is to use -advertise or -bind to select the exact ip address. the problem with that, though, is that the ip address is dynamic, so there's no option available.

This PR would give me what i need. I want to bind to whatever address i get on the 10.X overlay network, without knowing in advance what exact IP it is.

@sean-
Copy link
Contributor

sean- commented Mar 25, 2016

@beornf , thank you for this PR. There is work that is landing soon that will address this issue. This issue and the others referenced above are all targets for this pending work. This is a problem we are aware of and will be addressing.

@beornf
Copy link
Author

beornf commented Mar 26, 2016

Cool. I've been following issue #725 about a proposal to bind to a given interface as well as subnet as done in this PR. Looking forward to the work that targets the many use cases.

@nejtr0n
Copy link

nejtr0n commented Apr 6, 2016

This issue is great. Please merge it!

@slackpad slackpad removed their assignment Apr 25, 2016
@westsouthnight
Copy link

Please merge

@ashald
Copy link
Contributor

ashald commented Jun 24, 2016

Any chances for this one to be merged?..

@kylegato
Copy link

+1 please merge, I have multiple VLANs and private IPs and need to be able to specify the correct network to bind to.

@raykrueger
Copy link

👍 yes please.

@ChrisLundquist
Copy link

@slackpad What can I do to help push this forward? This would really help me with some overlay/underlay networking stuff. There seems to be a merge conflict now, but the patch looks pretty self contained, so I'd imagine it is easy to resolve. I'd be happy to resolve the conflicts and make a new PR. I suspect there is something more keeping this from getting merged.

@slackpad slackpad self-assigned this Sep 16, 2016
@slackpad
Copy link
Contributor

I'll take another look here now that 0.7 is out. We have some other bind address related stuff pending so just need to make sure everything makes sense together.

@fhaynes
Copy link

fhaynes commented Nov 9, 2016

Any movement on this? It would be very helpful for us.

@ashald
Copy link
Contributor

ashald commented Nov 9, 2016

Yeah, we would be happy to have this feature as well!

@slackpad slackpad added this to the 0.7.2 milestone Nov 17, 2016
This was referenced Nov 30, 2016
@sean-
Copy link
Contributor

sean- commented Dec 2, 2016

@beornf / @dcowden / @nejtr0n / @westsouthnight / @ashald / @kylegato / @raykrueger / @ChrisLundquist / @fhaynes : 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" "10.99.0.0/24" }}'
-bind='{{ GetAllInterfaces | include "network" "10.99.0.0/24" | sort "size,address" | attr "address" }}'

With the sockaddr command you can experiment with getting the right template syntax with the eval sub-command, for instance:

$ sockaddr eval 'GetAllInterfaces | include "network" "10.99.0.0/24" | sort "size,address" | attr "address"'
10.99.0.5

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
type/enhancement Proposed improvement or new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.