0

I have a BIND9 DNS server running on a company network that has a single master zone company.example and everything else is forwarded to the company DNS. I have managed to map server1.company.example and server2.company.example to their respective IP addresses, but I would also like to reach them by simply using their hostnames server1 and server2.

Any ideas on how to achieve this?

I tried using CNAME like shown below without any luck

$ORIGIN company.example.

...

server1            IN    A   4.5.6.7
server2            IN    A   4.5.6.8
server1.           IN    CNAME server1
server2.           IN    CNAME server2
markustp
  • 63
  • 1
  • 9
  • Your question is off topic here as not related to programming, but run `named-checkzone` and it will explain to you the errors you have. You can't have `server1.` appearing in the zonefile for `company.example.` as `server1.` is an absolute name, and it is not in this zone. – Patrick Mevzek May 06 '20 at 14:33
  • Sorry about the networking tag. I removed it now. I didn't have any errors when starting up with this zone but I wouldn't get a IP for the simple hostnames either. As Katie explained I needed to create a zone for each server. – markustp May 07 '20 at 12:10
  • It is not a tag problem, your question is not about programming and this website is about programming questions, see [help] and [tour]. Your question would be more on topic on [sf] for example. " I didn't have any errors when starting up with this zone " I do not believe this to be possible, I am sure `named-checkzone` will complain on your zone. I just tried and it does indeed give errors, like "z1:5: ignoring out-of-zone data (server1)" as expected. You should post real content (not bad obfuscation) and real commands and errors. – Patrick Mevzek May 07 '20 at 14:35

2 Answers2

1

You need a new SOA record as server1 and server2 are not within the company.example. domain. You would also have to append a . to your SOA record:

; Start of Authority
server1.   IN   SOA   ns1.example.com.   support.example.com. (
          XXXXXXXXXX  ; Serial
              XXXXXX  ; Refresh
               XXXXX  ; Retry
             XXXXXXX  ; Expire
              XXXXXX  ; Minimum
);

Disclaimer: I haven't actually tried this record as my nameservers are live :)

Katie
  • 2,594
  • 3
  • 23
  • 31
  • Does that mean I have to create two new zones? One for `server1` and one for `server2`? As far as I can see I can't add multiple SOA records in a single zone. – markustp May 07 '20 at 05:57
  • 1
    Correct, you need one zone file for each domain and they would each be considered different domains from your original one. – Katie May 07 '20 at 11:50
  • 1
    Yay! I am so happy to hear :) – Katie May 07 '20 at 12:04
1

The proper way of getting 'shortnames' to work is by configuring your Search Domains.

This is something that has to be configured on the DHCP Scopes as an option. It is Option 119

Info on the option for ISC DHCP
https://www.rfc-editor.org/rfc/rfc3397

Info on the option for Windows DHCP
https://www.normanbauer.com/2018/04/18/configuring-dhcp-option-119-domain-search-list-on-a-windows-dhcp-server/

And just add your domain in that option.

To check if it is working, On Windows, you can pull ipconfig /all and look for the DNS Suffix Search List

Windows IP Configuration

   Host Name . . . . . . . . . . . . : Desktop33
   Primary Dns Suffix  . . . . . . . :
   Node Type . . . . . . . . . . . . : Hybrid
   IP Routing Enabled. . . . . . . . : No
   WINS Proxy Enabled. . . . . . . . : No
   DNS Suffix Search List. . . . . . : mydomain.ca

On Linux, you can check /etc/resolv.conf and look for 'search' parameter

nameserver 192.168.2.2
options edns0
search mydomain.ca
Community
  • 1
  • 1
madacoda
  • 363
  • 4
  • 11
  • Would I have to configure my Search Domains for every host or only once for the server? I run on Linux, so would this work as my /etc/resolv.conf? `nameserver 127.0.0.1 search company.example` – markustp May 07 '20 at 12:20
  • If your clients are getting IPs from a DHCP server, you can configure that as a DHCP option (search domains) so it gets pushed to your clients automatically. Otherwise if your clients have static IPs, you will have to configure the search domains manually as well. – madacoda May 13 '20 at 15:28