Open jpmikkers opened 7 months ago
Binding to 0.0.0.0 is a bad idea for a DHCP server, it will start handing out IP leases on all your subnets.
From here https://stackoverflow.com/questions/13666789/receiving-udp-broadcast-packets-on-linux it seems I may have to bind another socket to the subnet broadcast address (e.g. 192.168.42.255) to receive broadcast packets on Linux.
@n-ice-ch I've created a test setup with ubuntu in virtualbox, indeed it seems broadcast packets are dropped somewhere. Disabling ufw doesn't help. I suspected my router, but the broadcasts arrive fine when I send them from ubuntu to windows. .To be continued..
Here's the issue: https://github.com/dotnet/runtime/issues/83525. The workaround looks clunky, will try it tomorrow.
Update: got it working on Ubuntu , so the trick is to bind to 0.0.0.0:67 but before that do a SO_BINDTODEVICE (bind to a specific nic) so it will only act as a DHCP server on that nic's subnet.
see https://github.com/jpmikkers/DHCPServer/blob/netcore/DHCPServer/Library/UDPSocketLinux.cs
Meanwhile, in that branch I've refactored the code a lot to use async/await, still needs some work in the main app though.
Sounds promising.
I've worked with IPAddress.Any for meanwhile. In my case it does not matter which subnet to serve as I use it as simple PXE.
But on Linux I can serve BIOS requests only. For EFI it does not work with IPAddress.Any.
So I'm very interested on your research.
Update: got it working on Ubuntu , so the trick is to bind to 0.0.0.0:67 but before that do a SO_BINDTODEVICE (bind to a specific nic) so it will only act as a DHCP server on that nic's subnet.
see https://github.com/jpmikkers/DHCPServer/blob/netcore/DHCPServer/Library/UDPSocketLinux.cs
Meanwhile, in that branch I've refactored the code a lot to use async/await, still needs some work in the main app though.
Did you get any update for the issue on Linux?
Hi,
This could be a source for information: https://stackoverflow.com/questions/74940771/not-receiving-broadcast-udp-messages-when-binding-to-specific-address