Difference between CNAME and SUBDOMAIN - dns

What is the difference between a CNAME and a Subdomain?
I understand that the a cname (the left side of a domain) can point to the domain, so you can two different urls point to the same address, ie.
ex1.mydomain.com - if setup as a CNAME can return the IP of mydomain.com
If ex1.mydomain.com is setup as a subdomain, does it have a different IP?
Another question is what should the ideal setup be in this situation:
I have IP1:80 for a web app
I have IP2:80 for another app
Can I point both of these IPs to the same A record, with perhaps a different cname or subdomain?
Thanks for any help?

CNAME is agnostic about name topology - it simply provides a way to alias a lookup for one name into a lookup for another name. So it may be in a subdomain context, or not.
Your second question doesn't make any sense to me. An A record maps from a domain name to (a single) IP address. So normally, in this situation, you'd have two domain names with an A record for each.

Related

Use same domain for two different subdomains?

I have a website called example.com.
I want www.example.com to point to my blog (on WordPress), but I want app.example.com to point to my app (on Heroku).
I am registered with Godaddy (could be any service though).
Is it possible to have one domain go to two completely different places?
Yes that is, just create two dns records for example:
www.example.com CNAME hosting.example.com
app.example.com A 109.23.23.45
cheers

How to add subdomain entry

I have a domain name (somename.com) registered at godaddy and i am using godaddy DNS Manager. But i am hosting my website with hostinger.com. So i have created a subdomain (sub.somename.com) on hostinger which by default points to same IP as a domain.
Now i have entry on godaddy DNS for my domain and subdomain name which points to hostinger server address where my website hosted. But when i access my subdomain (sub.somename.com) it goes to my somename.com. I have to refresh it to load sub domain page correctly.
Godaddy DNS Entry
domainname -- somename.com -> IP address of hostinger.com
subdomain -- sub.somename.com --> IP address of hostinger.com (same as above)
Hostinger DNS Entry
subdomain -- sub.somename.com --> IP address of hostinger.com(same as above)
Is above entries is correct ?
Should we need to have entry for domain and subdomain both on godaddy DNS ?
Do we need to have a entry for subdomain in hostinger.com also ?
In order to create a subdomain correctly you have to go through 2 steps:
1. Update your DNS records, so they accept your subdomain (sub.somename.com).
You should have these records for your setup:
A: # -> IP of hostinger.com (this is to connect the domain with hostinger)
A: sub -> IP of hostinger.com (only put the subdomain name)
CNAME: * -> somename.com (so that everything before somename.com goes to somename.com)
CNAME: *.sub -> sub.somename.com (so that everything before sub.somename.com goes to somename.com)
There are different types of DNS Records, the one's you mentioned are all A Records, you have to use CNAME Records as well.
2. Creating a virtual host (on the hosting provider)
The previous step was so that the Domain Name Servers know to which ip to point when the subdomain is used. From this side we have to point the subdomain address (sub.somename.com) to a specific folder that contains the different website. Most host providers, when you create a subdomain automatically create a new folder you can put your content at and point at it.
So to answer your questions.
No you have to change your DNS Records so they match the information above. Let me remind you that changes in the DNS Records might take a while to take effect (1-2 hours).
Your DNS entries should be at one place. Usually they are provided by the hosting provider (hostinger in this case), but since they are also provided by GoDaddy as well feel free to update them there.
There is no need to have a DNS entry in hostinger if you update them in GoDaddy.
P.S. Since I haven't used hostinger before, feel free to update me if you have more info, like if you're using CPanel.
If you intend to host a subdomain at an IP different than your main site, the records should look like this.
Main Site (mysite.com)
Type: A
Name(Host): #
Value(Points To): 192.168.1.1
Blog Site (blog.mysite.com)
Type: A
Name(Host): blog
Value(Points To): 192.168.1.2
As a reference, you only need an A record to host a subdomain. CNAME record is an alias. www records are usually CNAME records to the root domain as they are the same page.
Hope this helps!

Point GoDaddy domain to a specific folder on my web server

Lets say I have ordered domain name abc.com from GoDaddy.
I want to point the domain to my web site that I am hosting locally on my computer via IIS. Lets say that to hit this website currently, you would go to '123.123.123.123/mysite/'.
I am trying to setup the DNS Zone File to do this, but I cannot figure out how to get it to point to the "/mysite/" directory.
How can I properly set my GoDaddy DNS Zone file to point to '123.123.123.123/mysite/'?'
You have got your concepts a little mixed up there. What you are looking for is a HTTP Redirect. DNS is simply a way to map an IP Address to a domain name, it doesn't care what the traffic does once it gets to your site.
Think of DNS as a Postcode (Zipcode). It puts a letter in your letterbox. There is no way for it to know that Betty is on the second floor, because that's not what the Postcode does.
DNS will point a domain name example.com to an IP Address 123.123.123.123. You can have multiple domain names, www.example.com and mysite.example.com all pointing to the same IP Address, and the server can be configured to figure out what to do with each individual domain name.
So what you could potentially do is have the server detect that you are requesting mysite.example.com and have that redirected to www.example.com/mysite. This would be the standard way of achieving this.

Rails 3 Custom Domains A Record vs CNAME

Could someone explain the difference between an A Record and a CNAME, and what I should be telling my users to do if I am building a site that allows for custom domains to point to a subdomain on my hosted service?
A record... www.rabbot.com -> 123.123.123.123 (ie. an actual IP address)
CNAME record... www.philip.com -> www.rabbot.com (ie. more like an alias)
Your life will be much simpler if you have your users to use a CNAME as they can point their domains to yours. Then if you need to update your server's IP address you can simply update the single A record you have instead of making all your users update their DNS entries.
This is true regardless of what web framework you are using...

Two subdomains pointing to two different hosts?

For example, let's say I have domain.com. Can I configure http://subdomain1.domain.com to be hosted on http://www.squarespace.com and http://subdomain2.domain.com to be hosted on http://www.discountasp.net/?
Yes. Set the A record of subdomain1 to point to the IP of your site at squarespace.com and the A record for subdomain2 to point to the IP being hosted at discountasp.net.
Yes - either use a CNAME record and point it to each of those domains, or an A record for the full domain (subdomain1.domain.com) pointed at the IP address you need.

Resources