This tutorial will show you how to configure a DNS service that is easy to maintain, easy to configure, and that is generally more secure than the classic BIND service. This article assumes that you are running a VPS with FreeBSD installed.<\/p>\n
To begin, open your terminal and install this package:<\/p>\n
<ceph>[~]# pkg install djbdns \r\nUpdating FreeBSD repository catalogue...\r\nFreeBSD repository is up-to-date.\r\nAll repositories are up-to-date.\r\nThe following 3 packages will be affected (of 0 checked):\r\n\r\nNew packages to be INSTALLED:\r\ndjbdns: 1.05_20,1\r\nucspi-tcp: 0.88_2\r\ndaemontools: 0.76_17\r\n\r\nThe process will require 1 MB more space.\r\n251 KB to be downloaded.\r\n\r\nProceed with this action? [y\/N]: y\r\nFetching djbdns-1.05_20,1.txz: 100% 139 KB 142.4k\/s 00:01 \r\nFetching ucspi-tcp-0.88_2.txz: 100% 62 KB 63.1k\/s 00:01 \r\nFetching daemontools-0.76_17.txz: 100% 51 KB 51.7k\/s 00:01 \r\nChecking integrity... done (0 conflicting)\r\n[1\/3] Installing ucspi-tcp-0.88_2...\r\n[1\/3] Extracting ucspi-tcp-0.88_2: 100%\r\n[2\/3] Installing daemontools-0.76_17...\r\n[2\/3] Extracting daemontools-0.76_17: 100%\r\n[3\/3] Installing djbdns-1.05_20,1...\r\n[3\/3] Extracting djbdns-1.05_20,1: 100%\r\n<\/code><\/pre>\nInstallation will automatically install additional packages (daemontools<\/code>\u00a0and\u00a0ucspi-tcp<\/code>).<\/p>\nCreate two users,\u00a0gtinydns<\/code>\u00a0and\u00a0gdnslog<\/code>. Start with the first user:<\/p>\n<ceph>[~]# adduser \r\nUsername: gtinydns\r\nFull name: gtinydns\r\nUid (Leave empty for default): \r\nLogin group [gtinydns]: \r\nLogin group is gtinydns. Invite gtinydns into other groups? []: \r\nLogin class [default]: \r\nShell (sh csh tcsh zsh rzsh nologin) [sh]: nologin\r\nHome directory [\/home\/gtinydns]: \r\nHome directory permissions (Leave empty for default): \r\nUse password-based authentication? [yes]: \r\nUse an empty password? (yes\/no) [no]: \r\nUse a random password? (yes\/no) [no]: yes\r\nLock out the account after creation? [no]: \r\nUsername : gtinydns\r\nPassword : <random>\r\nFull Name : gtinydns\r\nUid : 1002\r\nClass : \r\nGroups : gtinydns \r\nHome : \/home\/gtinydns\r\nHome Mode : \r\nShell : \/usr\/sbin\/nologin\r\nLocked : no\r\nOK? (yes\/no): yes\r\nadduser: INFO: Successfully added (gtinydns) to the user database.\r\nadduser: INFO: Password for (gtinydns) is: rTsada2131sa1Mg\r\nAdd another user? (yes\/no): no\r\nGoodbye!\r\n<\/code><\/pre>\nNow, add the second user:<\/p>\n
<ceph>[~]# adduser\r\nUsername: gdnslog\r\nFull name: gdnslog\r\nUid (Leave empty for default): \r\nLogin group [gdnslog]: \r\nLogin group is gdnslog. Invite gdnslog into other groups? []: \r\nLogin class [default]: \r\nShell (sh csh tcsh zsh rzsh nologin) [sh]: nologin\r\nHome directory [\/home\/gdnslog]: \r\nHome directory permissions (Leave empty for default): \r\nUse password-based authentication? [yes]: \r\nUse an empty password? (yes\/no) [no]: \r\nUse a random password? (yes\/no) [no]: yes\r\nLock out the account after creation? [no]: \r\nUsername : gdnslog\r\nPassword : <random>\r\nFull Name : gdnslog\r\nUid : 1003\r\nClass : \r\nGroups : gdnslog \r\nHome : \/home\/gdnslog\r\nHome Mode : \r\nShell : \/usr\/sbin\/nologin\r\nLocked : no\r\nOK? (yes\/no): yes\r\nadduser: INFO: Successfully added (gdnslog) to the user database.\r\nadduser: INFO: Password for (gdnslog) is: jWsdad33aasdaFa0\r\nAdd another user? (yes\/no): no\r\nGoodbye!\r\n<\/code><\/pre>\nRun the following command. Replace the IP address with the address of your AKLWEB Host server.<\/p>\n
<ceph>[~]# tinydns-conf gtinydns gdnslog \/usr\/local\/etc\/tinydns 108.61.100.100\r\n<\/code><\/pre>\nThis command will create directories, files, and other sub directories in\u00a0\/usr\/local\/etc\/tinydns<\/code>. It will also put the IP address of the VPS in\u00a0\/usr\/local\/etc\/tinydns\/env\/IP<\/code>.<\/p>\nCreate the directory\u00a0\/service<\/code>.<\/p>\n<ceph>[~]# mkdir \/service\r\n<\/code><\/pre>\nEdit your\u00a0\/etc\/rc.conf<\/code>\u00a0file:<\/p>\n<ceph>[~]# ee \/etc\/rc.conf\r\n<\/code><\/pre>\n… and and these lines:<\/p>\n
svscan_enable=\"YES\"\r\nsvscan_servicedir=\"\/service\"\r\n<\/code><\/pre>\nSave the configuration and start the\u00a0svscan<\/code>\u00a0service:<\/p>\n<ceph>[~]# \/usr\/local\/etc\/rc.d\/svscan start\r\nStarting svscan.\r\n<\/code><\/pre>\nNext, go to this directory:<\/p>\n
<ceph>[~]# cd \/usr\/local\/etc\/tinydns\/root\r\n<\/code><\/pre>\nEdit the\u00a0data<\/code>\u00a0file:<\/p>\n <ceph>[root]# ee data\r\n<\/code><\/pre>\n… and add some DNS data:<\/p>\n
# domain1.com\r\nZdomain1.com:dns1.domain1.com.:ns.domain1.com.:2013101203:604800:86400:2419200:604800:3600\r\n&domain1.com::dns1.domain1.com.:3600\r\n&domain1.com::dns2.domain1.com.:3600\r\n\r\n# MX\r\n@domain1.com::mail1.domain1.com.:10:3600\r\n@domain1.com::mail2.domain1.com.:30:3600\r\n\r\n# IP's (A records)\r\n=dns1.domain1.com:108.61.210.99:3600\r\n=dns2.domain1.com:89.201.163.42:3600\r\n=mail1.domain1.com:89.201.163.42:3600\r\n=mail2.domain1.com:85.114.41.8:3600\r\n=www.domain1.com:108.61.178.194:3600\r\n=test1.domain1.com:193.198.184.100:3600\r\n=test2.domain1.com:108.61.178.215:3600\r\n\r\n# Aliases\r\n+domain1.com:108.61.178.194:3600\r\n+smtp.domain1.com:89.201.163.42:3600\r\n+imap.domain1.com:89.201.163.42:3600\r\n<\/code><\/pre>\nSave the file and exit.<\/p>\n
Run\u00a0ls<\/code>:<\/p>\n<ceph>[root]# ls\r\nMakefile add-alias add-childns add-host add-mx add-ns data\r\n<\/code><\/pre>\nConvert your text data to the database format:<\/p>\n
<ceph>[root]# make\r\n\/usr\/local\/bin\/tinydns-data\r\n<\/code><\/pre>\nRun\u00a0ls<\/code>\u00a0again:<\/p>\n<ceph>[root]# ls\r\nMakefile add-alias add-childns add-host add-mx add-ns data data.cdb\r\n<\/code><\/pre>\nNotice the\u00a0data.cdb<\/code>\u00a0file. You have created it with the\u00a0make<\/code>\u00a0command.<\/p>\nAnd one more thing, create a symbolic link:<\/p>\n
<ceph>[root]# ln -s \/usr\/local\/etc\/tinydns \/service\r\n<\/code><\/pre>\nNow test your new DNS server. Replace\u00a0108.61.178.110<\/code>\u00a0with IP address of your server.<\/p>\n<ceph>[root]# host www.domain1.com 108.61.178.110 \r\nUsing domain server:\r\nName: 108.61.178.110\r\nAddress: 108.61.178.110#53\r\nAliases: \r\n\r\nwww.domain1.com has address 108.61.178.194\r\n<\/code><\/pre>\nNameserver lookup:<\/p>\n
<ceph>[root]# host -t ns domain1.com 108.61.178.110 \r\nUsing domain server:\r\nName: 108.61.178.110\r\nAddress: 108.61.178.110#53\r\nAliases: \r\n\r\ndomain1.com name server dns1.domain1.com.\r\ndomain1.com name server dns2.domain1.com.\r\n<\/code><\/pre>\nMailserver MX lookup:<\/p>\n
<ceph>[root]# host -t mx domain1.com 108.61.178.110 \r\nUsing domain server:\r\nName: 108.61.178.110\r\nAddress: 108.61.178.110#53\r\nAliases: \r\n\r\ndomain1.com mail is handled by 10 mail1.domain1.com.\r\ndomain1.com mail is handled by 30 mail2.domain1.com.\r\n<\/code><\/pre>\nOne more time to be sure:<\/p>\n
<ceph>[root]# host mail1.domain1.com 108.61.178.110 \r\nUsing domain server:\r\nName: 108.61.178.110\r\nAddress: 108.61.178.110#53\r\nAliases: \r\n\r\nmail1.domain1.com has address 89.201.163.42\r\n<\/code><\/pre>\nCongratulations! You have a working DNS server. Replace\u00a0domain1.com<\/code>\u00a0with your domain. After every change, run the\u00a0make<\/code>\u00a0command to make new\u00a0data.cdb<\/code>\u00a0file.<\/p>\nExplanation of the data file:<\/p>\n
“A” records begin with an\u00a0=<\/code>\u00a0sign. Aliases or CNAME records with a\u00a0+<\/code>\u00a0sign. Mail servers begin with the\u00a0@<\/code>\u00a0sign. Nameservers with the\u00a0&<\/code>\u00a0sign.<\/p>\nExample 1:<\/p>\n
=test1.domain1.com:193.198.184.100:3600\r\n<\/code><\/pre>\n=<\/code>\u00a0stands for “A” record.\u00a0test1.domain1.com<\/code>\u00a0is the DNS name, IP\u00a0193.198.184.100<\/code>\u00a0is the address in which\u00a0test1.domain1.com<\/code>\u00a0resolves, and 3600 is the TTL (time to live).<\/p>\nExample 2:<\/p>\n
# MX\r\n@domain1.com::mail1.domain1.com.:10:3600\r\n@domain1.com::mail2.domain1.com.:30:3600\r\n<\/code><\/pre>\nIn this example,\u00a0mail1<\/code>\u00a0and\u00a0mail2<\/code>\u00a0are mail servers for\u00a0domain1.com<\/code>.\u00a0mail1<\/code>\u00a0has priority 10 and\u00a0mail2<\/code>\u00a0has priority 30. That means that mail servers will first try to deliver mail to\u00a0mail1<\/code>. If\u00a0mail1<\/code>\u00a0fails, then they will try\u00a0mail2<\/code>.<\/p>\nThe following line marks beginning of the zone info. It is required.<\/p>\n
Zdomain1.com:dns1.domain1.com.:ns.domain1.com.:2013101203:604800:86400:2419200:604800:3600\r\n<\/code><\/pre>\n2013101203<\/code>\u00a0number is used when you have secondary DNS on some other provider. When you change the number to\u00a02013101204<\/code>, the secondary DNS will know that there are some changes in DNS and will pick up the changes. This is just for informative purposes (you would need the AXFR DNS transfer service). Alternatively, you can copy and paste your DNS changes between two DJBDNS servers with the\u00a0rsync<\/code>\u00a0program.<\/p>\nIf you have PF Firewall on your FreeBSD server, add this line to allow DNS queries:<\/p>\n
pass quick proto {tcp, udp} from any to $me port 53 flags S\/SA keep state <\/code><\/pre>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"open","ping_status":"closed","template":"","format":"standard","manualknowledgebasecat":[230,244],"manual_kb_tag":[],"_links":{"self":[{"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/manual_kb\/2870"}],"collection":[{"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/manual_kb"}],"about":[{"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/types\/manual_kb"}],"author":[{"embeddable":true,"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/comments?post=2870"}],"version-history":[{"count":1,"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/manual_kb\/2870\/revisions"}],"predecessor-version":[{"id":2873,"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/manual_kb\/2870\/revisions\/2873"}],"wp:attachment":[{"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/media?parent=2870"}],"wp:term":[{"taxonomy":"manualknowledgebasecat","embeddable":true,"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/manualknowledgebasecat?post=2870"},{"taxonomy":"manual_kb_tag","embeddable":true,"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/manual_kb_tag?post=2870"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}