View Single Post

   
  #9 (permalink)  
Old 01-18-2008, 05:13 AM
Lew Pitcher
 
Posts: n/a
Default Re: Can linux box support 2 host names / 2 ip addresses

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Richard TU wrote:
> Thanks a lot for your replies.
> I understand a lot now after you explained it.
>
> Here is my problem:
> I have two linux boxes, each with its own IP and hostname. Now I want to
> combine these two into one linux box, but still keep the two sets of IP
> addresses and hostnames. For example, when I go to the web page, both
> hostnames should lead me to the same linux box after the combination.
> I prefer to use one NIC to listen to two IP addresses like setting eth0 and
> eth0:0 to different IP address. What I have to do is to add the hostname in
> the hosts file, is that right?


Remember that /etc/hosts only affects the system on which it resides.
So, each system that will access the new 'combined' system will need
corresponding changes to its own /etc/hosts file.

If you don't have control over these outside systems, then you should
make a change at the DNS level.


Assuming (for the purposes of this illustration) that your two sites are
currently named foo.bar.com (at IP address 10.0.0.1) and rosanne.bar.com
(at 10.0.0.2) here's what I would do with the combined system...

In your network config scripts
ifconfig eth0 10.0.0.1 broadcast 10.255.255.255 netmask 255.0.0.0
ifconfig eth0:0 10.0.0.2 broadcast 10.255.255.255 netmask 255.0.0.0

In your various /etc/hosts file
10.0.0.1 foo.bar.com foo
10.0.0.2 rosanne.bar.com rosanne
(alternatly, update your DNS to point these domain names to the proper
IP addresses).

In your Apache httpd.conf file
<VirtualHost foo.bar.com>
ServerAdmin webmaster@foo.bar.com
DocumentRoot /var/www/foo.bar.com
ServerName foo.bar.com
ErrorLog logs/foo.bar.com-error_log
CustomLog logs/foo.bar.com-access_log common
</VirtualHost>
<VirtualHost rosanne.bar.com>
ServerAdmin webmaster@rosanne.bar.com
DocumentRoot /var/www/rosanne.bar.com
ServerName foo.bar.com
ErrorLog logs/rosanne.bar.com-error_log
CustomLog logs/rosanne.bar.com-access_log common
</VirtualHost>

In directory /var/www/foo.bar.com
place the web pages for web domain foo.bar.com

In directory /var/www/rosanne.bar.com
place the web pages for the web domain rosanne.bar.com




- --

Lew Pitcher, IT Consultant, Enterprise Data Systems
Enterprise Technology Solutions, TD Bank Financial Group

(Opinions expressed here are my own, not my employer's)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (MingW32)

iD8DBQFBXbAvagVFX4UWr64RAjMDAJsHHy3vleqfV2AlOaCL7q TQ3W9RkQCgutRD
W6vA7v9F8HRk958EVxlzpzI=
=gB2x
-----END PGP SIGNATURE-----
Reply With Quote