TechnitiumSoftware/DnsServer · error · DnsServerException
Invalid domain name [{value}]: IP address cannot be used for
Error message
Invalid domain name [{value}]: IP address cannot be used for DNS server domain name. What it means
Thrown by the ServerDomain setter when the (Unicode->IDNA-normalized) value parses successfully as an IPAddress. The DNS server's domain must be a domain NAME, not an IP; using an IP would break SOA records, responsible-person mail, and NS generation.
Source
Thrown at DnsServerCore/Dns/DnsServer.cs:7108
#endregion
#region properties
public string ServerDomain
{
get { return _serverDomain; }
set
{
if (!_serverDomain.Equals(value, StringComparison.Ordinal))
{
if (DnsClient.IsDomainNameUnicode(value))
value = DnsClient.ConvertDomainNameToAscii(value);
DnsClient.IsDomainNameValid(value, true);
if (IPAddress.TryParse(value, out _))
throw new DnsServerException("Invalid domain name [" + value + "]: IP address cannot be used for DNS server domain name.");
_serverDomain = value.ToLowerInvariant();
_fallbackResponsiblePerson = new MailAddress("hostadmin@" + _serverDomain);
_authZoneManager.TriggerUpdateServerDomain();
_allowedZoneManager.UpdateServerDomain();
_blockedZoneManager.UpdateServerDomain();
_blockListZoneManager.UpdateServerDomain();
UpdateThisServer();
}
}
}
public string ConfigFolder
{ get { return _configFolder; } }
public IReadOnlyList<IPEndPoint> LocalEndPointsView on GitHub (pinned to d0484b6c1e)
Solutions
- Set ServerDomain to an actual hostname (e.g. ns1.example.com), and set the listen address separately via localEndPoints.
- If you have no domain, register one or use a dynamic-DNS hostname.
- Fix the configuration source (env var/UI/config file) that is feeding an IP into the domain field.
- Validate that IPAddress.TryParse(value) is false before assignment.
Example fix
// before
server.ServerDomain = "10.0.0.5";
// after
server.ServerDomain = "ns1.example.com";
server.LocalEndPoints = new[] { new IPEndPoint(IPAddress.Parse("10.0.0.5"), 53) }; Defensive patterns
Strategy: validation
Validate before calling
string SafeServerDomain(string value)
{
if (DnsClient.IsDomainNameUnicode(value)) value = DnsClient.ConvertDomainNameToAscii(value);
DnsClient.IsDomainNameValid(value, true);
if (IPAddress.TryParse(value, out _)) throw new ArgumentException("Server domain must be a hostname, not an IP");
return value.ToLowerInvariant();
} Type guard
static bool IsValidServerDomain(string value)
{
if (string.IsNullOrWhiteSpace(value)) return false;
if (IPAddress.TryParse(value, out _)) return false;
try { DnsClient.IsDomainNameValid(value, true); return true; } catch { return false; }
} Try / catch
try { server.ServerDomain = value; }
catch (DnsServerException ex) when (ex.Message.Contains("IP address cannot be used")) { return BadRequest("Provide a domain name, not an IP"); } Prevention
- Distinguish server domain (hostname) from bind address (IP) in config.
- Validate that the value is not an IP literal before assignment.
- Use a real registered or dynamic-DNS hostname for ServerDomain.
When it happens
Trigger: Setting ServerDomain to a string that is a valid IP literal (e.g. "192.168.1.1" or "::1") after IDNA conversion. The setter first validates the domain name, then explicitly rejects IP-form values.
Common situations: Operator confuses the server domain with the bind/listen address; copy-paste from a connection string; automation reading the listen IP into the domain field; misconfigured env var (e.g. SERVER_DOMAIN=10.0.0.5).
Related errors
- Network group map contains an invalid network address: {strN
- External to internal translation entries must have same addr
- External to internal translation entries must have same pref
- The SSO Authority URL length cannot be more than 255 chars.
- The SSO Authority URL scheme can be 'http' or 'https' only.
AI-assisted analysis of TechnitiumSoftware/DnsServer@d0484b6c1e (2026-08-13).
Data as JSON: /api/errors/9ae0d2de9a291d8d.
Report an issue: GitHub.