OPNsense Forum

English Forums => General Discussion => Topic started by: Hypocrisy7186 on May 07, 2023, 12:39:06 PM

Title: DHCPv4 scope without gateway or DNS
Post by: Hypocrisy7186 on May 07, 2023, 12:39:06 PM
Hi I'm attempting to set up a DHCP scope for a network where I only want to allocate IP addresses. I can see I can set the gateway to "none" but I can't find away not to allocate DNS servers or DNS search suffix. Is this possible?
Title: Re: DHCPv4 scope without gateway or DNS
Post by: sphbecker on May 08, 2023, 11:44:36 PM
I don't see a way to do that with the included DHCP server. Just set DNS to 192.0.2.1 (RFC 1166 unusable address).

Considering your hosts will have no gateway, they will instantly see no possible route to that address, which should cause connection attempts to instantly fail without a single packet ever leaving the NIC.
Title: Re: DHCPv4 scope without gateway or DNS
Post by: Hypocrisy7186 on May 11, 2023, 09:06:20 AM
Thanks I'll give that a try
Title: Re: DHCPv4 scope without gateway or DNS
Post by: Hypocrisy7186 on May 18, 2023, 08:50:16 AM
Well it turned out that 192.0.2.1 did cause slow DNS for me as I hadn't considered instances that had network connections in to this network and then another network that had a default gateway. This then cause the 192.0.2.1 DNS server to be used from the DHCP network but then attempt to route out of network that had a default gateway. This then led to DNS resolution delays while this timed out.

I tried changing the DNS server to 127.0.0.255, the thinking being that my local resolver listens on 127.0.0.53 so it would fail quicker but it actually cause the DNS servers not to be applied. I'm not sure if its the DHCP server not publishing or my systems ignoring the loopback DNS config but either way its now working as I wanted.

So to summarise. If you want a DHCPv4 scope that only gives out IP addresses and not a gateway or DNS server(s) then setting the gateway to "none" and DNS to "127.0.0.255" worked for me.