Adding extra IP’s to one network interface in RHL and Mac OS 10.4

When hosting some web services, it really makes sense to sometimes to have more than one IP on a machine. This is extremely useful when using SSL certs and you want to have IP-based virtual hosting.

On the Mac, this is very easy. All you have to do is

  1. Go to System Preferences -> Network.
  2. Select Network Port Configurations from the Show menu.
  3. Select the interface you want to add the extra IP to (for example, Built-in Ethernet), and click Duplicate.
  4. Now you can name it something like ‘Built-in Ethernet .YYY’ for your other IP.
  5. Hit apply.
  6. Now, in the Show menu, select the new port config you just made.
  7. Make your changes, and hit apply.
  8. Your done!

As far as doing this in RedHat Linux (or one of the RedHat based distros like Fedora Core or CentOS ), it is almost just as easy to do from the command line!

  1. Go to the /etc/sysconfig/network-scripts/ directory
    cd /etc/sysconfig/network-scripts/
  2. Copy the interface file that you want to add the IP to, and give it the same name as the current file, with ‘:0’ added (or :1, :2, depending on how many IPs are on this interface).
    cp ifcfg-eth0 ifcfg-eth0:0
  3. Edit the new file, and you only have to change a few things
    1. Change IPADDR= to your new IP address
    2. Change DEVICE= to add :0 (depending if this is the 2nd IP on that interface)
    3. remove DHCP_HOSTNAME (or set it to what it needs to be)
    4. remove the HWADDR entry
  4. Save the file that you just were working on
  5. Restart the network interfaces
    /etc/init.d/network restart
  6. Done!

Listening To: ‘March of the Pigs’ by NIN


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s