Domain Name System(DNS) Syntax Rules

What is a domain name, Why IANA cares?
Domain names are used to access machines over local network or internet with human readable syntax instead of IPs. www.example.com is the global example domain name that is reserved for educational purposes by IANA. IANA(International Assigned Numbers Association) manages DNS root zone and many other critical protocols and standards of internet. At first glance, i will highlight the right most part of domain name "com", our example domain name. "com" is defined by IANA as a top level domain name (TLD) and there are 312 TLDs and six kind of top level domain names presented in IANA DNS Root Zone:
  1. country-code(tr, ru, us, uk...), 
  2. sponsored(xxx, jobs, travel), 
  3. infrastructure(arpa), 
  4. generic-restricted(biz, name, pro), 
  5. generic(com, info, net), 
  6. test(.భారత్)
In the IANA DNS Root zone page, there is each of top level domain names and related organizations listed.

tlds-alpha-by-domain.txt
# Version 2011121300, Last Updated Tue Dec 13 15:07:02 2011 UTC
AC
AD
AE
AERO
AF
AG
AI
AL
AM
AN
AO
AQ
AR
ARPA
AS
ASIA
AT
AU
AW
AX
AZ
BA
BB
BD
BE
BF
BG
BH
BI
BIZ
BJ
BM
BN
BO
BR
BS
BT
BV
BW
BY
BZ
CA
CAT
CC
CD
CF
CG
CH
CI
CK
CL
CM
CN
CO
COM
COOP
CR
CU
CV
CW
CX
CY
CZ
DE
DJ
DK
DM
DO
DZ
EC
EDU
EE
EG
ER
ES
ET
EU
FI
FJ
FK
FM
FO
FR
GA
GB
GD
GE
GF
GG
GH
GI
GL
GM
GN
GOV
GP
GQ
GR
GS
GT
GU
GW
GY
HK
HM
HN
HR
HT
HU
ID
IE
IL
IM
IN
INFO
INT
IO
IQ
IR
IS
IT
JE
JM
JO
JOBS
JP
KE
KG
KH
KI
KM
KN
KP
KR
KW
KY
KZ
LA
LB
LC
LI
LK
LR
LS
LT
LU
LV
LY
MA
MC
MD
ME
MG
MH
MIL
MK
ML
MM
MN
MO
MOBI
MP
MQ
MR
MS
MT
MU
MUSEUM
MV
MW
MX
MY
MZ
NA
NAME
NC
NE
NET
NF
NG
NI
NL
NO
NP
NR
NU
NZ
OM
ORG
PA
PE
PF
PG
PH
PK
PL
PM
PN
PR
PRO
PS
PT
PW
PY
QA
RE
RO
RS
RU
RW
SA
SB
SC
SD
SE
SG
SH
SI
SJ
SK
SL
SM
SN
SO
SR
ST
SU
SV
SX
SY
SZ
TC
TD
TEL
TF
TG
TH
TJ
TK
TL
TM
TN
TO
TP
TR
TRAVEL
TT
TV
TW
TZ
UA
UG
UK
US
UY
UZ
VA
VC
VE
VG
VI
VN
VU
WF
WS
XN--0ZWM56D
XN--11B5BS3A9AJ6G
XN--3E0B707E
XN--45BRJ9C
XN--80AKHBYKNJ4F
XN--90A3AC
XN--9T4B11YI5A
XN--CLCHC0EA0B2G2A9GCD
XN--DEBA0AD
XN--FIQS8S
XN--FIQZ9S
XN--FPCRJ9C3D
XN--FZC2C9E2C
XN--G6W251D
XN--GECRJ9C
XN--H2BRJ9C
XN--HGBK6AJ7F53BBA
XN--HLCJ6AYA9ESC7A
XN--J6W193G
XN--JXALPDLP
XN--KGBECHTV
XN--KPRW13D
XN--KPRY57D
XN--LGBBAT1AD8J
XN--MGBAAM7A8H
XN--MGBAYH7GPA
XN--MGBBH1A71E
XN--MGBC0A9AZCG
XN--MGBERP4A5D4AR
XN--O3CW4H
XN--OGBPF8FL
XN--P1AI
XN--PGBS0DH
XN--S9BRJ9C
XN--WGBH1C
XN--WGBL6A
XN--XKC2AL3HYE2A
XN--XKC2DL3A5EE0H
XN--YFRO4I67O
XN--YGBI2AMMX
XN--ZCKZAH
XXX
YE
YT
ZA
ZM
ZW

Details of DNS Jargon(Syntax)
www.example.com is a standard domain name and following list is showing the aspects and rules of a domain name. I have picked rules and create this list with wiki and referenced RFCs
  • www, example and com are labels [wiki]
  • each label can be maximum 63 characters long [RFC1035, page 10] [RFC1123, page 13]
  • dots(.) are seperators [wiki]
  • com is top level domain (TLD)
  • www and example are subdomains  [wiki]
  • a domain can have maximum 127 subdomains [wiki]
  • domain name has maximum 255 characters [RFC1035, page 9][RFC1123, page 13]
  • the hierarchy of domains descends from right to left [wiki
  • LDH Rule: labels must contain only Letters, Digits and Hypen (not start or end with hypen) [RFC3696, page 3]  
  • top level domain names not be all numeric [RFC3696, page 3
  • domain names are not case sensitive [RFC3696, page 3]  

Final Touch, Regular Expression Pattern for Domain Name Syntax
The initial motivation of searching all these information is creating a unique pattern to validate domain names whilst user interactions or in any side of applications. However, without reducing the complexity of 312 tlds and their combinations, it is almost impossible to write a regex pattern to meet these requirements. But pattern creation tradeoff must be well analyzed and shouldn' t be copy-pasted from any resource on the internet. It must be flexible enough and meet the requirements of both above rules and you. I prefer this pattern:

Console
true
true
true
true
true
false
false

Comments

Popular posts from this blog

SoapUI 4.5.0 Project XML File Encoding Problem

COMRESET failed (errno=-32)

SoapUI - Dynamic Properties - Getting Current Time in DateTime Format