Is the hostname case sensitive? Is


equal to

ping myhost

Does it depend on the DNS used? Are there differences between Win/Mac/Unix systems?

  • 671
  • 1
  • 7
  • 14

4 Answers4


Names resolved from DNS are case insensitive. This is important to prevent confusion. If it was case sensitive then we would have eight variants of .com (.com, .Com, .cOm, .COm, .coM, .CoM, .cOM, and .COM). Country codes would have four.

If name resolution is case-sensitive for Ping it is not being done by DNS.

  • 27,737
  • 3
  • 37
  • 69
  • It does apparently get somewhat tricky after Internationalized Domain Names where added. In non-ASCII contexts case may matter. – Zoredache Apr 19 '11 at 17:15
  • 4
    @Zoredache: It appears the internationalized domains using the IDNA system must be encodable in Punycode, which involves translation to lowercase. There are also additional restrictions to ensure the names are visually distinct. Also you don't want to force users to ensure they get the case right. – BillThor Apr 19 '11 at 17:34

I've just had this here at work. DNS should be case insensitive.... the RFC (RFC 4343 - Domain Name System (DNS) Case Insensitivity Clarification) specifies that but doesn't say it MUST be lower case.

So we had the pleasure of troubleshooting a host that didn't resolve things right for our internal domain "t.local"

p123$ ping p123-db.t.local
PING p123-db.t.local ( 56(84) bytes of data.
....works ok

p123$ ping P123-dB.T.lOcal
ping: unknown host P123-dB.T.lOcal

Why bother resolving the mixed case? Because that's what tcpdump was showing as the DNS query because that's what the running software was asking for. pgbouncer was configured to use "p123-db" in its config, and resolv.conf specified a search domain of "t.local" So what is mixing up the case?

Turns out glibc was toggling the case randomly. The process is called "0x20 padding" and was first described in 2008 in "Use of Bit 0x20 in DNS Labels to Improve Transaction Identity" https://datatracker.ietf.org/doc/html/draft-vixie-dnsext-dns0x20-00

The main purpose is to increase the entropy so that its harder to fake a reply - the question's case must match the case of the answer.

A good discussion may be found here. https://developers.google.com/speed/public-dns/docs/security?csw=1#randomize_case

Separately, we run powerDNS internally, and that does lookups against a database. For years, noone has used a hostname or FQDN in the t.local domain with a capital letter, so we never noticed that our internal domain was case sensitive.

Was fixed by some tweaks in the query, but this would have broken the 0x20 mixed case lookups as above - the client may require the answer is returned in the same case as it was requested.

Short answer: DNS should not be case sensitive, but the question and answer will need to be identical case, in the future.

  • 1,842
  • 13
  • 21
  • 2,379
  • 14
  • 25
  • 4
    The answer 4 years after the question was asked, is subtly different. I wonder in another 4 years will the answer be "yes - DNS is now case sensitive" – Criggie Jan 28 '16 at 04:45

I just finished troubleshooting an issue on an embedded SE Linux device where host name resolution was exhibiting case sensitivity.

"ping MYHOST" would ping to, whereas "ping myhost" would ping the correct IP Address.

nslookup produced correct results for both uppercase and lowercase, indicating that the DNS server was not at fault.

But unlike nslookup, which ignores the cache, "getent hosts MYHOST" output "", and "getent hosts myhost" output the correct IP Address.

So nscd is apparently case sensitive. Calling "nscd -i hosts" to clear the cache fixed the issue.

The MYHOST in (uppercase) ended up cached with due to a process trying to establish a connection to MYHOST before the DNS entry was created, which happens when the remote device gets its DHCP assignment.


As BillThor mentioned, it's not case sensitive at the DNS or netbios resolution level.

The various OSes won't have a problem with the different casing either.

However, the applications may be aware of them. For example, the web platforms on the various environments can check for case sensitivity. It's more common now for search engine optimization (SEO) reasons to watch for different casing and redirect. That's all up to the application though so the answer there is that it varies.

For the 'most part' the hostname isn't a case sensitive concern at the application level either though.

Scott Forsyth
  • 16,449
  • 3
  • 37
  • 56