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've got a Ubuntu 13.10 VPS server with 1 IPv4 (111.111.111.111) (and 1 IPv6 address).

I recently requested an extra IP address (222.222.222.222) but I can't seem to figure out how to add the new IP address to my network configuration.

My current (default?) network configuration:

/etc/network/interfaces:

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet dhcp

From what I came up with after searching is that I need to add the new IP address like so:

iface eth0:1 inet static
address 222.222.222.222
netmask 255.255.255.0

But unfortunately this doesn't work and I've got the feeling it has something to do with the dhcp setting in auto eth0 -> iface eth0 inet dhcp but I have no clue how to fix this.

Also worth noting is that the gateway for IP 1 is different from the gateway for IP 2, could this lead to any issues?

My feeling says I need to remove the current network configuration for eth0 and replace it with:

iface eth0 inet static
address 111.111.111.111
netmask 255.255.255.0
gateway xxx.xxx.xxx.xxx

So the end result would look something like:

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
iface eth0 inet static
address 111.111.111.111
netmask 255.255.255.0
gateway xxx.xxx.xxx.xxx

iface eth0:1 inet static
address 222.222.222.222
netmask 255.255.255.0

Because there are some small sites currently active on this server I don't want to risk any downtime by changing these network configurations

My Goal

My goal is (please let me know if this is possible or not) to use IP address 1 (111.11...) for all apache2 requests on port 80. And to use IP address 2 (222.22...) for all requests through something other than apache2 (NodeJs for instance) but also on port 80.

share|improve this question
    
You don't need a second IP address just to run Node. And I think you'll find your answer here. –  Michael Hampton Jan 1 at 4:07
    
If I would like to run both on port 80 I do need separate IP addresses I guess. Concerning the comment you linked to; Where can I find the network and broadcast addresses and do I need to add allow-hotplug eth0? I guess the hotplug is because the extra interfaces are not aliases eth0:X, is that correct? –  Chris Jan 1 at 4:23
    
the network mask will be defined by your isp. the broadcast is generally the highest address in the network range –  lVlint67 Jan 1 at 4:56
    
"I don't want to risk any downtime by changing these network configurations". I would suggest setting up a machine with similar configuration for testing purposes. –  ErikE Jan 1 at 6:59

1 Answer 1

If both the addresses are on the same interface, your proposed configuration looks good. However you will need the following lines to ensure the interfaces come up:

auto eth0
auth eth0:1

These can be combined as:

auto eth0 eth0:1

The network and broadcast addresses will be determined from the IP Address and netmask if not provided. Your ISP must provide of these. They should be able to provide the broadcast and network addresses, although I never configure them.

If you have fixed IP addresses you won't want either DHCP or hotplug. Both of these are for non-server configurations. DHCP is used to get an address from the router or other DHCP server when connection to a network. Hotplug is used to select the appropriate configuration from a set of configurations when connecting to different networks. Hotplug would be appropriate for a laptop used in an office or at home where DHCP was not sufficient for configuration.

share|improve this answer

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.