I have done some reading on proper Hostname syntax and can't figure out what is a really proper Hostname/URL syntax
Can you please tell me if the following URLs are syntactically correct?
1.2.3.4.5.6.7/something
10.123.143.13333/something
1.2.3.4.5.6.7.com/something
some.host.name.com.org/something
Those are just some examples that i couldn't figure out.
Are those URLs correct?
These are not URLs, as they are missing a scheme.
Assuming that you mean HTTP URLs, they would be:
http://1.2.3.4.5.6.7/something
http://10.123.143.13333/something
http://1.2.3.4.5.6.7.com/something
http://some.host.name.com.org/something
RFC 3986 defines the syntax of the host subcomponent for all URIs (and RFC 2616 for HTTP(S) URIs follows that).
The host names of your example URIs would be:
1.2.3.4.5.6.7
10.123.143.13333
1.2.3.4.5.6.7.com
some.host.name.com.org
Valid host names follow the syntax defined (in the section linked above) by IP-literal
, IPv4address
, or reg-name
:
Check if IP-literal
:
As an IP-literal
requires enclosing square brackets ([
…]
), none are IP-literal
host names.
Check if IPv4address
:
As an IPv4address
must contain exactly three .
characters, 1.2.3.4.5.6.7
, 1.2.3.4.5.6.7.com
, and some.host.name.com.org
can’t be IPv4address
host names.
While 10.123.143.13333
has three .
, "13333" is not a valid dec-octet
, so it’s not an IPv4address
.
Check if reg-name
:
All of your examples are valid reg-name
host names, as 0-9
, a-z
, and .
are allowed characters.
Note that this does not mean that these are valid domain names in the DNS. RFC 3986 "does not mandate a particular registered name lookup technology".