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
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.eth0
orem1
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 theman
pages in Ubuntu are equally outdated as the ominous tutorials you're referring to (which I haven't seen).