From 2f1b2199c58d52f79a1aa251e482b00b8a3e0056 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Wed, 27 Sep 2023 18:25:23 +0800 Subject: [PATCH] Fix DHCPv4 listen address --- transport/dhcp/server.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/transport/dhcp/server.go b/transport/dhcp/server.go index 7288b94d..b07412f4 100644 --- a/transport/dhcp/server.go +++ b/transport/dhcp/server.go @@ -6,6 +6,7 @@ import ( "net/netip" "net/url" "os" + "runtime" "strings" "sync" "time" @@ -176,7 +177,11 @@ func (t *Transport) fetchServers0(ctx context.Context, iface *net.Interface) err var listener net.ListenConfig listener.Control = control.Append(listener.Control, control.BindToInterface(t.router.InterfaceFinder(), iface.Name, iface.Index)) listener.Control = control.Append(listener.Control, control.ReuseAddr()) - packetConn, err := listener.ListenPacket(t.ctx, "udp4", "0.0.0.0:68") + listenAddr := "0.0.0.0:68" + if runtime.GOOS == "linux" || runtime.GOOS == "android" { + listenAddr = "255.255.255.255:68" + } + packetConn, err := listener.ListenPacket(t.ctx, "udp4", listenAddr) if err != nil { return err }