Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I was given a second IP by my server provider. I am running Debian 5.0. I thought I knew how to add the IP to the system and configure with apache, but I have not yet been able to.

The primary IP works fine and I have a few sites already running on that one.

What steps would I take to add this second IP so that I use it in apache?

share|improve this question
add comment

4 Answers

up vote 6 down vote accepted

Assuming the new IP address is on the same subnet as the first, add a second virtual interface (sometimes called an "alias") to the primary network interface. This is configured, like all network interface settings, in /etc/network/interfaces. The Debian Reference manual has a section on the topic:

http://www.debian.org/doc/manuals/debian-reference/ch05.en.html#%5Fthe%5Fvirtual%5Finterface

A simple example, assuming your primary network interface is eth0 and has an ip of 192.168.1.1 and the new ip is 192.168.1.2:

auto eth0
iface eth0 inet static
  address 192.168.1.1
  netmask 255.255.255.0
  gateway 192.168.1.254

auto eth0:0
iface eth0:0 inet static
  address 192.168.1.2
  netmask 255.255.255.0

Once the appropriate settings have been added to /etc/network/interfaces, run ifup eth0:0 to activate the new interface.

If, however, the new ip is on a different subnet, you need to either provision the ip on a physically distinct network interface or create a VLAN interface, depending on how your ISP is prepared to hand it off to you. That's a whole new topic.

share|improve this answer
    
Thanks for the answer. I tried following these instructions, but when I restart the network interfaces I receive this error: :/etc# /etc/init.d/networking restart Reconfiguring network interfaces...SIOCDELRT: No such process if-up.d/mountnfs[eth0]: waiting for interface eth0:0 before doing NFS mounts (warning). done. The subnet is the same for the ips, so from what I know and read this above solution should work. The virtual host that I setup are not working and I get network timeout on the domain. –  David Sep 20 '09 at 0:36
    
The warnings sound reasonable. The fact that it makes reference to waiting for eth0:0 is good news. What do your network interfaces look like after restarting networking? Specifically, what does the output of "ifconfig -a" look like? –  Insyte Sep 20 '09 at 2:46
add comment

Even Simpler:

Use an "addresses" line in /etc/network/interfaces

iface eth1 inet static
        address 10.10.0.66
        netmask 255.255.255.240
        network 10.10.0.64
        broadcast 10.10.0.79
        gateway 10.10.0.65
        addresses 10.10.0.67/28 10.10.0.67/28 10.10.0.68/28

You can use a space seperated list of IPs/CIDR netmasks.

This is a crippled version of my interface definition (IPs changed and only relevant part)

share|improve this answer
    
I can't find the addresses line in the manpages interfaces or ifconfig, neither does it work on Debian Lenny. –  Lekensteyn Jan 22 '11 at 16:08
add comment

You are supposed to configure a new alias for your second ip.

The mandatory resources for ip management are the file /etc/network/interfaces and the ip tool from iproute package.

Where are things breaking? what doesn't work?

share|improve this answer
add comment

If you use the iproute package, you can put this in /etc/network/interfaces:

auto eth0
iface eth0 inet static
    address 10.0.0.17
    netmask 255.0.0.0
    gateway 10.0.0.1
    up   ip addr add 10.0.0.18 dev eth0
    down ip addr del 10.0.0.18 dev eth0
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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