Skip to content
This repository was archived by the owner on Dec 13, 2018. It is now read-only.
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
6 changes: 6 additions & 0 deletions configs/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ type Network struct {
// HostInterfaceName is a unique name of a veth pair that resides on in the host interface of the
// container.
HostInterfaceName string `json:"host_interface_name"`

// HairpinMode specifies if hairpin NAT should be enabled on the virtual interface
// bridge port in the case of type veth
// Note: This is unsupported on some systems.
// Note: This does not apply to loopback interfaces.
HairpinMode bool `json:"hairpin_mode"`
}

// Routes can be specified to create entries in the route table as the container is started
Expand Down
5 changes: 5 additions & 0 deletions network_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,11 @@ func (v *veth) create(n *network, nspid int) (err error) {
if err := netlink.NetworkSetMTU(host, n.Mtu); err != nil {
return err
}
if n.HairpinMode {
if err := netlink.SetHairpinMode(host, true); err != nil {
return err
}
}
if err := netlink.NetworkLinkUp(host); err != nil {
return err
}
Expand Down