5

My server have one IP and several domains hosted.

One and same IP appear in named.conf and several zone files.

When the IP address of the server changes, I need manually to change all those IP's.

Is there a way to do something like:

in named.conf:

#define $IP 123.123.123.123

zone file:

        MX 10     mail
        A         $IP
www     A         $IP
mail    A         $IP
*       CNAME     www

any help will be appretiated

Nick
  • 786
  • 2
  • 12
  • 37

1 Answers1

4

Well, if the IP Address is always the same for @, www and mail, you can add an $INCLUDE directive to your zone files (see here).

Ideally, create a commons.db zone file with your common zone descriptions:

@        IN    A    1.2.3.4
wwww     IN    A    1.2.3.4
mail     IN    A    1.2.3.4
*        IN    CNAME    www

and then in your domain zone files simply do:

@        IN    MX 10    mail
$INCLUDE  commons.db
Jacob Evans
  • 7,636
  • 3
  • 25
  • 55
Daniele Santi
  • 2,479
  • 1
  • 25
  • 22
  • not a bad idea, but what if my zones using 4-5 IP's in mixed way. can I somehow include just the IP ? – Nick Apr 27 '13 at 15:01
  • @Nick do you mean having different IPs for @, www and mail records? Or some domains on 1 IP, some on differnt IP and so on? Or some domains have IP 1.2.3.4 for www and 5.6.7.8 for mail, while some other the other way around (5.6.7.8 for www and 1.2.3.4 for mail0? – Daniele Santi Apr 27 '13 at 15:18
  • to be exact, the server have 4 IP's one is for web, another is for static content, another for different kind of web. each zone is different, but have one or more of these IP's. – Nick Apr 27 '13 at 15:46
  • 1
    @Nick then I fear you're out of luck. How many zones are we talking about? I think that a simple `sed 's/OLD.IP.ADD.RESS/NEW.IP.ADD.RESS/'` every now and then (how often do these IP change?) won't be too much of a hassle. – Daniele Santi Apr 27 '13 at 16:31
  • i'm doing it similar to this – Nick Apr 28 '13 at 16:46
  • @MrShunz link broken. – Jacob Evans Apr 19 '17 at 16:50
  • @JacobEvans link still works fine from here (http://www.zytrax.com/books/dns/ch8/include.html) – Daniele Santi May 23 '17 at 16:23
  • I fixed it for you – Jacob Evans May 23 '17 at 16:30