Differences between Bind and Advertise?

2,366 views
Skip to first unread message

Shaowei Png

unread,
May 2, 2016, 6:31:12 PM5/2/16
to Consul
While experimenting with the notes given on https://hub.docker.com/r/progrium/consul/ , I realized that for a particular command, "advertise" worked but using "bind" gave me an error message.

Can someone please explain to me what's the difference between advertise and bind, and why this error occurred?
I tried reading https://www.consul.io/docs/agent/options.html for the explanations but I don't quite get it.

This is run on an AWS EC2 instance with docker installed, and the private ip address is the instance's private ip address.

1) docker run -p 8400:8400 -p 8500:8500 -p 8600:53/udp -h node1 progrium/consul -server -advertise my-private-ip-address

This worked.

2) docker run -p 8400:8400 -p 8500:8500 -p 8600:53/udp -h node1 progrium/consul -server -bind my-private-ip-address

Logs:
==> WARNING: It is highly recommended to set GOMAXPROCS higher than 1
==> Starting raft data migration...
==> Starting Consul agent...
==> Error starting agent: Failed to start Consul server: Failed to start RPC layer: listen tcp 172.31.18.165:8300: bind: cannot assign requested address

Thank you for reading,
Shaowei

Michael Fischer

unread,
May 2, 2016, 6:51:16 PM5/2/16
to consu...@googlegroups.com
"bind" is the interface/IP that the Consul agent itself is supposed to use on the local machine.

"advertise" is the IP that Consul tells other agents and clients to connect to, when talking to this host.  

Best practice is to run Consul in a Docker container with host-level networking, and so "bind" and "advertise" should be the same.  (In other words, you shouldn't need to specify an "advertise" address.)

Best regards,

--Michael

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/hashicorp/consul/issues
IRC: #consul on Freenode
---
You received this message because you are subscribed to the Google Groups "Consul" group.
To unsubscribe from this group and stop receiving emails from it, send an email to consul-tool...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/consul-tool/b59fb39b-22bf-49c5-b6a4-67897877901f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Oren Shomron

unread,
May 4, 2016, 4:57:14 PM5/4/16
to Consul
Hi there,

I'm having a related issue. I am also running Consul in Docker on EC2 and am using the default network which requires NAT. I'm starting all nodes with -advertise <public_address> so that they can find eachother, as well as -join <master_public_address>.

On the master, I get logs like this:

    2016/05/04 18:57:39 [WARN] memberlist: Got ping for unexpected node 'consul-test-2' from=172.17.0.1:53090

...where 172.17.0.1 is on the private network. Is this address encoded in the ping packet?
On the master, tcpdump -i eth0 "udp port 8301" shows me that all incoming packets are indeed on the "public network".

For one of the other nodes, I seem to be getting a mix of public and private:

    2016/05/04 18:57:40 [WARN] memberlist: Got ping for unexpected node 'consul-test-1' from=172.17.0.1:53090
    2016/05/04 18:57:41 [WARN] memberlist: Got ping for unexpected node 'consul-test-1' from=10.x.x.x.:8301
    2016/05/04 18:57:41 [WARN] memberlist: Got ping for unexpected node consul-test-1 from=172.17.0.1:50148

Any help would be appreciated!

Thanks,
  - Oren

Oren Shomron

unread,
May 4, 2016, 5:03:50 PM5/4/16
to Consul
...scratch that. A bug in my script was using the wrong (master's) IP as the advertise for the additional nodes, which was causing craziness.

Thanks anyway! :)
Reply all
Reply to author
Forward
0 new messages