Hello,
johns...@gmail.com a ᅵcrit :
>
> I tried:
> ip link set em1 alias myalias
> and
> cat /sys/class/net/em1/ifalias
> gives:
> myalias
>
> I also tried:
> ifconfig p2p1:0 1.2.3.4
> but:
> cat /sys/class/net/p2p1/ifalias
> gives nothing.
>
> what is the difference between the two ?
/sys/class/net/p2p1/ifalias contains an arbitrary text attribute
associated to the network interface p2p1. AFAIK, it cannot be used as an
interface name by commands such as ifconfig or ip.
p2p1:0 is a label associated to a specific IPv4 address assigned to
p2p1, sometimes referred to as "IP alias". Note "IP", not "interface".
"ip addr" shows it in the line containing that IPv4 address. Labels are
a legacy from old times and are not supported for IPv6 address. It can
be used as an interface name by ifconfig to refer to the associated IPv4
address or by ip but then it refers to the whole interface, not just the
associated address (ip seems to strip the :* part).
> is there a way that I will set an alias with
> ifconfig so I will see it in /sys/class/net/em1/ifalias?
I don't think so. These are two completely different unrelated things.