640 Cheap Domain & Subdomain
0%

Buy a Cheap Domain and Set Up a Subdomain

The task: buy a domain on Namecheap for about the price of a coffee, then point yourdomain.xyz and lab.yourdomain.xyz at a server you control.

about 15 minutesroughly $2 for the first yearneeds a payment card and a server IP
Steps
  1. •Before you start
  2. 11 — Buy the domain cheaply
  3. 22 — Set up the root domain
  4. 33 — Add a subdomain
  5. 44 — Check it resolves
  6. •Links
•

Before you start

  • A payment card.
  • The IPv4 address of the server you want the name to point at.

If that server is the g1 VM from the previous lab, read its IP with:

bash
gcloud compute instances describe g1 --zone=us-central1-a \
  --format="get(networkInterfaces[0].accessConfigs[0].natIP)"
A VM that is stopped and started gets a new IP, and the DNS record then has to be updated. Reserve a static IP if that matters.

Replace yourdomain.xyz with your own domain everywhere below.

1

1 — Buy the domain cheaply

  • Go to namecheap.com and search for a name.
  • Pick a cheap TLD — .xyz, .site and .online are usually about a dollar for the first year.
  • Check the renewal price, not just the first-year price. The cheap number is promotional and applies once.
  • Skip every paid add-on. Keep the free WHOIS privacy, which is on by default.
  • Register for one year. Auto-renew off unless you want to keep the name past the promo.
ItemWhat to expect
First yearabout $1–2 on a cheap TLD
Renewalabout $10–14 per year
ICANN fee$0.18, unavoidable
DNS hostingfree, included
WHOIS privacyfree, keep it on
2

2 — Set up the root domain

In the Namecheap dashboard: Domain List → Manage → Advanced DNS.

Delete the two records Namecheap adds by default — the CNAME for www and the URL-redirect record — then add:

TypeHostValueTTL
A Record@your server's IPAutomatic

@ means the bare domain, yourdomain.xyz.

Leave the nameservers on Namecheap BasicDNS. Changing them moves DNS elsewhere and these records stop being used.
3

3 — Add a subdomain

Same screen, one more row. The host field is the subdomain label, nothing else:

TypeHostValueTTL
A Recordlabyour server's IPAutomatic

That gives you lab.yourdomain.xyz. One A record per subdomain is the whole rule — add www, api, demo the same way.

To point a subdomain at another hostname instead of an IP, use a CNAME record with the target hostname as the value.

4

4 — Check it resolves

DNS is not instant: minutes usually, a few hours at worst. Check from your own machine:

bash
dig +short yourdomain.xyz
dig +short lab.yourdomain.xyz

Both should print your server's IP. Then open http://lab.yourdomain.xyz in a browser.

nginx
If the server runs nginx, it also has to recognise the names. On the server: sudo sed -i 's/server_name _;/server_name yourdomain.xyz lab.yourdomain.xyz;/' /etc/nginx/sites-available/default then sudo nginx -t && sudo systemctl reload nginx.