After setting up our Ubuntu server and successfully deploy our Rails application, we need to setup our own DNS server with bind9 to publish our Rails application to the world via a meaningful domain name.
Install bind9:
sudo aptitude install bind9 dnsutils sudo nano /etc/bind/named.conf.local
Add the following lines in ‘named.conf.local’:
zone "domain.com" {
type master;
file "/etc/bind/zones/db.domain.com";
};
zone "0.168.192.in-addr.arpa" {
type master;
file "/etc/bind/zones/rev.0.168.192.in-addr.arpa";
};
Add a zone config file
sudo cp /etc/bind/db.local /etc/bind/zones/db.domain.com sudo nano /etc/bind/zones/db.domain.com
$TTL 604800
domain.com. IN SOA ns1.domain.com. support.domain.com. (
2010072504 ; Serial
604800 ; Refresh
86400 ; Retry
2419200 ; Expire
604800 ) ; Negative Cache TTL
; DNS
domain.com. IN NS ns1.domain.com.
; Sub-domains
@ IN A 202.181.234.41
ns1 IN A 202.181.234.41
www IN A 202.181.234.41
Configue bind9 options:
sudo nano /etc/bind/named.conf.options
Add the following lines to ‘/etc/bind/named.conf.options’:
query-source address * port 53;
notify-source * port 53;
transfer-source * port 53;
forwarders {
202.181.224.2;
202.181.224.3;
202.181.224.130;
202.181.224.140;
};
Edit ‘/etc/ressolv.conf’:
search domain.com nameserver 127.0.0.1 nameserver 123.456.789.123 nameserver 202.181.224.2 nameserver 202.181.224.3 nameserver 202.181.202.130 nameserver 202.181.224.140
Add the following lines to ‘/etc/iptables.up.rulse’ and restart iptables:
iptables -I INPUT -p udp -m udp --dport 53 -j ACCEPT iptables -I INPUT -p tcp -m tcp --dport 53 -j ACCEPT
Install nscd and clear DNS lookup cache:
sudo aptitude install nscd sudo /etc/init.d/nscd restart
Test the result:
dig @localhost domain.com dig domain.com
Settings for your domain name in GoDaddy.com
I registered my domain on GoDaddy.com, so i need to set the nameserver to point to the newly created DNS server and set the host ip for ns1.domain.com.
Setting Host ip address for DNS server (It will takes 24-48 hours to be effective) :
- Login your account on GoDaddy.com
- Account Manager>My Products>Domain>Domain Manager
- Host Summary (At the lower left corner)
- Add a Host
- Host name: ns1
- Host IP: [Your DNS server fixed ip address]
- OK
Setting nameservers:
- Login your account on GoDaddy.com
- Account Manager>My Products>Domain>Domain Manager
- Name Server>Set Nameservers
- Add your own DNS server and any secondary DNS server in your region
References:
DNS (bind9) Configuration HowTo
Ubuntu Hardy – Installing a DNS Server with BIND
Related Posts
- Setting Up PHP FastCGI and phpMyAdmin with nginx
- Setting Up Ubuntu Server for Ruby on Rails Deployment
- Deploy Rails application via Git and Capistrano
