TechnitiumSoftware / DnsServer

Technitium DNS Server
https://technitium.com/dns/
GNU General Public License v3.0
4.47k stars 431 forks source link

Unable to enable DHCP scope #336

Closed CyberfoxDK closed 3 years ago

CyberfoxDK commented 3 years ago

It is possible to configure the DHCP scope, but not possible to enable it. Windows Server 2019 standalone, single nic. Firewall disabled. Running on VMware esxi 6.7.0U3

2021-10-31 11:35:21 UTC] [192.168.11.2:67] DHCP Server failed to activate scope: LAN System.Net.Sockets.SocketException (10048): Only one usage of each socket address (protocol/network address/port) is normally permitted. at System.Net.Sockets.Socket.UpdateStatusAfterSocketErrorAndThrowException(SocketError error, String callerName) at System.Net.Sockets.Socket.DoBind(EndPoint endPointSnapshot, SocketAddress socketAddress) at System.Net.Sockets.Socket.Bind(EndPoint localEP) at DnsServerCore.Dhcp.DhcpServer.<>c__DisplayClass26_0.b__0(IPAddress key) in Z:\Technitium\Projects\DnsServer\DnsServerCore\Dhcp\DhcpServer.cs:line 888 at System.Collections.Concurrent.ConcurrentDictionary2.GetOrAdd(TKey key, Func2 valueFactory) at DnsServerCore.Dhcp.DhcpServer.BindUdpListener(IPEndPoint dhcpEP) in Z:\Technitium\Projects\DnsServer\DnsServerCore\Dhcp\DhcpServer.cs:line 862 at DnsServerCore.Dhcp.DhcpServer.ActivateScopeAsync(Scope scope, Boolean waitForInterface) in Z:\Technitium\Projects\DnsServer\DnsServerCore\Dhcp\DhcpServer.cs:line 970

CyberfoxDK commented 3 years ago

Looks like the scope configuration is binding to the servers ip, and not 0.0.0.0 after uninstalling Technitium, running cc-cleaner, rebooting, installing Technitium again the default scope shows 0.0.0.0 instead of deleting the default scope (which i did earlier) i edited the default scpe (this way retaining the eth bind to 0.0.0.0) at configured my settings. Now everything works as expected.... but interface now shows interface ip (192.168.11.2) and not 0.0.0.0

ShreyasZare commented 3 years ago

Thanks for the post.

System.Net.Sockets.SocketException (10048): Only one usage of each socket address (protocol/network address/port) is normally permitted.

The error that you reported quoted above means that there is another application running on your server which is using UDP port 67 and thus the Technitium DHCP server is unable to bind on the same port.

You can test this with netstat -ano | find ":67" command and find out the which process is using that UDP port by matching its PID from the command and checking with the process list in task manager.

When you managed to get it working after reboot, it could be just that the other process using the UDP port didn't start up so the DHCP scope worked as expected. Technitium DNS server does not require restarting the app to apply any settings so as to not lose the DNS cache. Even things like changing ports or socket bindings is done without restarting the app.

So, the steps like using cc-cleaner (Technitium does not use registry for any settings), reinstalling the software, etc. made no difference.

ShreyasZare commented 3 years ago

Looks like the scope configuration is binding to the servers ip, and not 0.0.0.0 after uninstalling Technitium, running cc-cleaner, rebooting, installing Technitium again the default scope shows 0.0.0.0 instead of deleting the default scope (which i did earlier) i edited the default scpe (this way retaining the eth bind to 0.0.0.0) at configured my settings. Now everything works as expected.... but interface now shows interface ip (192.168.11.2) and not 0.0.0.0

If the DHCP scope shows the interface as "0.0.0.0" then it means that none of the server's network interfaces are in that scope's IP address range thus the scope will just listen on "0.0.0.0" so that DHCP relay agents can connect with it from any network interface.

When one of the server's network interfaces is in the DHCP scope's range then the scope will bind to the IP address of the interface and the interface's IP address will be displayed in the UI.

CyberfoxDK commented 3 years ago

Thanks for the post.

System.Net.Sockets.SocketException (10048): Only one usage of each socket address (protocol/network address/port) is normally permitted.

The error that you reported quoted above means that there is another application running on your server which is using UDP port 67 and thus the Technitium DHCP server is unable to bind on the same port.

You can test this with netstat -ano | find ":67" command and find out the which process is using that UDP port by matching its PID from the command and checking with the process list in task manager.

When you managed to get it working after reboot, it could be just that the other process using the UDP port didn't start up so the DHCP scope worked as expected. Technitium DNS server does not require restarting the app to apply any settings so as to not lose the DNS cache. Even things like changing ports or socket bindings is done without restarting the app.

So, the steps like using cc-cleaner (Technitium does not use registry for any settings), reinstalling the software, etc. made no difference. (I did not get it working after reboot... i had to unisntall, cc clean, reboot and install from scratch.)

This is the strange part, no other service is running. It seems to me that the previous version of technitium is not completely uninstalled, and still working on this. Only after running cccleaner after uninstall and reboot, the service came up again. No other service were using UDP 67 or any of the other bootP or DHCP protocols on the server.

Technitium may not use registry for anything, but it still have referances in the registry. I will try to see if i can recreate the issue on a new server.

CyberfoxDK commented 3 years ago

Looks like the scope configuration is binding to the servers ip, and not 0.0.0.0 after uninstalling Technitium, running cc-cleaner, rebooting, installing Technitium again the default scope shows 0.0.0.0 instead of deleting the default scope (which i did earlier) i edited the default scpe (this way retaining the eth bind to 0.0.0.0) at configured my settings. Now everything works as expected.... but interface now shows interface ip (192.168.11.2) and not 0.0.0.0

If the DHCP scope shows the interface as "0.0.0.0" then it means that none of the server's network interfaces are in that scope's IP address range thus the scope will just listen on "0.0.0.0" so that DHCP relay agents can connect with it from any network interface.

When one of the server's network interfaces is in the DHCP scope's range then the scope will bind to the IP address of the interface and the interface's IP address will be displayed in the UI.

After a short while, the interface changed from 0.0.0.0 to the servers ip 192.168.11.2 But it is quite comon that interfaces listening to 0.0.0.0 means listening to all interfaces on the server. (Even though it is bad practice)

CyberfoxDK commented 3 years ago

Tried to recreate the issue, but without success. Thank you for your suggestions ShreyasZare.