From: Chris Davies on
On Mar 16, 7:55 am, susi <susmit...(a)gmail.com> wrote:
> How can I get the details about a subdomain?

David Schwartz <davids(a)webmaster.com> wrote:
> Cut off everything before and including the first '.'

> Subdomain: www.google.com
> Domain: google.com


Subdomain: www.bbc.co.uk
Domain: bbc.co.uk

Subdomain: www.leedsth.nhs.uk
Domain: nhs.uk

It's really not that easy.
Chris
From: Lew Pitcher on
On Mar 17, 1:26 am, Lew Pitcher <lpitc...(a)teksavvy.com> wrote:
> On Mar 16, 10:55 am, susi <susmit...(a)gmail.com> wrote:
>
> > How can I get the details about a subdomain?
> > ie mainly need to get the domain name.
>
> Your question is not very clear. What do you mean by "details about a
> subdomain"? What details?
>
> "mainly need to get the domain name" - subdomains are one or more
> qualifiers added on to a domain name. A domain name is one or more
> qualifiers added on to a TLDn. How many qualifiers in your domain
> names? If you don't know that, then you can't distinguish subdomains
> from domains.

The only generic method I can think of is to use network tools like
host(1) and whois(1) to help determine the point where your subdomain
turns into a domain, and your domain turns into just a series of high-
level qualifiers.

With
www.harrods.co.uk
host(1) returns a valid IP address, and whois(1) returns "error";
www.harrods.co.uk is a subdomain of harrods.co.uk

With
harrods.co.uk
host(1) returns a valid IP address, and whois(1) returns valid domain
info; harrods.co.uk is the domain name

With
co.uk
host(1) returns no valid IP address, and whois(1) returns "error";
co.uk is a high-level qualifier, and not a domain name


The tools you use to perform this iterative test will depend on the
language you write your test in. Use string-handling tools to strip
off qualifiers from the test domain name; remove from the left side of
the string, any characters up to and including the first period.

Then test with host(1): a valid IP address means that you are still
within the domain
Then test with whois(1): an error indicates that you are still within
the subdomain

When host(1) returns a valid IP address /and/ whois(1) returns a
successful domain lookup, then you have your primary domain for the
initial subdomain.
From: David Schwartz on
On Mar 17, 2:12 am, Chris Davies <chris-use...(a)roaima.co.uk> wrote:

> Subdomain:www.bbc.co.uk
> Domain: bbc.co.uk
>
> Subdomain:www.leedsth.nhs.uk
> Domain: nhs.uk

Sure, but bbc.co.uk is also a subdomain of the co.uk domain. And
www.leedsth.nhs.uk is also a subdomain of the leedsth.nhs.uk domain.

> It's really not that easy.

It is that easy. Just cut off the part before and including the first
dot and you have the domain that is a subdomain off. That domain may
in turn by a subdomain of another domain. Arguably, every domain is a
subdomain of the '.' domain, the DNS root.

DS
From: pk on
David Schwartz wrote:

> On Mar 17, 2:12 am, Chris Davies <chris-use...(a)roaima.co.uk> wrote:
>
>> Subdomain:www.bbc.co.uk
>> Domain: bbc.co.uk
>>
>> Subdomain:www.leedsth.nhs.uk
>> Domain: nhs.uk
>
> Sure, but bbc.co.uk is also a subdomain of the co.uk domain. And
> www.leedsth.nhs.uk is also a subdomain of the leedsth.nhs.uk domain.
>
>> It's really not that easy.
>
> It is that easy. Just cut off the part before and including the first
> dot and you have the domain that is a subdomain off. That domain may
> in turn by a subdomain of another domain. Arguably, every domain is a
> subdomain of the '.' domain, the DNS root.

I think his point was that given a name like, say

www.foo.bar.example.com

it's not apparent where the domain/subdomain boundaries are from the name
itself (though we'd probably need a more precise definition of "domain" here
- I will loosely assume the meaning that most people seem to give to the
word). That domain name may be contained *directly* in either one of the
foo.bar.example.com, bar.example.com, example.com and com (and perhaps root)
domains. The keyword here is "directly".

That is, assuming it is contained in "example.com", no domain names
"bar.example.com" and "foo.bar.example.com" exist at all.

In terms of DNS zone file, you could have this:

$ORIGIN example.com.
www.foo.bar IN A 1.2.3.4

which would make that name contained in the "example.com" domain, but not in
"foo.bar.example.com" neither in "bar.example.com" (those wouldn't even
exist).
From: David Schwartz on
On Mar 18, 12:17 pm, pk <p...(a)pk.invalid> wrote:

> > It is that easy. Just cut off the part before and including the first
> > dot and you have the domain that is a subdomain off. That domain may
> > in turn by a subdomain of another domain. Arguably, every domain is a
> > subdomain of the '.' domain, the DNS root.

> I think his point was that given a name like, say

> www.foo.bar.example.com

> it's not apparent where the domain/subdomain boundaries are from the name
> itself (though we'd probably need a more precise definition of "domain" here
> - I will loosely assume the meaning that most people seem to give to the
> word).

It is apparent. The name "www.foo.bar.example.com" denotes the host
"www" in the "foo.bar.example.com" domain, which is a sub-domain of
the "bar.example.com" domain, itself a sub-domain of the "example.com"
domain.

> That domain name may be contained *directly* in either one of the
> foo.bar.example.com, bar.example.com, example.com and com (and perhaps root)
> domains. The keyword here is "directly".

Sure, it may. But how the domain is tracked and resolved through DNS
has nothing to do with what the domain *is*.

> That is, assuming it is contained in "example.com", no domain names
> "bar.example.com" and "foo.bar.example.com" exist at all.

You mean they don't exist in the DNS naming system. They still exist.

> In terms of DNS zone file, you could have this:
>
> $ORIGIN example.com.www.foo.bar IN  A  1.2.3.4
>
> which would make that name contained in the "example.com" domain, but not in
> "foo.bar.example.com" neither in "bar.example.com" (those wouldn't even
> exist).

They wouldn't exist in the DNS system. But this question, as far as I
can tell, doesn't have anything to do with the DNS name resolution
system but about the naming scheme itself. How you name things, and
you resolve those names to addresses or records, are two logically
distinct issues.

If the OP meant the question to be understood the way you seem to
think it should be understood, then the OP has confused these two
issues.

DS