From beae5c6bba3eb1bf2868e49431f979fa270423e1 Mon Sep 17 00:00:00 2001 From: Sean Chittenden Date: Sat, 4 Mar 2017 20:41:15 -0800 Subject: [PATCH 1/2] Change `ClientAddr` to default to `BindAddr` when not present. With this change, it is now possible to only specify the `-bind` or `bind_addr` attributes and get a functioning consul agent. --- command/agent/command.go | 6 ++++++ command/agent/config.go | 1 - website/source/docs/agent/options.html.markdown | 13 +++++++++---- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/command/agent/command.go b/command/agent/command.go index 1ee73527c57a..49f3fbd11e6b 100644 --- a/command/agent/command.go +++ b/command/agent/command.go @@ -264,6 +264,12 @@ func (c *Command) readConfig() *Config { } } + // If the client address is empty, default to using the value specified by the + // bind address. + if config.ClientAddr == "" { + config.ClientAddr = config.BindAddr + } + // Ensure all endpoints are unique if err := config.verifyUniqueListeners(); err != nil { c.Ui.Error(fmt.Sprintf("All listening endpoints must be unique: %s", err)) diff --git a/command/agent/config.go b/command/agent/config.go index bd507628cad0..a75cac18acc7 100644 --- a/command/agent/config.go +++ b/command/agent/config.go @@ -742,7 +742,6 @@ func DefaultConfig() *Config { Datacenter: consul.DefaultDC, Domain: "consul.", LogLevel: "INFO", - ClientAddr: "127.0.0.1", BindAddr: "0.0.0.0", Ports: PortConfig{ DNS: 8600, diff --git a/website/source/docs/agent/options.html.markdown b/website/source/docs/agent/options.html.markdown index 591eaaf27c01..46c4d9a74792 100644 --- a/website/source/docs/agent/options.html.markdown +++ b/website/source/docs/agent/options.html.markdown @@ -115,8 +115,9 @@ will exit with an error at startup. [`-bind` command-line flag](#_bind), and if this is not specified, the `-bind` option is used. This is available in Consul 0.7.1 and later. * `-client` - The address to which - Consul will bind client interfaces, including the HTTP and DNS servers. By default, - this is "127.0.0.1", allowing only loopback connections. + Consul will bind client interfaces, including the HTTP and DNS servers. When + not specified, the default value is the same as + the [`_bind` command-line flag](#_bind) address. * `-config-file` - A configuration file to load. For more information on @@ -586,8 +587,12 @@ Consul will not enable TLS for the HTTP API unless the `https` port has been ass reduce write pressure. If a check ever changes state, the new state and associated output is synchronized immediately. To disable this behavior, set the value to "0s". -* `client_addr` Equivalent to the - [`-client` command-line flag](#_client). +* `client_addr` Equivalent + to the [`-client` command-line flag](#_client). When not specified, the + default value is the same as the [`bind_addr`](#bind_addr) address. It is not + normally necessary to specify this value, however, may be necessary in more + complex setups where agents are NATed or when an agent is running in client + and server mode (common in development). * `datacenter` Equivalent to the [`-datacenter` command-line flag](#_datacenter). From df50950600add9f1acc293cae7bb1b03f9fd3c1a Mon Sep 17 00:00:00 2001 From: Sean Chittenden Date: Mon, 6 Mar 2017 12:26:35 -0800 Subject: [PATCH 2/2] Note the default value prior to 0.8 for `-client` was `127.0.0.1`. --- website/source/docs/agent/options.html.markdown | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/website/source/docs/agent/options.html.markdown b/website/source/docs/agent/options.html.markdown index 46c4d9a74792..cf4cdc924f5f 100644 --- a/website/source/docs/agent/options.html.markdown +++ b/website/source/docs/agent/options.html.markdown @@ -116,8 +116,8 @@ will exit with an error at startup. * `-client` - The address to which Consul will bind client interfaces, including the HTTP and DNS servers. When - not specified, the default value is the same as - the [`_bind` command-line flag](#_bind) address. + not specified, the default value is the same as the [`_bind` command-line + flag](#_bind) address (prior to 0.8 the default value was `127.0.0.1`). * `-config-file` - A configuration file to load. For more information on @@ -589,10 +589,11 @@ Consul will not enable TLS for the HTTP API unless the `https` port has been ass * `client_addr` Equivalent to the [`-client` command-line flag](#_client). When not specified, the - default value is the same as the [`bind_addr`](#bind_addr) address. It is not - normally necessary to specify this value, however, may be necessary in more - complex setups where agents are NATed or when an agent is running in client - and server mode (common in development). + default value is the same as the [`bind_addr`](#bind_addr) address (prior to + `0.8` the default value was `127.0.0.1`). It is not normally necessary to + specify this value, however, may be necessary in more complex setups where + agents are NATed or when an agent is running in client and server mode (common + in development). * `datacenter` Equivalent to the [`-datacenter` command-line flag](#_datacenter).