network.go 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. package configs
  2. // Network defines configuration for a container's networking stack
  3. //
  4. // The network configuration can be omitted from a container causing the
  5. // container to be setup with the host's networking stack
  6. type Network struct {
  7. // Type sets the networks type, commonly veth and loopback
  8. Type string `json:"type"`
  9. // Name of the network interface
  10. Name string `json:"name"`
  11. // The bridge to use.
  12. Bridge string `json:"bridge"`
  13. // MacAddress contains the MAC address to set on the network interface
  14. MacAddress string `json:"mac_address"`
  15. // Address contains the IPv4 and mask to set on the network interface
  16. Address string `json:"address"`
  17. // Gateway sets the gateway address that is used as the default for the interface
  18. Gateway string `json:"gateway"`
  19. // IPv6Address contains the IPv6 and mask to set on the network interface
  20. IPv6Address string `json:"ipv6_address"`
  21. // IPv6Gateway sets the ipv6 gateway address that is used as the default for the interface
  22. IPv6Gateway string `json:"ipv6_gateway"`
  23. // Mtu sets the mtu value for the interface and will be mirrored on both the host and
  24. // container's interfaces if a pair is created, specifically in the case of type veth
  25. // Note: This does not apply to loopback interfaces.
  26. Mtu int `json:"mtu"`
  27. // TxQueueLen sets the tx_queuelen value for the interface and will be mirrored on both the host and
  28. // container's interfaces if a pair is created, specifically in the case of type veth
  29. // Note: This does not apply to loopback interfaces.
  30. TxQueueLen int `json:"txqueuelen"`
  31. // HostInterfaceName is a unique name of a veth pair that resides on in the host interface of the
  32. // container.
  33. HostInterfaceName string `json:"host_interface_name"`
  34. // HairpinMode specifies if hairpin NAT should be enabled on the virtual interface
  35. // bridge port in the case of type veth
  36. // Note: This is unsupported on some systems.
  37. // Note: This does not apply to loopback interfaces.
  38. HairpinMode bool `json:"hairpin_mode"`
  39. }
  40. // Routes can be specified to create entries in the route table as the container is started
  41. //
  42. // All of destination, source, and gateway should be either IPv4 or IPv6.
  43. // One of the three options must be present, and omitted entries will use their
  44. // IP family default for the route table. For IPv4 for example, setting the
  45. // gateway to 1.2.3.4 and the interface to eth0 will set up a standard
  46. // destination of 0.0.0.0(or *) when viewed in the route table.
  47. type Route struct {
  48. // Sets the destination and mask, should be a CIDR. Accepts IPv4 and IPv6
  49. Destination string `json:"destination"`
  50. // Sets the source and mask, should be a CIDR. Accepts IPv4 and IPv6
  51. Source string `json:"source"`
  52. // Sets the gateway. Accepts IPv4 and IPv6
  53. Gateway string `json:"gateway"`
  54. // The device to set this route up for, for example: eth0
  55. InterfaceName string `json:"interface_name"`
  56. }