A comprehensive guide to configure DNS and web server using Bind, AWS, and Let's Encrypt
This guide walks you through the process of setting up DNS on a server using BIND and configuring a web server with Apache on AWS. We'll also secure the web server with SSL using Let's Encrypt. Follow the steps to ensure proper DNS resolution and server accessibility.
sudo apt update sudo apt install bind9 bind9utils bind9-doc
Create a directory to store your zone files:
sudo mkdir -p /etc/bind/zones
Create the zone file for your domain:
sudo vi /etc/bind/zones/db.soham.sbs
In the file, define the A records for your domain:
$TTL 604800 @ IN SOA ns1.soham.sbs. admin.soham.sbs. ( 2 ; Serial 604800 ; Refresh 86400 ; Retry 2419200 ; Expire 604800 ) ; Negative Cache TTL ; Name servers @ IN NS ns1.soham.sbs. ; A records @ IN A 3.7.174.57 ns1 IN A 15.206.90.100 ns2 IN A 15.206.90.100 www IN A 3.7.174.57
sudo vi /etc/bind/named.conf.local
Add this configuration:
zone "soham.sbs" { type master; file "/etc/bind/zones/db.soham.sbs"; };
sudo systemctl restart bind9
Navigate to the domain management section where you have the domain registered.
Add the following name servers:
ns1.soham.sbs ns2.soham.sbs
Make sure the name servers point to the correct IPs of your BIND server (e.g., 15.206.90.100).
Use tools like dig to verify that your domain resolves correctly:
dig @15.206.90.100 soham.sbs
sudo apt update sudo apt install apache2
Create a virtual host file for your domain:
sudo vi /etc/apache2/sites-available/soham.sbs.conf
In the file, configure your web server settings:
<VirtualHost *:80> ServerAdmin admin@soham.sbs DocumentRoot /var/www/soham.sbs ServerName soham.sbs ServerAlias www.soham.sbs ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost>
sudo a2ensite soham.sbs.conf sudo systemctl restart apache2
sudo apt install certbot python3-certbot-apache
sudo certbot --apache -d soham.sbs -d www.soham.sbs
sudo certbot renew --dry-run
Ensure your domain resolves correctly to your web server's IP:
dig @15.206.90.100 soham.sbs
Check if SSL is installed by accessing your site via HTTPS in a browser.
Author: Tanmoy Chatterjee
Date: May 2025