Published Aug 26, 2024
A subdomain is an extension of your primary domain name. It is used to organize and navigate to different sections of your website. A subdomain is created by adding a prefix to your primary domain name, separated by a dot (e.g., blog.example.com where blog is the subdomain of the primary domain example.com).
Configuring subdomains involves setting up DNS records with your domain registrar or DNS hosting provider. Here’s a step-by-step guide to configure subdomains, using GoDaddy as an example:
Log in to your account on your domain registrar’s website (e.g., GoDaddy).
Navigate to the My Products page to view your domain names.
Locate the domain you want to configure and click DNS next to it. This will take you to the DNS Management page.
In the DNS Management page, locate the Records section.
Click Add to create a new DNS record.
Type: Select A (Address) from the dropdown menu.
Host: Enter the subdomain prefix (e.g., blog to create blog.example.com).
Points to: Enter the IP address of the server where the subdomain will be hosted.
TTL (Time to Live): Set a TTL value, such as 600 seconds (10 minutes).
Example:
Type: A
Host: blog
Points to: 192.0.2.1
TTL: 600 or 3500
Click Save to create the subdomain.
DNS changes can take some time to propagate across the Internet. You can use various tools to check if the subdomain has been correctly set up.
Tools to Verify DNS Propagation
1 - WhatsMyDNS.net: Enter your subdomain to see the current DNS records from various locations around the world.
2 - nslookup: Use the nslookup command in your terminal or command prompt to query the DNS records.
Example: open Terminal in system run the command
- nslookup blog.example.com
Example: Configuring a Subdomain in AWS Route 53
If you are using AWS Route 53, follow these steps:
1. Log in to the AWS Management Console
Navigate to the Route 53 Dashboard.
2. Select Your Hosted Zone
Click on Hosted zones and select the domain you want to configure.
3. Create a New Record
Example:
Record name: blog
Record type: A
Value: 192.0.2.1
TTL: 600
Click Create records.
Example: Using AWS CLI to Create a Subdomain
For those who prefer using the AWS CLI, here are the commands to create a subdomain:
Create an A Record
aws route53 change-resource-record-sets --hosted-zone-id Z3AADJGX6KTTL2 --change-batch '{
"Comment": "Creating subdomain blog.example.com",
"Changes": [{
"Action": "UPSERT",
"ResourceRecordSet": {
"Name": "blog.example.com",
"Type": "A",
"TTL": 600,
"ResourceRecords": [{"Value": "192.0.2.1"}]
}
}]
}'