network.go 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. // Route defines a routing table entry.
  41. //
  42. // Routes can be specified to create entries in the routing table as the container
  43. // is started.
  44. //
  45. // All of destination, source, and gateway should be either IPv4 or IPv6.
  46. // One of the three options must be present, and omitted entries will use their
  47. // IP family default for the route table. For IPv4 for example, setting the
  48. // gateway to 1.2.3.4 and the interface to eth0 will set up a standard
  49. // destination of 0.0.0.0(or *) when viewed in the route table.
  50. type Route struct {
  51. // Destination specifies the destination IP address and mask in the CIDR form.
  52. Destination string `json:"destination"`
  53. // Source specifies the source IP address and mask in the CIDR form.
  54. Source string `json:"source"`
  55. // Gateway specifies the gateway IP address.
  56. Gateway string `json:"gateway"`
  57. // InterfaceName specifies the device to set this route up for, for example eth0.
  58. InterfaceName string `json:"interface_name"`
  59. }