There may be times where you want to host a subdomain on a different server than the main domain. To accomplish this, you need an A record, added either at the domain registrar if possible, or the server that hosts mydomain.com.
sub.mydomain.com. 14400 IN A XXX.XXX.XXX
The X’s should be replaced by the target server’s IP address. I prefer changing this info at the domain record level, since that doesn’t require cooperation of the main domain’s host, and thus can be changed by the domain owner in the event the target server’s IP changes.
For this to work, the subdomain MUST be added to the target server. A very simple way to do this is to add the main domain as an Addon in cPanel, and then set up the subdomain which will add all the relevant DNS entries (even though the main domain is not actually hosted on the target server). ((Caveat – I’ve found you may see occasional weirdness, though, with the approach described, such as a WordPress installation that requires uploads to go straight to the upload folder to work, instead of month and year-based folder settings. Would probably be better to add the subdomain to your server configuration directly for long-term robustness.))

Hey Dixie, thanks for the information. I’m a bit confused about the ‘A’ record.
I want to move my subdomain to a new host/server and for this I added the subdomain link on the new host/server via ‘Addon Domain’.
Now, the new host/server is giving me the name of servers. But in the DNS zone editior of the subdomain, I’ve (assumed)
Name: subdomain.url.com
TTL: 44444
Type: A (also CNAME and TXT)
Address: 171.222.41.21
So, now what should I change in it or should I create a new record and where should I add the name-servers of the new host.
Many many thanks in advance.
Rmra – I’m not especially accomplished at this, as I don’t frequently do it. That’s why I put it here, so I could refer to it if needed!
But in addition to setting up the subdomain on the new host, you need that A record connect to the main domain. The nameservers for the main domain is where traffic is going to be first routed. A records can be added directly to the domain record for some registrars, whereas some, not. If not, then it has to go on the old hosting server, since this is where internet traffic goes for the domain first, main or sub. That sounds like the piece you are missing.
It means that main domain & subdomain should be on 1 host. And also it is impossible to add both domain & subdomain on two different hosts.
Thanks for the information.
The main domain is only “added” to the host of the sub-domain as a container. Internet traffic to the main domain does not actually get routed there. But adding the main domain to the second host via cPanel is an easy way to have the records you need set up without editing your configuration files directly, a much messier process. I wrote this post after doing it, as a reference and help to others who might need to do the same.