The service often has to create a lot of DNS zones, add or modify records in them. Manually, this is a rather painstaking and complicated process: after all, you need to keep in mind the syntax and not make mistakes in the details. For such things, the most it is to get the job done by the computer
IAdmin is a system created for the automatic generation of Bind configs on a hosting server and represents the iadmin database in the MySQL database and a script that generates configuration files based on the data from the database. To set up Bind, dns_domains, dns_records, dns_subgmail tables are used. The main script written in Perl reads data from the iadmin database and creates configuration files. Zone files are generated in the / var / cache / bind / directory. Other zone files that are not served by iadmin are also stored there. The same system creates a config for the secondary-DNS, which is transferred there. Until the script runs, all changes from the database are NOT materialized.
Data
Dns_domains table
The table consists of the following fields and is the main table for configuring the DNS server:
- id - the sequence number of the record
- domainname - the name of the domain whose zone will be supported by Bind
- www - Do you need a subdomain www (1 - required)
- ftp - Whether ftp subdomain is required (1 is required)
- mail - Are MX records required in the zone (1 is required)
- typemai l - Defines a template for generating MX records ('our' - Postfix will serve, 'gmail' - Google Apps is activated on the domain). If mail = 0, this field is ignored. Further changes are possible.
- secondaryfor - For which DNS servers (IP), our server will be secondary (NULL - master)
- hosted_on - Record A: IP address where the site is hosted with the given domain name
- enable - Whether the zone is active (1 is active). Otherwise, this zone is not generated. It should be noted that if the zone answers enable = 0, it will not throw it out of the bind service, but any settings via the iadmin system will not affect any
- serial - Serial zone. After any changes in this table, or in dns_records, dns_subgmail, you need to increase the value. The structure year_month_day_application - thus it is convenient to see when there were changes in the zone.
- owner - write NS-servers English (1) or standard (0)
For example, in order to add the English-speaking iadmin.vip zone to the service, with gmail and without ftp (hosting 123.123.4.56), you need to write the following line in the table:
id
| domainname
| www
| ftp
| mail
| typemail
| secondaryfor
| hosted_on
| enable
| serial
| owner
|
215
| iadmin.vip
| one
| 0
| one
| gmail
| Null
| 123.123.4.56
| one
| 2010082001
| one
|
')
This entry will allow you to generate a zone file of approximately the following content:
$ TTL 86400
iadmin.vip. IN SOA ns0.english.com. ns1.english.com. (
2010082001; serial
10800; refresh
3600; retry
604800; expire
86400); minimum
IN NS ns0.english.com.
IN NS ns1.english.com.
IN A 123.123.4.56
; IN MX 1 relay.iadmin.vip.
; relay IN A 77.88.99.11
IN MX 1 ASPMX.L.GOOGLE.COM.
IN MX 5 ALT1.ASPMX.L.GOOGLE.COM.
IN MX 5 ALT2.ASPMX.L.GOOGLE.COM.
IN MX 10 ASPMX2.GOOGLEMAMA.COM.
IN MX 10 ASPMX3.GOOGLEMAMA.COM.
IN MX 10 ASPMX4.GOOGLEMAMA.COM.
IN MX 10 ASPMX5.GOOGLEMAMA.COM.
IN TXT "v = spf1 include: aspmx.googlemail.com ~ all"
mail IN CNAME ghs.google.com.
calendar IN CNAME ghs.google.com.
start IN CNAME ghs.google.com.
docs IN CNAME ghs.google.com.
_xmpp-server._tcp.iadmin.vip. IN SRV 5 0 5269 xmpp-server.l.google.com.
_xmpp-server._tcp.iadmin.vip. IN SRV 20 0 5269 xmpp-server1.l.google.com.
_xmpp-server._tcp.iadmin.vip. IN SRV 20 0 5269 xmpp-server2.l.google.com.
_xmpp-server._tcp.iadmin.vip. IN SRV 20 0 5269 xmpp-server3.l.google.com.
_xmpp-server._tcp.iadmin.vip. IN SRV 20 0 5269 xmpp-server4.l.google.com.
_jabber._tcp.iadmin.vip. IN SRV 5 0 5269 xmpp-server.l.google.com.
_jabber._tcp.iadmin.vip. IN SRV 20 0 5269 xmpp-server1.l.google.com.
_jabber._tcp.iadmin.vip. IN SRV 20 0 5269 xmpp-server2.l.google.com.
_jabber._tcp.iadmin.vip. IN SRV 20 0 5269 xmpp-server3.l.google.com.
_jabber._tcp.iadmin.vip. IN SRV 20 0 5269 xmpp-server4.l.google.com.
www IN CNAME iadmin.vip.
ww IN CNAME iadmin.vip.
wwww IN CNAME iadmin.vip.
Dns_records table
The table is used to add arbitrary records to the zone and consists of the following fields:
- domainname - The name of the domain zone to which the entry is being added.
- rectype - what type of record is added (A, CNAME, MX, NS, etc.)
- data - The data to be added.
- enabled - Takes the value 1 - this entry will be added and 0 - the entry is deactivated
- id - the sequence number of the record (automatically)
For example, in order to add an entry in which the iadmin.vip domain zone will have third-party mail servers (not our mail and not gmail), but, say, relay.dc.ukrtel.net, you need to write the following line:
domainname
| rectype
| data
| enabled
| id
|
.iadmin.vip
| MX
| 10 relay.dc.ukrtel.net.
| one
| 680
|
We must remember that after this we need to increase the serial in the dns_domains domain zone.
Dns_subgmail table
The table serves to simplify the writing of zones in which there are several subdomains using Google Apps and consists of the following fields:
- id - the sequence number of the record (automatically)
- domainname - The name of the domain zone in which the subdomain is used
- subdomain - A subdomain for which Google Apps is also required.
- enable - Takes the value 1 - this subdomain will be added and 0 - the record is deactivated
For example, in order to add an entry in which the iadmin.vip domain zone will have the sync subdomain with the Google Apps service, you need to write the following line:
id | domainname | subdomain | enable |
56 | iadmin.vip | sync | one |
Then the domain zone will look like this:
$ TTL 86400
iadmin.vip. IN SOA ns0.english.com. ns1.english.com. (
2010082001; serial
10800; refresh
3600; retry
604800; expire
86400); minimum
IN NS ns0.english.com.
IN NS ns1.english.com.
IN A 77.88.99.11
; IN MX 1 relay.iadmin.vip.
; relay IN A 123.123.4.56
IN MX 1 ASPMX.L.GOOGLE.COM.
IN MX 5 ALT1.ASPMX.L.GOOGLE.COM.
IN MX 5 ALT2.ASPMX.L.GOOGLE.COM.
IN MX 10 ASPMX2.GOOGLEMAMA.COM.
IN MX 10 ASPMX3.GOOGLEMAMA.COM.
IN MX 10 ASPMX4.GOOGLEMAMA.COM.
IN MX 10 ASPMX5.GOOGLEMAMA.COM.
IN TXT "v = spf1 include: aspmx.googlemail.com ~ all"
mail IN CNAME ghs.google.com.
calendar IN CNAME ghs.google.com.
start IN CNAME ghs.google.com.
docs IN CNAME ghs.google.com.
_xmpp-server._tcp.iadmin.vip. IN SRV 5 0 5269 xmpp-server.l.google.com.
_xmpp-server._tcp.iadmin.vip. IN SRV 20 0 5269 xmpp-server1.l.google.com.
_xmpp-server._tcp.iadmin.vip. IN SRV 20 0 5269 xmpp-server2.l.google.com.
_xmpp-server._tcp.iadmin.vip. IN SRV 20 0 5269 xmpp-server3.l.google.com.
_xmpp-server._tcp.iadmin.vip. IN SRV 20 0 5269 xmpp-server4.l.google.com.
_jabber._tcp.iadmin.vip. IN SRV 5 0 5269 xmpp-server.l.google.com.
_jabber._tcp.iadmin.vip. IN SRV 20 0 5269 xmpp-server1.l.google.com.
_jabber._tcp.iadmin.vip. IN SRV 20 0 5269 xmpp-server2.l.google.com.
_jabber._tcp.iadmin.vip. IN SRV 20 0 5269 xmpp-server3.l.google.com.
_jabber._tcp.iadmin.vip. IN SRV 20 0 5269 xmpp-server4.l.google.com.
www IN CNAME iadmin.vip.
ww IN CNAME iadmin.vip.
wwww IN CNAME iadmin.vip.
sync IN MX 1 ASPMX.L.GOOGLE.COM.
sync IN MX 5 ALT1.ASPMX.L.GOOGLE.COM.
sync IN MX 5 ALT2.ASPMX.L.GOOGLE.COM.
sync IN MX 10 ASPMX2.GOOGLEMAIL.COM.
sync IN MX 10 ASPMX3.GOOGLEMAIL.COM.
sync IN MX 10 ASPMX4.GOOGLEMAIL.COM.
sync IN MX 10 ASPMX5.GOOGLEMAIL.COM.
sync IN TXT "v = spf1 include: aspmx.googlemail.com ~ all"
mail.sync IN CNAME ghs.google.com.
calendar.sync IN CNAME ghs.google.com.
start.sync IN CNAME ghs.google.com.
docs.sync IN CNAME ghs.google.com.
_xmpp-server._tcp.sync.iadmin.vip. IN SRV 5 0 5269 xmpp-server.l.google.com.
_xmpp-server._tcp.sync.iadmin.vip. IN SRV 20 0 5269 xmpp-server1.l.google.com.
_xmpp-server._tcp.sync.iadmin.vip. IN SRV 20 0 5269 xmpp-server2.l.google.com.
_xmpp-server._tcp.sync.iadmin.vip. IN SRV 20 0 5269 xmpp-server3.l.google.com.
_xmpp-server._tcp.sync.iadmin.vip. IN SRV 20 0 5269 xmpp-server4.l.google.com.
_jabber._tcp.sync.iadmin.vip. IN SRV 5 0 5269 xmpp-server.l.google.com.
_jabber._tcp.sync.iadmin.vip. IN SRV 20 0 5269 xmpp-server1.l.google.com.
_jabber._tcp.sync.iadmin.vip. IN SRV 20 0 5269 xmpp-server2.l.google.com.
_jabber._tcp.sync.iadmin.vip. IN SRV 20 0 5269 xmpp-server3.l.google.com.
_jabber._tcp.sync.iadmin.vip. IN SRV 20 0 5269 xmpp-server4.l.google.com.
Also, we must remember that after this we need to change the serial in the dns_domains domain zone.
Script
The script, based on the data stored in iadmin, writes configuration files for bind (Now it is on perl, it will most likely be rewritten in python later).
Sources posted on
github