LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   Multiple hostname for the same interface (https://www.linuxquestions.org/questions/linux-server-73/multiple-hostname-for-the-same-interface-4175448697/)

karnaf 02-05-2013 08:18 AM

Multiple hostname for the same interface
 
Hi all,

I have a VM with apache on it serving three different sub-domains, for example:
  1. user.example.com
  2. moderator.example.com
  3. admin.example.com

When the VM starts, it gets its IP from the DHCP which should update the nameserver (both are on another VM in the same internal network)

Is there a way for me to register all three hostnames (user, moderator, admin) through DHCP so that anyone in the example.com domain can access any of the addresses, even if the VMs IP had changed?

I tried looking in the following directions, but couldn't find the answer
  • Change the dhclient to publish several hostnames
  • Change the way the DHCP and the NS talk, so that the DHCP would know how to magically notify the NS on that
  • Change the way the NS works
The current solution I followed was to assign a static IP for that VM, with static entries in the NS, but I'm looking for something funkier :cool:

Some of my VMs are Ubuntu, some are Fedora

Thanks
karnaf

acid_kewpie 02-05-2013 09:09 AM

a web server has no business running on DHCP. That's just horrible.

What I would suggest is seeing a difference between a hostname and a web domain it serves. A machine should be called by, and therefore registered to DHCP as, the name of the BOX, not of it's websites. the ONLY A record for that box should be the machine hostname. any subsequent sites that it hosts should then be defined statically in DNS as CNAME records pointing to that A record.

TenTenths 02-05-2013 09:36 AM

Quote:

Originally Posted by acid_kewpie (Post 4884805)
a web server has no business running on DHCP. That's just horrible.

I can see where it would be useful to use DHCP to configure things like default gateways, upstream DNS servers etc, but would have a MAC based IP reservation within the DHCP scope.

acid_kewpie 02-05-2013 09:38 AM

oh sure, a reservation is very different. There is no anticipation of anything changing, just being centrally controlled in that sort of situation. You should always now what IP is serving your website though.

karnaf 02-05-2013 01:13 PM

Quote:

Originally Posted by acid_kewpie (Post 4884805)
a web server has no business running on DHCP. That's just horrible.

Not sure I understand, so I'll answer both options I could think you meant
1. if you meant httpd & dhcp are on the same VM, well, they aren't
2. if you meant that a machine running httpd should have a static address and not get it dynamically, then I agree. However, that's a dev VM machine in a crazy world :-)
Quote:

Originally Posted by acid_kewpie (Post 4884805)
What I would suggest is seeing a difference between a hostname and a web domain it serves. A machine should be called by, and therefore registered to DHCP as, the name of the BOX, not of it's websites. the ONLY A record for that box should be the machine hostname. any subsequent sites that it hosts should then be defined statically in DNS as CNAME records pointing to that A record.

Sounds like a good plan. Just making sure I got it right
let's assume the machine's "real" hostname is my-funky-dev-server
my-funky-dev-server.example.com will get an IP from DHCP (the A record), which in turn will update the NS
in the NS, I'll set CNAME for all three sub-domains of my web app to point to my-funky-dev-server.example.com by name, and not by IP
Correct?

Thanks!
k

jefro 02-05-2013 02:31 PM

Some people use host headers to send the page to the correct server.

acid_kewpie 02-05-2013 02:53 PM

Quote:

Originally Posted by jefro (Post 4885008)
Some people use host headers to send the page to the correct server.

I think everyone uses host headers... that's how HTTP works.. :confused:


All times are GMT -5. The time now is 05:54 PM.