Hostname Naming Convention Generator with RFC 1123 Checks

This hostname naming convention generator builds lists of hostnames from a template such as {site}-{role}-{type}-{seq}. It combines your values, zero-pads the sequence number, checks every name against the RFC 952 and RFC 1123 rules (labels up to 63 characters, FQDN up to 253, no leading hyphen), flags collisions with names you already have, and exports a CSV.

Result

The result updates automatically as you change any input.

Formula and worked steps
Formulas used
  • Hostname label: 1 to 63 characters; letters, digits and hyphens; no leading or trailing hyphen (RFC 952, relaxed by RFC 1123 to allow a leading digit)
  • FQDN: at most 253 characters in text form (255 octets on the wire, RFC 1035)
  • Names generated = product of the value lists used in the template x count of sequence numbers
  • Zero padding: sequence number written with at least the chosen number of digits
  • Collision: the same name (case-insensitive) generated twice or already in your list
Assumptions
  • Operating systems and directory services apply their own limits on top of DNS rules, for example 15 characters for NetBIOS and Windows computer names. Check the limits of your platforms.
  • Names are compared case-insensitively because DNS is. The domain part of existing names is ignored when checking for collisions.
  • Underscores are valid in some DNS names (such as service records) but not in hostnames, so they are reported as invalid.
References

Naming Fibre Channel zones and aliases? Use the SAN zoning naming convention generator or the SAN zone alias generator, which follow SAN conventions for WWPNs and fabrics; this page is for DNS hostnames.

Building SAN aliases from WWPNs? Use the SAN zone alias generator; this page generates and validates DNS hostnames.

What is a hostname naming convention?

A naming convention is a rule for building the name of every machine, switch or appliance from a fixed pattern. A good one makes names predictable: someone who sees nyc-web-vm-07 knows the site, the role and the kind of system without looking it up. It makes automation simple, since scripts can build names instead of fetching them, and it keeps inventories, monitoring and DNS consistent. A poor one grows by accident: names carry jokes, old project names and information that has since changed.

Tokens and templates

The generator uses a template with tokens in braces: {site}, {role}, {type}, {env} and {seq}. Each token other than {seq} has a list of values, such as sites nyc and lon, and roles web and db. The tool produces every combination, and for {seq} it adds a number from the start value, for as many numbers as you ask. The template {site}-{role}-{type}-{seq} with two sites, two roles, one type and three numbers produces 12 names, from nyc-web-vm-01 to lon-db-vm-03.

Zero padding

Padding the number with zeros makes names sort in the right order and keeps their length constant: web-01 and web-10 sort correctly where web-1 and web-10 do not. Choose a width that leaves room to grow; two digits holds 99 machines per group and three holds 999. A number that outgrows the padding still works, so the 100th server in a two-digit scheme is simply named 100, but the names then sort and align less well.

How the hostname generator validates names

The label rules

A hostname is one label in the DNS. RFC 952 defined the original rules: letters, digits and hyphens, with no hyphen at the start or end. RFC 1123 relaxed them to allow a name to start with a digit, as in 3com.example. DNS limits a label to 63 characters, and the full domain name to 253 characters in text form, which is 255 octets on the wire including the length bytes. The tool applies the RFC 1123 rule by default, and has a strict option that rejects names starting with a digit for systems that still follow RFC 952.

What is not allowed

Spaces, underscores, dots inside a label, accented characters and punctuation are not valid in a hostname. Underscores are a common surprise: they appear in some DNS names, such as service records, but are not allowed in hostnames, and some software rejects them. A label that exceeds 63 characters, an empty label, or a leading or trailing hyphen is flagged with the reason. If you give a domain suffix, the tool also checks that the resulting FQDN fits in 253 characters and that the domain’s own labels are valid.

Collision checking

Two machines with the same name cause hard-to-find faults. The generator compares names without regard to case, because DNS is case-insensitive, and flags any name that is produced twice, for example because the same value appears twice in a list, and any name that is already in the list of existing names that you paste. Existing names may include their domain; the tool ignores it. The status column says OK, Invalid with the reason, or Collision.

Worked example

With the default template, two sites, two roles, one type, three numbers and padding of two, the tool produces 12 names. Adding the domain corp.example.com gives FQDNs of 30 characters, such as nyc-web-vm-01.corp.example.com. If you paste nyc-web-vm-01 as an existing name, that row is reported as a collision and the other 11 are OK. If you replaced a role with a 60-character string, the generated labels would exceed 63 characters and be flagged invalid. The summary reports the longest label and the longest FQDN so that you can see how close you are to the limits.

Why it matters for network engineers

Names are the first thing everybody sees: in monitoring, logs, tickets and CLI prompts. Consistent names let you filter, sort and automate; inconsistent ones need tribal knowledge. They also touch DNS directly, since every hostname is a DNS record in most environments. Generating names in bulk avoids typos and makes sure that every name is valid before it reaches a configuration, which prevents failed deployments and the awkward renaming of devices already in service. When names change, plan the DNS cutover with the DNS propagation time calculator.

Best practices and common mistakes

Keep names short and stable: encode what does not change, such as site and role, and keep what does change, such as owner or project, in a CMDB or tags. RFC 1178 gives long-standing advice on choosing names, including avoiding names that depend on facts that will change. Use lower case, hyphens as separators and fixed-width numbers. Reserve space in the pattern for environments and for new sites, and document the scheme with an example for every device type.

Common mistakes are mixing separators, using location in names of machines that may move, putting the IP address or the VLAN in the name, and picking a scheme so long that the FQDN approaches the limit when sub-domains are added. Another is forgetting that some systems apply shorter limits, such as the 15-character limit for Windows computer names, so check the strictest platform you run. If you also label cabling or racks with a related scheme, the patch panel port planner shows one approach for physical labels. For SAN zoning aliases, which follow different rules, see the SAN zoning naming convention generator and the SAN zone alias generator.

Rolling it out

Generate the list, export the CSV and load it into your inventory and DNS before you build the machines. Create forward and reverse records together, including IPv6 reverse zones, which you can plan with the IPv6 subnet calculator. Review the convention yearly: if a new site or type does not fit, extend the pattern deliberately instead of making an exception.

FAQs

What characters are allowed in a hostname?

Letters, digits and hyphens. A label may not start or end with a hyphen. RFC 952 did not allow a leading digit; RFC 1123 relaxed that. Underscores and spaces are not allowed.

What is the maximum length of a hostname and FQDN?

A single label is limited to 63 characters, and a fully qualified domain name to 253 characters in text form (255 octets on the wire).

Why zero-pad hostname numbers?

Padding makes names a fixed length and sort in the right order: web-01 and web-10 sort correctly, while web-1 and web-10 do not.

What makes a good server naming convention?

Short, stable names built from a fixed pattern of values that rarely change, such as site, role and type, plus a padded sequence number, with changeable details kept in an inventory.

Next, try the DNS propagation time, the IPv6 subnet calculator and patch panel port calculator, or browse all DNS & Naming calculators and the full list of network calculators.