Testing makezone Running makezone is simple. Here is a test run: ./makezone add=zone name=example.com template=standard This creates the /var/named/example.com.zone zone file for example.com using the standard zone template. The contents of this zone file look like the following: ; ; This zone file is generated automatically by makezone script ; If you edit this file manually, the changes will be lost ; if you regenerate the zone again using makezone ; $TTL 86400 $ORIGIN example.com. @ 1D IN SOA @ root ( 01 ; serial 3H ; refresh 15M ; retry 1W ; expiry 1D ) ; minimum 1D IN NS 192.168.0.11 1D IN NS 192.168.1.254 1D IN MX 5 192.168.0.100 1D IN MX 10 192.168.0.101 ns 1D IN A 192.168.0.11 www 1D IN A 192.168.0.12 www IN CNAME apache.example.com. ftp 1D IN A 192.168.0.12 the /etc/named.conf has the following lines appended: // // Master zone configuration for example.com // zone “example.com” IN { type master; file “example.com.zone”; allow-update { none; }; }; 656 Part IV: Using PHP for Sysadmin Tasks 23 549669 ch18.qxd 4/4/03 9:27 AM Page 656 Now, if the BIND server is restarted using the /etc/rc.d/init.d/named restart command, it loads the new zone. On some systems the named control script will be located in a different directory. You can test the new zone using the dig command. For example: dig www.example.com A outputs something like the following: ; <<>> DiG 9.2.1 <<>> www.example.com A ;; global options: printcmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 50838 ;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 3, ADDITIONAL: 0 ;; QUESTION SECTION: ;www.example.com. IN A ;; ANSWER SECTION: www.example.com. 26922 IN A 192.168.0.12 ;; AUTHORITY SECTION: example.com. 86400 IN NS ns.example.com. ;; Query time: 3469 msec ;; SERVER: 192.168.0.11#53(192.168.0.11) ;; WHEN: Sat Dec 14 03:03:58 2002 ;; MSG SIZE rcvd: 127 Similarly, you can query about other records, as shown here: The following will show mail exchanger (MX) records: dig example.com MX Chapter 18: BIND Domain Manager 657 23 549669 ch18.qxd 4/4/03 9:27 AM Page 657 The following will show name server (NS) records: dig example.com NS Summary In this chapter, you learned how to develop a command-line PHP script that helps you manage DNS configuration on your Linux system. Such scripts can take the tedium out of administering the several files that need updating when you add a domain. Scripts such as this also maintain the integrity of the configuration by helping omit typos and other mistakes. 658 Part IV: Using PHP for Sysadmin Tasks 23 549669 ch18.qxd 4/4/03 9:27 AM Page 658 Internet Applications CHAPTER 19 Web Forms Manager CHAPTER 20 Web Site Tools Part V 24 549669 PP05.qxd 4/4/03 9:27 AM Page 659 24 549669 PP05.qxd 4/4/03 9:27 AM Page 660 . “example.com” IN { type master; file “example.com.zone”; allow-update { none; }; }; 656 Part IV: Using PHP for Sysadmin Tasks 23 549669 ch18.qxd 4/4/03 9:27 AM Page 656 Now, if the BIND server is restarted. records: dig example.com NS Summary In this chapter, you learned how to develop a command-line PHP script that helps you manage DNS configuration on your Linux system. Such scripts can take the tedium. the integrity of the configuration by helping omit typos and other mistakes. 658 Part IV: Using PHP for Sysadmin Tasks 23 549669 ch18.qxd 4/4/03 9:27 AM Page 658 Internet Applications CHAPTER