Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

When I add an IPv4 address for the interface eth0:0 with ifconfig, it is created correctly:

ifconfig eth0:0 add 192.168.10.10

This can be verified by ifconfig or "ip a".

When I add an IPv6 address however, ifconfig seems to ignore the alias of the interface:

ifconfig eth0:0 add fc00::2/48

The address fc00::2/48 is added to eth0 then, not to eth0:0, no matter if eth0:0 previously exists with an IPv4 address or not.

I'm doing this on CentOS 5 but I guess it is a general behaviour of ifconfig? Am I doing something wrong or is this by intention? I'm using separate aliases for interfaces very often and I hoped to use it for IPv6 as well.

Kind regards Marten

share|improve this question
add comment

migrated from stackoverflow.com Sep 21 '12 at 2:14

This question came from our site for professional and enthusiast programmers.

1 Answer

This is intentional. The aliases were added because in IPv4 you could usually only have one IP address on an interface. The aliases were added to work around that. With IPv6 multiple addresses per interface are very normal so the aliases are not used anymore.

The ifconfig tool is not the easiest tool to manage this though. The ip tool makes this much easier.

This is how you show the current addresses:

# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN qlen 1000
    link/ether 00:0c:29:75:36:4e brd ff:ff:ff:ff:ff:ff
    inet 83.137.17.100/26 brd 83.137.17.127 scope global eth0
    inet6 2001:4038:0:16::16/64 scope global 
       valid_lft forever preferred_lft forever
    inet6 fe80::20c:29ff:fe75:364e/64 scope link 
       valid_lft forever preferred_lft forever

You can add an extra address like this:

# ip addr add 2001:db8::1/64 dev eth0

And it just shows up as one of the addresses in the list:

# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN qlen 1000
    link/ether 00:0c:29:75:36:4e brd ff:ff:ff:ff:ff:ff
    inet 83.137.17.100/26 brd 83.137.17.127 scope global eth0
    inet6 2001:db8::1/64 scope global 
       valid_lft forever preferred_lft forever
    inet6 2001:4038:0:16::16/64 scope global 
       valid_lft forever preferred_lft forever
    inet6 fe80::20c:29ff:fe75:364e/64 scope link 
       valid_lft forever preferred_lft forever
share|improve this answer
    
The point is, that I don't actually want to add and remove interfaces or IP addresses manually by calling ip or ifconfig. In RHEL or CentOS, you can have dozends of single files in /etc/sysconfig/network-scripts, each defining the configuration for one interfaces like eth0:24. On Ubuntu, you can add a line like "source interfaces.d/*" to /etc/network/interfaces with the same effect. That way you don't have to restart the whole network configuration to add or remove an IP address, but you can do it by adding or removing single interface definitions. –  Marten Lehmann Sep 19 '12 at 13:06
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.