Saturday, January 29, 2011

Add a subdomain to NAMED config file.

Hi,

I have a domain configuration file called example.com.conf

I want to add the following subdomain to it: members.example.conf and add it's own MX records (it's running a seperate mail system).

How do I specify the MX records for a subdomain?

  • Same way you specify A records. Keep in mind MX records MUST be FQDNs, not IP addresses.

     $origin example.com
     subdomain      300 IN A 127.0.0.1
     mail.subdomain 300 IN A 127.0.0.1
     subdomain      300 IN MX 0 mail.subdomain.example.com.
    

    Edit:

    The first column in your file is currently blank because it's inherited from the record above it (likely your SOA record)

    This should be just as valid as what I posted above:

     $origin example.com
     subdomain      300 IN A 127.0.0.1
                    300 IN MX 0 mail.subdomain.example.com.
     $origin subdomain.example.com
     mail           300 IN A 127.0.0.1
    

    Basically, there's more than one way to skin a cat. However, $origins can make things unnecessarily confusing, so sometimes it's better to be verbose.

    Samuurai : Ah ok, so right now, to specify the MX records for the example.com domain, the first column is blank, but to specify the MX record for the subdomain, I just enter the name of it there..?
    brent : See my edit in the above post
    Samuurai : Thanks a lot for your help. We don't have an origin variable and our SOA looks like this:@ IN SOA ns1.example.com networks.example.com. ( serial, refresh etc...) It might be that it's getting it from the definition in named.conf.include ?
    Alnitak : BIND automatically sets $ORIGIN to whatever the domain name is set to in that zone's configuration section in `named.conf`.
    From brent
  • First, a name like this is not a subdomain, in strict terminology. It is just another name inside the current domain. If it were a subdomain, it would have NS records in the parent domain and and SOA record in the subdomain's file.

    If you want to make another name inside your file, all you have to do is simply add it. As others have said, you need to add the MX records for it, using names on the right-hand side. Then add A records for those names. Inside domain "example.com" you could use:

    newname          MX 100 mailhost.newname
    mailhost.newname A 1.2.3.4
    

    The TTL can be left to default (as I did here).

    @ in the first column means "whatever this zone's apex name is" so it will be taken from the configuration file. @ is a lazy way to write the domain's apex, but only that. For example, you cannot use foo.@ to mean foo.example.com -- it won't work.

    Samuurai : Thanks a lot. That clarifies it for me. I wish I could vote you up, but I don't have enough rep!

0 comments:

Post a Comment