Skip to content

Commit

Permalink
Enable ipv6 for rootless users by default
Browse files Browse the repository at this point in the history
Fixes containers/podman#10889

Inspired by @rugk

Signed-off-by: Daniel J Walsh <[email protected]>
  • Loading branch information
rhatdan committed Sep 17, 2021
1 parent 096309b commit 4e098c6
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 4 deletions.
16 changes: 14 additions & 2 deletions docs/containers.conf.5.md
Original file line number Diff line number Diff line change
Expand Up @@ -467,11 +467,23 @@ and pods are visible.

Path to the slirp4netns binary.

**network_cmd_options**=[]
**network_cmd_options**=["enable_ipv6=true",]

Default options to pass to the slirp4netns binary.

Example "allow_host_loopback=true"
Valid options values are:

- **allow_host_loopback=true|false**: Allow the slirp4netns to reach the host loopback IP (`10.0.2.2`, which is added to `/etc/hosts` as `host.containers.internal` for your convenience). Default is false.
- **mtu=MTU**: Specify the MTU to use for this network. (Default is `65520`).
- **cidr=CIDR**: Specify ip range to use for this network. (Default is `10.0.2.0/24`).
- **enable_ipv6=true|false**: Enable IPv6. Default is false. (Required for `outbound_addr6`).
- **outbound_addr=INTERFACE**: Specify the outbound interface slirp should bind to (ipv4 traffic only).
- **outbound_addr=IPv4**: Specify the outbound ipv4 address slirp should bind to.
- **outbound_addr6=INTERFACE**: Specify the outbound interface slirp should bind to (ipv6 traffic only).
- **outbound_addr6=IPv6**: Specify the outbound ipv6 address slirp should bind to.
- **port_handler=rootlesskit**: Use rootlesskit for port forwarding. Default.
Note: Rootlesskit changes the source IP address of incoming packets to a IP address in the container network namespace, usually `10.0.2.100`. If your application requires the real source IP address, e.g. web server logs, use the slirp4netns port handler. The rootlesskit port handler is also used for rootless containers when connected to user-defined networks.
- **port_handler=slirp4netns**: Use the slirp4netns port forwarding, it is slower than rootlesskit but preserves the correct source IP address. This port handler cannot be used for user-defined networks.

**no_pivot_root**=false

Expand Down
5 changes: 5 additions & 0 deletions pkg/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,10 @@ image_copy_tmp_dir="storage"`
"TERM=xterm",
}

networkCmdOptions := []string{
"enable_ipv6=true",
}

helperDirs := []string{
"/somepath",
}
Expand All @@ -213,6 +217,7 @@ image_copy_tmp_dir="storage"`
gomega.Expect(defaultConfig.Engine.NumLocks).To(gomega.BeEquivalentTo(2048))
gomega.Expect(defaultConfig.Engine.OCIRuntimes).To(gomega.Equal(OCIRuntimeMap))
gomega.Expect(defaultConfig.Containers.HTTPProxy).To(gomega.Equal(false))
gomega.Expect(defaultConfig.Engine.NetworkCmdOptions).To(gomega.BeEquivalentTo(networkCmdOptions))
gomega.Expect(defaultConfig.Engine.HelperBinariesDir).To(gomega.Equal(helperDirs))
gomega.Expect(defaultConfig.Engine.ServiceTimeout).To(gomega.BeEquivalentTo(300))
})
Expand Down
2 changes: 1 addition & 1 deletion pkg/config/containers.conf
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ default_sysctls = [
# Default options to pass to the slirp4netns binary.
# For example "allow_host_loopback=true"
#
#network_cmd_options = []
#network_cmd_options = ["enable_ipv6=true",]

# Whether to use chroot instead of pivot_root in the runtime
#
Expand Down
4 changes: 3 additions & 1 deletion pkg/config/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,9 @@ func defaultConfigFromMemory() (*EngineConfig, error) {
c.CgroupManager = defaultCgroupManager()
c.ServiceTimeout = uint(5)
c.StopTimeout = uint(10)

c.NetworkCmdOptions = []string{
"enable_ipv6=true",
}
c.Remote = isRemote()
c.OCIRuntimes = map[string][]string{
"crun": {
Expand Down

0 comments on commit 4e098c6

Please sign in to comment.