1

Currently I am stuck trying to label the interfaces for additional IP addresses I am adding to an interface. Let's say the interface is eth0 ($IFACE), then for $ADDRFAM="inet" I can add an IPv4 address to a labeled alias of eth0 like this:

ip -f $ADDRFAM addr add 10.0.0.1 dev $IFACE:test label $IFACE:test

which translates to

ip -f inet addr add 10.0.0.1/32 dev eth0:test label eth0:test

where the -f inet, i.e. IPv4, is implied and could be left out.

A cursory check with ifconfig yields:

eth0:test Link encap:Ethernet  HWaddr AA:BB:CC:DD:EE:FF
          inet addr:10.0.0.1  Bcast:0.0.0.0  Mask:255.255.255.255
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

Trying something similar with IPv6 ($ADDRFAM="inet6"):

ip -f $ADDRFAM addr add fdbf:98fc:66a5:de67::1/128 dev $IFACE:test label $IFACE:test

which expands to

ip -f inet6 addr add fdbf:98fc:66a5:de67::1/128 dev eth0:test label eth0:test

indicates no failure, but doesn't yield the expected result either:

eth0      Link encap:Ethernet  HWaddr AA:BB:CC:DD:EE:FF
          [...]
          inet6 addr: fdbf:98fc:66a5:de67::1/128 Scope:Global
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:5641 errors:0 dropped:0 overruns:0 frame:0
          TX packets:5483 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:792232 (792.2 KB)  TX bytes:861177 (861.1 KB)

eth0:test Link encap:Ethernet  HWaddr AA:BB:CC:DD:EE:FF
          inet addr:10.0.0.1  Bcast:0.0.0.0  Mask:255.255.255.255
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

What gives? Why does the labeling not give the expected effect of listing the address under eth0:test?


For comparison, the respective lines from ip addr look like this:

2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    [...]
    inet 10.0.0.1/32 scope global eth0:test
       valid_lft forever preferred_lft forever
    [...]
    inet6 fdbf:98fc:66a5:de67::1/128 scope global
       valid_lft forever preferred_lft forever
4
  • 2
    You should not be using old-style interface aliases at all anymore, (they contain a colon) despite that there are millions of outdated tutorials out there. All your IP addresses should be directly on the interface. May 7, 2014 at 2:29
  • @MichaelHampton: why? The documentation states only a single thing about this, that there are old-style (legacy style) aliases and that you can add more iface ... blocks to add more addresses (examples only given gor IPv4). Alas, even that doesn't work with IPv6. Not to mention that it prevents me from giving sensible names to the interfaces. May 7, 2014 at 9:33
  • If you want to rename the interface, then just rename the interface rather than making aliases. May 7, 2014 at 12:11
  • @MichaelHampton: you do realize that I was asking for different names for the different public IP addresses? Which means I do not merely want to rename the physical interface. In fact I don't care whether that's called eth0 or em1 or whatever. What I am interested is to group the public IPv4/IPv6 pairs into aliases of meaningful names. But you made a claim and still haven't provided any reasons. Also: this clearly indicates that the examples coming with Ubuntu as well as the man pages in Ubuntu are equally outdated as the ominous tutorials you're referring to (which I haven't seen). May 7, 2014 at 14:20

1 Answer 1

1

I realize this answer is for different flavors of 'NIX but I'll take a second stab and see if this helps.

Q. How do I add multiple IPv6 address to eth0 under Red Hat / Fedora / RHEL / CentOS Linux for virtual hosting?

A. There are two ways to add network aliaes under Red hat / CentOS Linux system. You need to edit any one of the following file in order to add IPv6 network alias.

/etc/rc.local - Use ifconfig command and shell loop.
/etc/sysconfig/network-scripts/ifcfg-eth0 - Set special variable called IPV6ADDR_SECONDARIES for eth0 virtual hosting (network alias).

First, setup IPv6 main server IP address and default router. Once basic IPv6 connectivity established you can setup aliases for NIC. /etc/rc.local configuration

To add 2607:f0d0:1002:11::10 to 2607:f0d0:1002:11::50 (total 40) virtual aliases, open /etc/rc.local file, enter:

vi /etc/rc.local

Append following code:

IP Alias

for ip in {10..40}; do /sbin/ifconfig eth0 inet6 add 2607:f0d0:1002:11::${ip}/64; done

You can type the same command at a shell prompt to immediately activate network aliases. Or create a shell script and call it from /etc/rc.local itself:

!/bin/bash

INETP="2607:f0d0:1002:11::" PRE="64" START=2 END=200 INT_IF="eth0" IFCONFIG=/sbin/ifconfig echo -n "Adding IPv6 Alias..." for i in {$START..$END} do $IFCONFIG $INT_IF inet6 add ${INETP}${i}/${PRE} done echo "Done!"

sysv style configuration

Open network interface configuration file, enter:

vi /etc/sysconfig/network-scripts/ifcfg-eth0

Append a list of secondary IPv6 addresses following code (set 5 aliases):

IPV6ADDR_SECONDARIES="2607:f0d0:1002:11::10/64 \ 2607:f0d0:1002:11::11/64 \ 2607:f0d0:1002:11::12/64 \ 2607:f0d0:1002:11::13/64 \ 2607:f0d0:1002:11::14/64"

Save and close the file. Restart networking:

/etc/init.d/network restart

So it seems the IPV6 address is an alias in and of itself.

source: http://www.cyberciti.biz/faq/redhat-centos-rhel-fedora-linux-add-multiple-ip-samenic/

6
  • I think you are mixing up concepts, due to the similar name! Please read that man page yourself first. Of course I will be happy if you can point out how this connects to what I am trying to do. Also see ietf.org/rfc/rfc3484.txt ... this is what ip-addrlabel is all about. May 6, 2014 at 23:18
  • @0xC0000022L my apologies I obviously have no idea what you are trying to do. Perhaps you could elaborate? Thank you
    – Elder Geek
    May 6, 2014 at 23:26
  • Try to follow the :test (or eth0:test) in the commands and outputs inside my question. The address label your answer is about is in a sense related precedence ("address selection"), not to labeling as in "naming". I am trying to name the interfaces (and aliases) in IPv6 as I can do in IPv4. May 6, 2014 at 23:28
  • Does this help? tldp.org/HOWTO/Linux+IPv6-HOWTO/x1035.html.
    – Elder Geek
    May 6, 2014 at 23:49
  • Or this? computerhope.com/unix/ip.htm
    – Elder Geek
    May 6, 2014 at 23:51

You must log in to answer this question.

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