-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Closed
Description
by krolaw:
In writing my DHCP library I have found: l, err := net.ListenPacket("udp4", "192.168.1.250:67") Listens on one interface but ignores broadcast packets coming to that interface. So I end up using: l, err := net.ListenPacket("udp4", ":67") Listens on all interfaces and captures broadcast packets: On a device with multiple interfaces this can be problematic. The workaround so far has been to use iptables to block dhcp client packets coming in on unwanted interfaces. However, there is still the issue that any response packet doesn't go over the correct interface. When I try to open a new udp socket on the correct interface (using ip), and source port, it obviously doesn't work as the listener bound to that port. The workaround has been to open a new udp socket on a different port and use iptables to SNAT the source port on the way through to 67. Having a ListenBroadcastUDP function would also make writing client side DHCP practical. Thanks.