Skip to content

DNS names generated with underscores (_) violate RFC 952/1123 hostname rules during dotnet new #64978

@Tasteful

Description

@Tasteful

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

The template/tooling generates DNS names (e.g., hostnames or domain labels) that contain underscores (_). According to DNS hostname specifications (RFC 952 and RFC 1123), underscores are not valid characters in hostnames. This causes failures in environments and libraries that strictly validate DNS names (e.g., Kubernetes, Docker, cloud DNS, and DNS client libraries).

Actual Behavior

Generated names include underscores—e.g., my_service.example.com, MY_SERVICE, or derived labels such as my_service-api. These are rejected by systems enforcing RFC-compliant DNS hostnames.

Impact

  • Deployment failures in Kubernetes/Docker due to invalid DNS labels.
  • DNS resolution errors in client libraries.
  • Operational inconsistencies if environments silently mutate invalid names.
  • Developer confusion when template output contradicts DNS standards.

References

  • RFC 952 — DoD Internet Host Table Specification: hostnames use letters, digits, and hyphen; no leading/trailing hyphen.
  • RFC 1123 — Requirements for Internet Hosts – Application and Support: relaxes RFC 952 to allow starting with a digit; underscores remain invalid for hostnames.
  • SRV records (underscores in service labels are valid): see service naming like _sip._tcp.example.com.

Additional Notes

If this template also generates SRV/DKIM/DMARC records or service identifiers, underscores are expected only in those service labels—not in hostnames.

Expected Behavior

Generated names should only use:

  • Letters a–z (case-insensitive)
  • Digits 0–9
  • Hyphen -

Additional rules:

  • Labels must not start or end with a hyphen.
  • Each label must be ≤ 63 characters.
  • The full domain must be ≤ 253 characters.
  • No underscores in hostnames (allowed only in special record labels like SRV/DKIM/DMARC service identifiers, e.g., _sip._tcp).

Steps To Reproduce

Create a new project using localhost tld's and a name including dots (.)

dotnet new web --localhost-tld -n "my.namespace.web"

Exceptions (if any)

No response

.NET Version

10.0.101

Anything else?

No response

Metadata

Metadata

Labels

area-infrastructureIncludes: MSBuild projects/targets, build scripts, CI, Installers and shared frameworkfeature-templates

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions