summaryrefslogtreecommitdiff
path: root/libpod/networking_linux.go
diff options
context:
space:
mode:
Diffstat (limited to 'libpod/networking_linux.go')
-rw-r--r--libpod/networking_linux.go22
1 files changed, 22 insertions, 0 deletions
diff --git a/libpod/networking_linux.go b/libpod/networking_linux.go
index addf1814c..ef2f034ab 100644
--- a/libpod/networking_linux.go
+++ b/libpod/networking_linux.go
@@ -35,6 +35,15 @@ import (
"golang.org/x/sys/unix"
)
+const (
+ // slirp4netnsIP is the IP used by slirp4netns to configure the tap device
+ // inside the network namespace.
+ slirp4netnsIP = "10.0.2.100"
+
+ // slirp4netnsDNS is the IP for the built-in DNS server in the slirp network
+ slirp4netnsDNS = "10.0.2.3"
+)
+
// Get an OCICNI network config
func (r *Runtime) getPodNetwork(id, name, nsPath string, networks []string, ports []ocicni.PortMapping, staticIP net.IP, staticMAC net.HardwareAddr, netDescriptions ContainerNetworkDescriptions) ocicni.PodNetwork {
var networkKey string
@@ -541,12 +550,25 @@ func (r *Runtime) setupRootlessPortMappingViaRLK(ctr *Container, netnsPath strin
}
}
+ childIP := slirp4netnsIP
+outer:
+ for _, r := range ctr.state.NetworkStatus {
+ for _, i := range r.IPs {
+ ipv4 := i.Address.IP.To4()
+ if ipv4 != nil {
+ childIP = ipv4.String()
+ break outer
+ }
+ }
+ }
+
cfg := rootlessport.Config{
Mappings: ctr.config.PortMappings,
NetNSPath: netnsPath,
ExitFD: 3,
ReadyFD: 4,
TmpDir: ctr.runtime.config.Engine.TmpDir,
+ ChildIP: childIP,
}
cfgJSON, err := json.Marshal(cfg)
if err != nil {