How to use numbers in DNS host names

binddomain-name-system

I want to setup an DNS record which contains only digits, for example:

www1                    A       1.2.3.4
1                       CNAME   www1

However, the pure number seems not work.

I know some sites which use integer in their host names, something like 400.5432.somefax.com, so I guess maybe I should escape the numbers?

EDIT

It seems BIND do support labels of pure numbers:

$ dig @localhost 1.example.com
...
1.example.com.     43200  IN  CNAME  www1.example.com.
www1.example.com.  43200  IN  A      1.2.3.4
...

However, when I use the Google DNS server (8.8.8.8), it's failed.

; <<>> DiG 9.7.3 <<>> 1.example.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 20866
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 0

;; QUESTION SECTION:
;1.example.com.         IN  A

;; AUTHORITY SECTION:
example.com.        1205    IN  SOA root.example.com. admin.example.com. 5 3600 600 43200 3600

;; Query time: 112 msec
;; SERVER: 8.8.8.8#53(8.8.8.8)
;; WHEN: Tue May  3 19:09:39 2011
;; MSG SIZE  rcvd: 94

However, Google DNS server should be no problem with number labels, because it can resolve, for example, 83592583.qzone.qq.com:

; <<>> DiG 9.7.3 <<>> 83592583.qzone.qq.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 18687
;; flags: qr rd ra; QUERY: 1, ANSWER: 4, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;83592583.qzone.qq.com.     IN  A

;; ANSWER SECTION:
83592583.qzone.qq.com.  600 IN  CNAME   qq.com.edgesuite.net.
qq.com.edgesuite.net.   9439    IN  CNAME   a1574.b.akamai.net.
a1574.b.akamai.net. 18  IN  A   60.254.175.65
a1574.b.akamai.net. 18  IN  A   60.254.175.64

;; Query time: 328 msec
;; SERVER: 8.8.8.8#53(8.8.8.8)
;; WHEN: Tue May  3 19:12:10 2011
;; MSG SIZE  rcvd: 134

So, BIND9 is okay, Google DNS is okay, my zone config is okay, I can dig @localhost 1.example.com which gives the correct answer. But I can't dig @8.8.8.8 1.example.com, (neither 8.8.4.4), Now I stuck.

Best Answer

RFC 1912, documenting common DNS configuration errors, states:

Allowable characters in a label for a host name are only ASCII letters, digits, and the `-' character. Labels may not be all numbers, but may have a leading digit (e.g., 3com.com). Labels must end and begin only with a letter or digit. See [RFC 1035] and [RFC 1123]. (Labels were initially restricted in [RFC 1035] to start with a letter, and some older hosts still reportedly have problems with the relaxation in [RFC 1123].) Note there are some Internet hostnames which violate this rule (411.org, 1776.com). The presence of underscores in a label is allowed in [RFC 1033], except [RFC 1033] is informational only and was not defining a standard. There is at least one popular TCP/IP implementation which currently refuses to talk to hosts named with underscores in them.

Label is equivalent to hostname for your question.

RFC1912 is informational, not setting a standard. In the way of informational RFCs, some DNS implementations took it as gospel and therefore don't work with all numbers. Which is another way of saying, for maximum compatibility with the entire Internet, put at least one letter in your hostnames.

Obviously it can work (heck, the RFC cites examples!), so the trick is convincing your DNS server to allow it. And for that, I'll have to defer to other users.

Related Topic