ドメイン名にアンダースコアが使えない理由をRFCに求める
月曜日, 6月 30th, 2008みなさまこんにちは、加賀田です。そろそろ夏休みの話題が出るようになりました。みなさまのご予定はいかがでしょう?私も何か、考えなあかんなあ。
さて、本日は前回の続きで、ドメイン名にアンダースコアが使えないらしいという話をRFCから裏付けてみるというお話です。調べてみると、これが奥深い奥深い…。
今回の話題はこれまで頻繁に話題にされているらしく、どさにっきさんの記事はじめ各所にまとめや解説が見られます。が、最終的に問題になるのは「ドメイン名の仕様をどのRFCに求めるか?」ということ。本件についてずばり答えてくれるようなRFCはなくて、関連するRFCに記述が分散しているようです。どさにっきさんを参考にして関連しそうなRFCを話題別にまとめると、おおむね以下のような感じです。
- インターネットホスト(RFC952, 1123)
- DNS(RFC1034, 1035, 2181)
- URI(RFC1630, 1738, 2396, 3986)
- HTTP(RFC1945, 2616)
- SMTP(RFC2821)
- メールアドレス(RFC2822)
- SRVレコード(RFC2782)
- DKIM(RFC4781:昨年出たばっかり!)
そしてそれぞれの仕様で、アンダースコアが使えたり使えなかったりする、と。ずいぶんややこしいですね。
ドメイン名にアンダースコアが「使えない」論拠としてRFCが引かれている例としては、例えばWikipediaの「ホスト名」の項目ではRFC952が引かれています。RFC952中の該当の記述は以下のとおり。
A “name” (Net, Host, Gateway, or Domain name) is a text string up to 24 characters drawn from the alphabet (A-Z), digits (0-9), minus sign (-), and period (.). Note that periods are only allowed when they serve to delimit components of “domain style names”. (See RFC-921, “Domain Name System Implementation Schedule”, for background). No blank or space characters are permitted as part of a name. No distinction is made between upper and lower case. The first character must be an alpha character. The last character must not be a minus sign or period. A host which serves as a GATEWAY should have “-GATEWAY” or “-GW” as part of its name. Hosts which do not serve as Internet gateways should not use “-GATEWAY” and “-GW” as part of their names. A host which is a TAC should have “-TAC” as the last part of its host name, if it is a DoD host. Single character names or nicknames are not allowed.
ちなみにこの記述のうち、1文字目はアルファベットでなければならないという制限はRFC1123で英数字に緩和されています。
One aspect of host name syntax is hereby changed: the restriction on the first character is relaxed to allow either a letter or a digit.
また、Yahoo!カテゴリへのサイト登録ではRFC2396に照らして、ドメインにアンダースコアを含むURLを登録することはできないようになっているようです。RFC2396は先述のRFC1123を参照しているので、同様にアンダースコアが使えないことになりますね。
Hostnames take the form described in Section 3 of [RFC1034] and Section 2.1 of [RFC1123]
しかし現在では、RFC2396はRFC3986によって破棄されています。
This document obsoletes [RFC2396], which merged “Uniform Resource Locators” [RFC1738] and “Relative Uniform Resource Locators” [RFC1808] in order to define a single, generic syntax for all URIs.
そしてそのRFC3986では、本来使用できない文字をパーセントエンコーディングを介して使用できるようになりました。これに従えば、アンダースコアの仕様も事実上許容されることになります。
A percent-encoding mechanism is used to represent a data octet in a component when that octet’s corresponding character is outside the allowed set or is being used as a delimiter of, or within, the component.
なのでYahoo!カテゴリの対応には何らかの変更が必要かもしれませんね。







