1

I've recently installed Gentoo on a dedicated server. I have 6 IPs, and I forgot to write down one config before I erased the CentOS install.

Should I have
eth0 = ip1
eth0:0 = ip2
eth0:1 = ip3
eth0:2 = ip4
eth0:3 = ip5
eth0:4 = ip6

or should I have eth0:0 sharing the main IP?
eth0 = ip1
eth0:0 = ip1
eth0:1 = ip2
eth0:2 = ip3
eth0:3 = ip4
eth0:4 = ip5
eth0:5 = ip6

4 Answers 4

6

You DON'T need interface aliases in order to have multiple IP addresses for the same server. You should use interface aliases mostly if you are dealing with separate subnets and need to route between the addresses, which doesn't seem to be the case.

With Linux (since 2.2 or 2.4, I don't remember) a single interface may have many addresses. This is the preferred way of setting it up. There are issues with the multiple aliases setup, for example, it is not clear how a broadcast message should be handled if multiple aliases are on the same subnet.

I don't know how you set this in Gentoo configuration, but using the standard ip interface, it is simple:

ip addr add ip1/prefix brd + dev eth0
ip addr add ip2/prefix dev eth0
ip addr add ip3/prefix dev eth0
ip addr add ip4/prefix dev eth0
ip addr add ip5/prefix dev eth0
ip addr add ip6/prefix dev eth0

Note 1: Broadcasts will be received only by the first address. If your addresses are on different subnets, you may want to set broadcasts on the other IPs also.

Note 2: ifconfig won't probably show the additional addresses, it is obsolete anyways. Use ip addr show to check which addresses are assigned to each network interface.

Anyways, answering your question: no. Each alias is viewed as a different interface for the system. So eth0 would be one interface, with one address, eth0:0 would be another interface with another address and so on.

2
  • For a gold star, can anyone tell me how you'd do this in Debian/Ubuntu's /etc/network/interfaces config file? Apr 29, 2010 at 5:44
  • Found it! Have just one iface section and add an "up" subsection with "ip addr add..." - seen here linode.com/wiki/index.php/… Apr 29, 2010 at 13:25
5

Each entry should be unique.

eth0 = ip1
eth0:0 = ip2
eth0:1 = ip3
eth0:2 = ip4
eth0:3 = ip5
eth0:4 = ip6 
1
  • Yes, seconded, they should.
    – edomaur
    Aug 29, 2009 at 6:38
2

I agree with Juliano. In Gentoo, you can configure this with /etc/conf.d/net and then set config_eth0 with multiple space seperated ips. The line should look like this: config_eth0=( "192.168.0.1/24" "192.168.0.2/24" "192.168.0.3/24" )

1

Each must be unique. The number after the colon is arbitrary and the numbers need not be sequential. In fact, they don't even have to be numbers at all. From Documentation/networking/alias.txt in the Linux source:

An alias is formed by adding a colon and a string when running ifconfig.
This string is usually numeric, but this is not a must.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .