Link to home
Start Free TrialLog in
Avatar of gddl630
gddl630Flag for United Kingdom of Great Britain and Northern Ireland

asked on

how to configure multiple IPs on centos box for different sites

we will be hosting multiple sites on this box and I need to use different IPs in ssl.conf etc so how can I configure the IPs on the interface?

in an old rhel box I've seen in /etc/rc.d/rc.local stuff like: ifconfig eth0:10 10.30.0.117 netmask 255.0.0.0, but I was told this is pretty "predestrian" way of doing it

what is the recommended way this should be done? best practice even

I've come across suggestions to copy ifcfg-eth0 for all aliases incrementing the value after :
/etc/sysconfig/network-scripts/
cp ifcfg-eth0 ifcfg-eth0:0
cp ifcfg-eth0 ifcfg-eth0:1 etc
http://www.xenocafe.com/tutorials/linux/redhat/bind_multiple_ip_addresses_to_single_nic/index.php

is this how it is supposed to be done?
ASKER CERTIFIED SOLUTION
Avatar of pingvinos
pingvinos
Flag of Serbia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Julian Parker
reccommended way would be to use the config files in /etc/sysconfig/network-scripts as you mentioned in you post and in the post above.
I've just reread your post, if you mean by hosting multiple sites in a web site sort of way, you would use virtual hosts configured in the httpd.conf file, this would then need to point to your document root depending on hostname.

Is that what you meant?
Jools,multiple SSL (HTTPS!) sites not possible on one IP,because every SSL-enabled site needs a different IP address...so name-based virtual directories do not apply for this question.
Avatar of allen-davis
allen-davis

if you want to write your own IP script to do it, another pretty simple way is to use the ip addr command (/sbin/ip)

ip addr add xx.xx.xx.xx/mask dev <dev name>

for example
ip addr add 10.128.10.100/24 dev eth0

would add the IP address 10.128.10.100 to the eth0 network interface.  You would then have to use "ip addr" to see the list of ip addresses, ifconfig would not show the  address.  But if you managed the startup and shutdown in the rc scripts somewhere, you could pretty easily have one script to manage that just lists out the virtual IPs you want to add to the box.

From there, you can define IP based virtual hosts in the apache conf file to listen for the various sites on the IPs you defined.