I didn’t really know how to title the question because it’s really more than what I titled this post, but that’s what explanations are for I guess. Here’s what I would like to do.
Someone very adept as fiddling with DNS records would be ideal for answering this question.
Here’s my topology so-to-speak.
I have a domain that I would like to split across two hosts. Here’s SPECIFICALLY what I mean.
I want to host example.com at one host and sub.example.com at another (DigitalOcean).
Now, as I understand it (it’s been years since I have messed with DNS records), I could achieve this by doing the following …
Setup my registrar’s DNS records like so …
example.com => IP of host1 sub.example.com => IP of host2 (DigitalOcean droplet)
In order to pull this off, I would have to tell the registrar that I want to use their nameserver. That would be step one. Then, configure the DNS records as shown above.
I’m just really not sure how I would do this.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
I think I have solvedExample link my issue. We shall see. Here’s my current DNS configuration. I am trying to keep the nameserver configuration as close to the registrar as possible. It would be a hassle if I closed my account here or somewhere else (another host) and had to change where my custom DNS settings were. So, my registrar now holds this configuration.
Host #1 = The host that will handle the pretty website and all that javascript / css / php we love to mess around with.
Host #2 = The serious business host (DigitalOcean) where I can create a development test server.
| Type | Host | IP |
|---|---|---|
| A | @ | Host #1’s IP |
| A | * | Host #1’s IP |
| A | dev | Host #2’s IP |
Thanks to this amazing tool, I have this working exactly correctly.
The @ entry says when the domain is matched exactly, go to host #1 and pull the resource (site). The * says, whenever someone types in any subdomain OTHER than the exception (dev), still go to the host #1 and pull that resource (whatever it may be). The “dev” bit says, when the input matches exactly dev.example.com, go to host #2 (DigitalOcean). Perfect!
Does anyone see anything wrong with this? Will this configuration cause any DNS issues?
I didn’t really understand your question, I think, but this should be how to set the DNS as you asked:
| Type | Hostname | IP |
|---|---|---|
| NS | ns1.digitalocean.com. | - |
| NS | ns2.digitalocean.com. | - |
| NS | ns3.digitalocean.com. | - |
| A | @ | {ip:host1} |
| A | sub | {ip:host2} |
Which registrar did you use? I can help you with Namecheap to set custom nameservers.
Ok, so I have this working now. It’s working flawlessly as follows.
example.com => Host 1 dev.example.com => Host 2
Now the final question remains …
When I setup a droplet, should I set the hostname (first input box) to “dev” or “dev.example.com” (the fully qualified domain name)? My guess would be the entire domain name dev.example.com, but I am unsure.
When the user agent request reaches the digital ocean servers, it expects to see the tnire thing I believe. Am I correct?
I just want to be clear — when you create a droplet, the “hostname” is NOT a “nickname” or something, it’s actually the name used to configure the server - as in the hostname of the machine (if it were a bare metal box).
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.