Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/22773.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:improvement
connect: default upstream.local_bind_address to ::1 for IPv6 agent bind address
```
3 changes: 2 additions & 1 deletion agent/structs/connect_proxy_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,8 @@ type Upstream struct {
Datacenter string

// LocalBindAddress is the ip address a side-car proxy should listen on for
// traffic destined for this upstream service. Default if empty is 127.0.0.1.
// traffic destined for this upstream service. Default if empty is 127.0.0.1 for IPv4
// or ::1 if IPv6 agent bind address.
LocalBindAddress string `json:",omitempty" alias:"local_bind_address"`

// LocalBindPort is the ip address a side-car proxy should listen on for traffic
Expand Down
13 changes: 12 additions & 1 deletion connect/proxy/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package proxy

import (
"fmt"
"github.com/hashicorp/consul/agent/netutil"
"net"
"strconv"
"time"
Expand All @@ -19,6 +20,11 @@ import (
"github.com/hashicorp/go-hclog"
)

const (
defaultIPv4LocalBindAddress = "127.0.0.1"
defaultIPv6LocalBindAddress = "::1"
)

// Config is the publicly configurable state for an entire proxy instance. It's
// mostly used as the format for the local-file config mode which is mostly for
// dev/testing. In normal use, different parts of this config are pulled from
Expand Down Expand Up @@ -115,7 +121,12 @@ func (uc *UpstreamConfig) applyDefaults() {
uc.DestinationPartition = "default"
}
if uc.LocalBindAddress == "" && uc.LocalBindSocketPath == "" {
uc.LocalBindAddress = "127.0.0.1"
dualStack, _ := netutil.IsDualStack()
if dualStack {
uc.LocalBindAddress = defaultIPv6LocalBindAddress
} else {
uc.LocalBindAddress = defaultIPv4LocalBindAddress
}
}
}

Expand Down
Loading