Documentation ¶
Overview ¶
Package dhclient allows for getting both DHCPv4 and DHCPv6 leases on multiple network interfaces in parallel.
Index ¶
- Variables
- func Configure4(iface netlink.Link, packet *dhcpv4.DHCPv4) error
- func Configure6(iface netlink.Link, packet *dhcpv6.Message) error
- func FilterBondedInterfaces(ifs []netlink.Link, verbose bool) []netlink.Link
- func IfUp(ifname string, linkUpTimeout time.Duration) (netlink.Link, error)
- func Interfaces(ifName string) ([]netlink.Link, error)
- func ParseISCSIURI(s string) (*net.TCPAddr, string, 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 NetworkProtocol
- type Packet4
- func (p *Packet4) Boot() (*url.URL, error)
- func (p *Packet4) Configure() error
- func (p *Packet4) GatherDNSSettings() (ns []net.IP, sl []string, dom string)
- func (p *Packet4) ISCSIBoot() (*net.TCPAddr, string, error)
- func (p *Packet4) Lease() *net.IPNet
- func (p *Packet4) Link() netlink.Link
- func (p *Packet4) Message() (*dhcpv4.DHCPv4, *dhcpv6.Message)
- func (p *Packet4) Response() interface{}
- func (p *Packet4) String() string
- type Packet6
- func (p *Packet6) Boot() (*url.URL, error)
- func (p *Packet6) Configure() error
- func (p *Packet6) DNS() []net.IP
- func (p *Packet6) ISCSIBoot() (*net.TCPAddr, string, error)
- func (p *Packet6) Lease() *dhcpv6.OptIAAddress
- func (p *Packet6) Link() netlink.Link
- func (p *Packet6) Message() (*dhcpv4.DHCPv4, *dhcpv6.Message)
- func (p *Packet6) String() string
- 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") // ErrNoRootPath means no root path option was found in DHCP message. ErrNoRootPath = errors.New("no root path in DHCP message") // ErrNoServerHostName represents that no pxe boot server was found. ErrNoServerHostName = errors.New("no server host name present in DHCP message") )
var DefaultScheme = "tftp"
DefaultScheme for boot file if there are none in the lease
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 FilterBondedInterfaces ¶
FilterBondedInterfaces takes a slice of links, checks to see if any of them are already bonded to a bond, and returns the ones that aren't bonded.
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 ParseISCSIURI ¶
Format:
iscsi:@"<servername>":"<protocol>":"<port>":"<LUN>":"<targetname>"
@ for now will be ignored. Eventually we would want complete support. iscsi:[<username>:<password>[:<reverse>:<password>]@]"<servername>":"<protocol>":"<port>"[:[<iscsi_iface_name>]:[<netdev_name>]]:"<LUN>":"<targetname>" "<servername>" may contain an IPv6 address enclosed with [] with an arbitrary but bounded number of colons.
"<targetname>" may contain an arbitrary string with an arbitrary number of colons.
func SendRequests ¶
func SendRequests(ctx context.Context, ifs []netlink.Link, ipv4, ipv6 bool, c Config, linkUpTimeout time.Duration) chan *Result
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 // Modifiers4 allows modifications to the IPv4 DHCP request. Modifiers4 []dhcpv4.Modifier // Modifiers6 allows modifications to the IPv6 DHCP request. Modifiers6 []dhcpv6.Modifier // V6ServerAddr can be a unicast or broadcast destination for DHCPv6 // messages. // // If not set, it will default to nclient6's default (all servers & // relay agents). V6ServerAddr *net.UDPAddr // V6ClientPort is the port that is used to send and receive DHCPv6 // messages. // // If not set, it will default to dhcpv6's default (546). V6ClientPort *int // V4ServerAddr can be a unicast or broadcast destination for IPv4 DHCP // messages. // // If not set, it will default to nclient4's default (DHCP broadcast // address). V4ServerAddr *net.UDPAddr // If true, add Client Identifier (61) option to the IPv4 request. V4ClientIdentifier bool }
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) // ISCSIBoot returns the target address and volume name to boot from if // they were part of the DHCP message. ISCSIBoot() (*net.TCPAddr, string, error) // Link is the interface the configuration is for. Link() netlink.Link // Return the full DHCP response, this is either a *dhcpv4.DHCPv4 or a // *dhcpv6.Message. Message() (*dhcpv4.DHCPv4, *dhcpv6.Message) }
Lease is a network configuration obtained by DHCP.
type NetworkProtocol ¶
type NetworkProtocol int
NetworkProtocol is either IPv4 or IPv6.
const ( NetIPv4 NetworkProtocol = 1 NetIPv6 NetworkProtocol = 2 NetBoth NetworkProtocol = 3 )
Possible network protocols; either IPv4, IPv6, or both.
func (NetworkProtocol) String ¶
func (n NetworkProtocol) String() string
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
func (*Packet4) ISCSIBoot ¶
ISCSIBoot returns the target address and volume name to boot from if they were part of the DHCP message.
Parses the IPv4 DHCP Root Path for iSCSI target and volume as specified by RFC 4173.
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) ISCSIBoot ¶
ISCSIBoot returns the target address and volume name to boot from if they were part of the DHCP message.
Parses the DHCPv6 Boot File for iSCSI target and volume as specified by RFC 4173 and RFC 5970.
func (*Packet6) Lease ¶
func (p *Packet6) Lease() *dhcpv6.OptIAAddress
Lease returns lease information assigned.
type Result ¶
type Result struct { // Protocol is the IP protocol that we tried to configure. Protocol NetworkProtocol // 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.