# Solved: BIND: Zone and hostname with the same name



## dolphin (Dec 1, 2013)

Hi!

I use BIND and want this:

The zone is "dep.location.example.com" and a server in this zone has the hostname "node", with the IP address "10.33.44.55".
Then, I have a second zone with the name "node.dep.location.example.com". All e-mail messages to this zone (for example "admin@node.dep.location.example.com") are supposed to be delivered to the host "node.dep.location.example.com".

To get this, I arranged this:

named.conf.local

```
zone "dep.location.example.com" {
    type master;
    file "/etc/bind/dep.location.example.com.db";
};
zone "node.dep.location.example.com" {
    type master;
    file "/etc/bind/node.dep.location.example.com.db";
};
```

dep.location.example.com.db

```
$TTL 3600

@                   IN        SOA     bind.location.example.com.     admin.node.dep.location.example.com.     (
                                      2013111901          ; Tag und Nummer der letzten Aenderung
                                      3600                ; Refresh [1h]
                                      600                 ; Retry   [10m]
                                      86400               ; Expire  [1d]
                                      600 )               ; Negative Cache TTL [1h]

@                   IN        NS      bind.location.example.com.

@                   IN        MX      10 node.dep.location.example.com.

node                IN        A       10.33.44.55
```

node.dep.location.example.com.db

```
$TTL 3600

@                   IN        SOA     bind.location.example.com.     admin.node.dep.location.example.com.     (
                                      2013111901          ; Tag und Nummer der letzten Aenderung
                                      3600                ; Refresh [1h]
                                      600                 ; Retry   [10m]
                                      86400               ; Expire  [1d]
                                      600 )               ; Negative Cache TTL [1h]

@                   IN        NS      bind.location.example.com.

@                   IN        MX      10 node.dep.location.example.com.
```

The problem is that this does not work.

With the configuration above, `dig @bind node.dep.location.example.com mx` successfully delivers the MX record for "node.dep.location.example.com", but a `dig @bind node.dep.location.example.com a` does NOT deliver the A record for the host "node.dep.location.example.com".

When I deactivate the "node.dep.location.example.com" zone, then `dig @bind node.dep.location.example.com a` successfully delivers the A record for the host "node.dep.location.example.com", but there is no MX record anymore.

What can I do to get what I want?

Thanks in advance,

dolphin


----------



## fonz (Dec 1, 2013)

*Re: BIND: Zone and hostname with the same name*

For starters, the file lines in named.conf should refer to the zone files themselves, not their *.db files.

Second, why are you using a separate zone for the node?


----------



## dolphin (Dec 2, 2013)

*Re: BIND: Zone and hostname with the same name*



			
				fonz said:
			
		

> For starters, the file lines in named.conf should refer to the zone files themselves, not their *.db files.



Hm. I use Debian. Is this in BSD Unix different? I thought, DB files *are* zone files.



			
				fonz said:
			
		

> Second, why are you using a separate zone for the node?



I tried to set the MX record into the "deb.location.example.com" file like this:

```
node.dep.location.example.com                   IN        MX      10 node.dep.location.example.com.
```

Perhaps, I should try it again, but last time, it didn't work.


----------



## usdmatt (Dec 2, 2013)

*Re: BIND: Zone and hostname with the same name*

You can't just move the A record for node.dep.location.example.com into node.dep.location.example.com.db?

As you have local zone files for dep.location.example.com and node.dep.location.example.com, I believe the 'more specific' zone file is taking precedence, so it's using node.dep.location.example.com.db as the source for all records in the node.dep.location.example.com zone (and ignoring your node A record in the parent zone file).

Of course, as mentioned above, if there's no specific reason for it, it makes more sense to move all the records into the parent zone file and scrap the 'node' zone completely.


----------



## dolphin (Dec 2, 2013)

*Re: BIND: Zone and hostname with the same name*



			
				usdmatt said:
			
		

> You can't just move the A record for node.dep.location.example.com into node.dep.location.example.com.db?
> 
> As you have local zone files for dep.location.example.com and node.dep.location.example.com, I believe the 'more specific' zone file is taking precedence, so it's using node.dep.location.example.com.db as the source for all records in the node.dep.location.example.com zone (and ignoring your node A record in the parent zone file).



Nice idea. I tried this in node.dep.location.example.com:

```
node.dep.location.example.com                 IN        A       10.33.44.55
```

instead of this (because I don't want "node.node.dep.location.example.com")

```
node                IN        A       10.33.44.55
```

And I tried this (with additional 'dot'):

```
node.dep.location.example.com.                 IN        A       10.33.44.55
```

With both variants, a simple `dig @bind node.dep.location.example.com a` does not deliver a result.

dolphin


----------



## usdmatt (Dec 2, 2013)

*Re: BIND: Zone and hostname with the same name*

node.dep.location.example.com as in your first example would of have been expanded to node.dep.location.example.com.node.dep.location.example.com.. The example with the extra dot is correct. You could of have also used @ as in your other records in that zone file. @ means use whatever the current value of $ORIGIN is. By default, $ORIGIN is the same as the zone name, so the following should be perfectly acceptable:


```
@                   IN        NS      bind.location.example.com.
@                   IN        MX      10 node.dep.location.example.com.
@                   IN        A        10.33.44.55
```

If your MX record is working then there is no reason this A record shouldn't. Splitting a subdomain into its own zone isn't ideal but I do it for one of my domains to make management easier and I've never had any problems with it.

Did you definitely increment the serial number? Also make sure no errors are logged by BIND when you reload the zone file.


----------



## kpa (Dec 2, 2013)

*Re: BIND: Zone and hostname with the same name*



> Did you definitely increment the serial number?



About the serial number, it makes absolutely no difference if it's not incremented unless you have slave servers that need to compare it to the previous serial number. On a single master server with no slaves you can put whatever you want as the serial number, even if you never change it it won't make a difference.


----------



## dolphin (Dec 2, 2013)

*Re: BIND: Zone and hostname with the same name*



			
				usdmatt said:
			
		

> [...]You could of also used @ as in your other records in that zone file. @ means use whatever the current value of $ORIGIN is. By default, $ORIGIN is the same as the zone name, so the following should be perfectly acceptable:
> 
> 
> ```
> ...



Yippee! It works! This is my node.dep.location.example.com.db file now:

```
@                   IN        NS      bind.location.example.com.
@                   IN        MX      10 node.dep.location.example.com.
@                   IN        A       10.33.44.55
```

Thank you!

- dolphin -


----------

