diff --git a/command/agent/agent.go b/command/agent/agent.go index 5d8b663b02..13431c24ef 100644 --- a/command/agent/agent.go +++ b/command/agent/agent.go @@ -440,9 +440,10 @@ func (a *Agent) consulConfig() (*consul.Config, error) { } // set the src address for outgoing rpc connections - // to RPCAdvertise with port 0 so that outgoing - // connections use a random port. - base.RPCSrcAddr = &net.TCPAddr{IP: base.RPCAdvertise.IP} + // Use port 0 so that outgoing connections use a random port. + if !isAddrANY(base.RPCAddr.IP) { + base.RPCSrcAddr = &net.TCPAddr{IP: base.RPCAddr.IP} + } // Format the build string revision := a.config.Revision