I want to break this down as simply as possible, hopefully.
We need to clarify some terms and how the technology works.
You say you have a domain,
www.example.com hosted externally, with a sub domain
data.example.com. But this is not a proper description of what you have. What you actually have is a domain,
example.com that is registered with a domain registrar and a hosting company is hosting the domain records (DNS) for the
example.com domain. On those DNS servers you have an A record (
www.example.com) that points to the IP address of what is likely a website your hosting provider is hosting for you.
Now, I think where the confusion here is that you are calling, and treating,
data.example.com as a sub domain. But, what you really mean to do is simply treat
data.example.com as a host (your NAS). That means there should be another A record setup at your hosting provider for the
example.com zone. It should simply say that
data.example.com points to the public IP address of your Internet service on premise.
Then, on your router, as you have stated, you have forwarded the necessary ports from your public IP to your internal NAS.
If all you are trying to do is use
data.example.com to access your NAS, then in most cases, what I just described is ALL you have to do. Based on the data you provided, you have gone way beyond what is necessary. You appear to have created a sub domain (
data.example.com) at your hosting provider. This is wrong. You appear to have tried to create a DNS zone on your NAS’s internal DNS server for
data.example.com, this is wrong. You have multiple adjustments to your router DNS settings or on your computer, this is wrong.
Again, if the only goal you are trying to achieve is to type data.abc.com in to a browser and access your NAS, then you must undo all this extra stuff you’ve done.
There is simply one thing you need to do, create an A record in the abc.com zone at your hosting provider for data.abc.com that points to the public IP address assigned to your internet service.
Only sometimes, if you have a more advanced router, do you run in to hairpin NAT issues. In that case, there are some routing adjustments that need to be made, or you can do split-dns where you have the abc.com domain hosted internally and externally. On the internal DNS server you have an A record for the abc.com zone that says data.abc.com points to the private IP address of your NAS. But, this paragraph should be ignored, unless you actually have the issue.
To reiterate again, data.abc.com is NOT a sub domain and should not be treated like one. It is simply a host (A record) entry in the abc.com domain, and there is absolutely no need for any internal DNS servers or any other modifications made to your router’s or computer’s DNS settings other than default.
Under default conditions, your computer uses your router as a DNS forwarder, and your router forwards DNS requests to your ISP and your ISP will forward requests for data.abc.com to your hosting provider. In return, your computer will obtain the public IP address of your on-premise network. If data.abc.com is typed in to your browser, regardless if you are internal or external you will access your NAS via the public IP. Again, sometimes there can be a hairpin NAT issue, but most home routers do not have this issue. You can test for this problem by typing the public IP address in to your browser, when you are internal, and seeing if you can access your NAS, instead of using the private IP address.