Skip to content

Instantly share code, notes, and snippets.

@ti-mo
Created July 20, 2022 07:27
Show Gist options
  • Save ti-mo/7021866d54e2c9f617f9c800db210976 to your computer and use it in GitHub Desktop.
Save ti-mo/7021866d54e2c9f617f9c800db210976 to your computer and use it in GitHub Desktop.
dhcpv6 client for simple 4-way exchange
package main
import (
"flag"
"fmt"
"github.com/insomniacslk/dhcp/dhcpv6"
"github.com/insomniacslk/dhcp/dhcpv6/client6"
)
var (
iface = flag.String("i", "eth0", "Interface to configure via DHCPv6")
)
func main() {
flag.Parse()
c := client6.NewClient()
msgs, err := c.Exchange(*iface,
dhcpv6.WithClientID(dhcpv6.Duid{
Type: dhcpv6.DUID_UUID,
Uuid: []byte{0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1},
}),
dhcpv6.WithIAPD([4]byte{0, 0, 0, 1}),
)
if err != nil {
panic(err)
}
for _, msg := range msgs {
fmt.Println(msg.Summary())
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment