Skip to content

Writing a DHCPv4 server on Windows. Is it supported? #497

@clarkmcc

Description

@clarkmcc

I'm working on writing a DHCP server. I recognize that on Windows this library won't bind to a specific network interface, so I tried this approach. I am able to successfully bind the UDP listener to the specific IP address which is assigned to a specific network interface, but I'm not seeing any logs indicating that packets are received.

conn, err := net.ListenUDP("udp4", &net.UDPAddr{
	IP:   net.ParseIP("10.0.0.253"),
	Port: dhcpv4.ServerPort,
})
require.NoError(t, err)

srv, err := server4.NewServer("Ethernet 2", nil, func(conn net.PacketConn, peer net.Addr, pkt *dhcpv4.DHCPv4) {
	fmt.Println("Received packet:", pkt.Summary())
}, server4.WithConn(conn))
require.NoError(t, err)
require.NoError(t, srv.Serve())

When I run this on macOS instead, it works just fine. Has anyone got this working on Windows before?

srv, err := server4.NewServer("Ethernet 2", &net.UDPAddr{
	IP:   net.ParseIP(":0"),
	Port: dhcpv4.ServerPort,
}, func(conn net.PacketConn, peer net.Addr, pkt *dhcpv4.DHCPv4) {
	fmt.Println("Received packet:", pkt.Summary())
})
require.NoError(t, err)
require.NoError(t, srv.Serve())

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions