Documentation ¶
Overview ¶
Package dhclient provides a unified interface for interfacing with both DHCPv4 and DHCPv6 clients.
Index ¶
- Variables
- func Configure4(iface netlink.Link, packet *dhcpv4.DHCPv4) error
- func Configure6(iface netlink.Link, packet *dhcpv6.Message) error
- func IfUp(ifname string) (netlink.Link, error)
- func Interfaces(ifName string) ([]netlink.Link, error)
- func SendRequests(ctx context.Context, ifs []netlink.Link, ipv4, ipv6 bool, c Config) chan *Result
- func WriteDNSSettings(ns []net.IP, sl []string, domain string) error
- type Config
- type Lease
- type LogLevel
- type Packet4
- type Packet6
- type Result
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNoBootFile represents that no pxe boot file was found. ErrNoBootFile = errors.New("no boot file name present in DHCP message") // ErrNoServerHostName represents that no pxe boot server was found. ErrNoServerHostName = errors.New("no server host name present in DHCP message") )
Functions ¶
func Configure4 ¶
Configure4 adds IP addresses, routes, and DNS servers to the system.
func Configure6 ¶
Configure6 adds IPv6 addresses, routes, and DNS servers to the system.
func Interfaces ¶
Interfaces takes an RE and returns a []netlink.Link that matches it, or an error. It is an error for the returned list to be empty.
func SendRequests ¶
SendRequests coordinates soliciting DHCP configuration on all ifs.
ipv4 and ipv6 determine whether to send DHCPv4 and DHCPv6 requests, respectively.
The *Result channel will be closed when all requests have completed.
Types ¶
type Config ¶
type Config struct { // Timeout is the timeout for one DHCP request attempt. Timeout time.Duration // Retries is how many times to retry DHCP attempts. Retries int // LogLevel determines the amount of information printed for each // attempt. The highest log level should print each entire packet sent // and received. LogLevel LogLevel }
Config is a DHCP client configuration.
type Lease ¶
type Lease interface { fmt.Stringer // Configure configures the associated interface with the network // configuration. Configure() error // Boot is a URL to obtain booting information from that was part of // the network config. Boot() (*url.URL, error) // Link is the interface the configuration is for. Link() netlink.Link }
Lease is a network configuration obtained by DHCP.
type Packet4 ¶
Packet4 implements convenience functions for DHCPv4 packets.
func NewPacket4 ¶
NewPacket4 wraps a DHCPv4 packet with some convenience methods.
func (*Packet4) GatherDNSSettings ¶
GatherDNSSettings gets the DNS related infromation from a dhcp packet including, nameservers, domain, and search options
type Packet6 ¶
type Packet6 struct {
// contains filtered or unexported fields
}
Packet6 implements Packet for IPv6 DHCP.
func NewPacket6 ¶
NewPacket6 wraps a DHCPv6 packet with some convenience methods.
func (*Packet6) Boot ¶
Boot returns the boot file URL and parameters assigned.
TODO: RFC 5970 is helpfully avoidant of where these options are used. Are they added to the packet? Are they added to an IANA? It *seems* like it's in the packet.
func (*Packet6) Lease ¶
func (p *Packet6) Lease() *dhcpv6.OptIAAddress
Lease returns lease information assigned.
type Result ¶
type Result struct { // Interface is the network interface the attempt was sent on. Interface netlink.Link // Lease is the DHCP configuration returned. // // If Lease is set, Err is nil. Lease Lease // Err is an error that occured during the DHCP attempt. Err error }
Result is the result of a particular DHCP attempt.