I have my own server in home and webhosting server. I want to have my server being accessible when typed domain.tld and webpage (from outside webhosting) over WWW.domain.tld. Webhosting provider gives me both dns and public IP. After successful registration of my domain with www I tried to add proper records to my local freedns provider (freedns.42.pl) which allows me do add/modify A, AAAA, NS, MX, TXT record and add redirections/frames and menage subareas. I entered record A: @->my-home-ip and www->webhosting-ip. Without success: even after few hours all queries (including www) to my domain was redirected to my home ip. I've tried adding www as CNAME or even sub-area, but again - www to my home ip. Sub-areas don't work too. I know that it's possible to have another server with www than adress without it, but I can't fugure how to do it. It seems that dns is automatically point www.something.domain.tld to something.domain.tld
Domains and subdomains have to be resolved meaning that the visitor uses a DNS resolver to find the IP of the resource. So, if you make a
CNAME to a subdomain, it will be the exact same as making an
A-record to the IP, except take longer to access because the domain has to be resolve.
You're looking perhaps at a reverse proxy server which could proxy the content from
www.example.com to another domain it will listen on.