dhcp

package
v0.0.0-...-efa7b7e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 17, 2026 License: AGPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Start

func Start(iface, preferredClient string, daemonMode bool) error

Start launches a DHCPv4 client for the given interface. If preferredClient is empty, uses the native client. If preferredClient is "dhclient", "dhcpcd", or "udhcpc", uses that external client. In daemon mode, native client stays running to renew leases; otherwise it's oneshot.

func StartV6

func StartV6(iface string, daemonMode bool) error

StartV6 launches a DHCPv6 client for the given interface.

func Status

func Status(iface string) string

Status returns the DHCP status for an interface.

func Stop

func Stop(iface string) error

Stop kills the DHCP client running on the given interface.

func StopAll

func StopAll() error

StopAll kills all DHCP clients managed by nic.

Types

type Lease

type Lease struct {
	Interface  string    `json:"interface"`
	IP         string    `json:"ip"`
	SubnetMask string    `json:"subnet_mask"`
	Router     string    `json:"router"`
	DNS        []string  `json:"dns"`
	Domain     string    `json:"domain,omitempty"`
	ServerIP   string    `json:"server_ip"`
	LeaseTime  uint32    `json:"lease_time"`
	RenewTime  uint32    `json:"renew_time"`
	RebindTime uint32    `json:"rebind_time"`
	AcquiredAt time.Time `json:"acquired_at"`
}

Lease holds DHCPv4 lease information.

func (*Lease) CIDR

func (l *Lease) CIDR() string

CIDR returns the IP/prefix string for ip addr add.

func (*Lease) ExpiryDeadline

func (l *Lease) ExpiryDeadline() time.Time

ExpiryDeadline returns when the lease expires.

func (*Lease) RebindDeadline

func (l *Lease) RebindDeadline() time.Time

RebindDeadline returns when the lease enters rebinding state.

func (*Lease) RenewalDeadline

func (l *Lease) RenewalDeadline() time.Time

RenewalDeadline returns when the lease should be renewed.

type LeaseV6

type LeaseV6 struct {
	Interface  string    `json:"interface"`
	Addresses  []V6Addr  `json:"addresses"`
	DNS        []string  `json:"dns"`
	ServerDUID []byte    `json:"server_duid"`
	ClientDUID []byte    `json:"client_duid"`
	IAID       uint32    `json:"iaid"`
	RenewTime  uint32    `json:"renew_time"`
	RebindTime uint32    `json:"rebind_time"`
	AcquiredAt time.Time `json:"acquired_at"`
}

LeaseV6 holds DHCPv6 lease information.

func (*LeaseV6) ExpiryDeadline

func (l *LeaseV6) ExpiryDeadline() time.Time

ExpiryDeadline returns when the first DHCPv6 address becomes invalid.

func (*LeaseV6) RebindDeadline

func (l *LeaseV6) RebindDeadline() time.Time

RebindDeadline returns when the earliest DHCPv6 IA_NA must be rebound.

func (*LeaseV6) RenewalDeadline

func (l *LeaseV6) RenewalDeadline() time.Time

RenewalDeadline returns when the earliest DHCPv6 IA_NA should be renewed.

type V6Addr

type V6Addr struct {
	IP            string `json:"ip"`
	PrefixLen     int    `json:"prefix_len"`
	PreferredLife uint32 `json:"preferred_life"`
	ValidLife     uint32 `json:"valid_life"`
}

V6Addr holds a single DHCPv6 address with lifetimes.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL