Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide instructions and demo how to successfully run dhcp server on Linux Ubuntu #21

Open
jpmikkers opened this issue Jan 23, 2024 · 7 comments
Assignees

Comments

@jpmikkers
Copy link
Owner

No description provided.

@n-ice-ch
Copy link

Hi,

This could be a source for information:
https://stackoverflow.com/questions/74940771/not-receiving-broadcast-udp-messages-when-binding-to-specific-address

@jpmikkers
Copy link
Owner Author

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.

@jpmikkers
Copy link
Owner Author

@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..

@jpmikkers
Copy link
Owner Author

Here's the issue: dotnet/runtime#83525.
The workaround looks clunky, will try it tomorrow.

@jpmikkers
Copy link
Owner Author

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.

@n-ice-ch
Copy link

n-ice-ch commented Feb 7, 2024

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.

@n-ice-ch
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants