If I have a subdomain in my webhost, is it possible to redirect it to a sever that has a public IP?

I created a subdomain using CPanel on my webhost. Because hosting costs are relatively high where I am, I wanted to take the subdomain created and redirect it to my own server using bind9 on Linux.

Should this be possible, is it then also possible to have that subdomain become my main domain on my server and create subdomains out of it? I'm looking for something like this:

Domain: example.com
Subdomain: foo.example.com

If I can redirect foo.example.com to my own server, I want to create domains on it such as:


Can this be done?

  • @JonatanGarber I appreciate the editing. Thanks! I had trouble expressing my thoughts. – adlescouflair Dec 6 '13 at 20:34
  • You're welcome. I'm happy to help. – Jonathan Garber Dec 8 '13 at 23:29

You'd need to check if your homeserver is at a location with a fixed IP address. Some Internet service providers used fixed IPs, probably most don't. This is their external facing IP, so your broadband router at home will have 1 external IP. Then each device in your home will have its own private or internal IP. If you have a static IP, the subdomain can point to that, but if you don't, you need to use some sort of dynamic dns service, eg dyndns.org which can be configured in certain makes of broadband router.

The best way to set up the subdomain may be to use your domain management where you bought the main domain from, rather than setting it up in cPanel, but I don't use cPanel now so I'm not sure about this bit.

Then, when traffic comes from the subdomain to the router, you need to set up redirection so the router knows where in your home network to send it on to. Depending on how you're using it, it's probably Port Redirection settings in the router. If it's HTTP traffic you'd probably want to configure the router's public port 80 to redirect to port 80 of the IP address of your homeserver. Additionally your homeserver will probably need to have a fixed IP address so the router always knows where to find it.

I note you said your homeserver has a public IP. If it really does have a public IP then you'd obviously be able to skip some of these steps, but usually it's only the router that has the public IP.

Feel free to correct me anyone else! It's a while since I've done anything like this

  • Thanks for the reply. Frankly I got lost with you in your explanation. I don't actually have any contact with the company the domain name was reserve or brought from, but I do have contact with the company that is hosting my website. <br/> I have a dedicated public IP connected directly connected to the PC. I was thinking to ask the host to change the IP they use for the subdomain, and change it to my IP and configure the domain at home, but then, can I do subdomains from it like this example:<br/> bar.foo.example.com qux.foo.example.com – adlescouflair Dec 6 '13 at 20:58
  • this answer is to complex, don't really understand if I have a domain such as alex.mywebsite.com already working and pointing to my home server if all the traffic that goes to test.alex.mywebsite.com goes to my home server as well. Can someone clarify this for me? – alexandre1985 Apr 23 '17 at 14:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.