Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AddressFamily ¶
type AddressFamily uint8
AddressFamily selects the address family used by DHCP.
const ( FamilyIPv4 AddressFamily = iota FamilyIPv6 )
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client owns a rtnetlink handle and any DHCP sessions started through it. A Client is safe for concurrent use.
func (*Client) Close ¶
Close stops DHCP sessions, removes resources owned by those sessions, and closes the rtnetlink handle. Close is idempotent.
func (*Client) Configure ¶
Configure applies a static address or starts a managed DHCP session. Configure does not automatically bring the interface up; call SetUp first. Applying a new configuration stops an existing DHCP session for the same interface and removes resources installed by that session.
func (*Client) Netlink ¶
Netlink returns the underlying handle so callers retain access to the full vishvananda/netlink API. The handle is owned by Client and must not be closed separately.
func (*Client) SetDown ¶
SetDown stops a DHCP session, removes its configured address and route, then brings the interface administratively down.
type Config ¶
type Config struct {
Interface string
Mode Mode
Static StaticConfig
DHCP DHCPConfig
}
Config is the high-level interface configuration request.
type DHCPConfig ¶
type DHCPConfig struct {
Family AddressFamily
Timeout time.Duration
Retries int
Metric int
RATimeout time.Duration
WriteDNS bool
DNSPath string
}
DHCPConfig controls the DHCP exchange and the default route installed from the lease. FamilyIPv4 is the default. For DHCPv6, the default route and additional DNS servers are learned from Router Advertisements. A zero Timeout or Retries uses dependency defaults. A zero RATimeout uses ten seconds. If WriteDNS is true, DNSPath is replaced with the DNS servers from DHCP and RA; an empty DNSPath defaults to /etc/resolv.conf.
type Lease ¶
type Lease struct {
Family AddressFamily
Address *net.IPNet
Gateway net.IP
DNS []net.IP
Server net.IP
LeaseTime time.Duration
RenewalTime time.Duration
RebindingTime time.Duration
}
Lease is the part of a DHCP lease needed by a network configuration consumer. DNS is always reported to the caller and is only written to a resolver file when DHCPConfig.WriteDNS is true. For DHCPv6, Gateway and DNS can include information learned from IPv6 Router Advertisements.
type StaticConfig ¶
type StaticConfig struct {
Address *net.IPNet
Gateway net.IP
Metric int
// FlushAddresses removes existing addresses of the same family before
// installing Address, preserving IPv6 link-local addresses. Removal is
// not rolled back if configuration fails.
FlushAddresses bool
}
StaticConfig describes the address and optional default route to install. The interface should have one configuration owner. Existing addresses are preserved unless FlushAddresses is true. Routes are not explicitly flushed, but a matching default route may be replaced.