What length can a network interface name have?

As far as the Linux-specific part of this, in recent kernel versions this is defined by IFNAMSIZ to be 16 bytes, so 15 user-visible bytes (assuming it includes a trailing null). IFNAMSIZ is used in defining struct net_device’s name field here.

In order to test empirically, you can use the following to see that 16 bytes fails and 15 bytes works:

# CLEAN SLATE
root# ip link ls dev 123456789012345
Device "123456789012345" does not exist.
root# ip link ls dev 1234567890123456
Device "1234567890123456" does not exist.

# FAIL
root# ip link add dev 1234567890123456 type dummy
Error: argument "1234567890123456" is wrong: "name" too long
root# ip link ls dev 1234567890123456
Device "1234567890123456" does not exist.

# PASS
root# ip link add dev 123456789012345 type dummy
root# ip link ls dev 123456789012345
40: 123456789012345: <BROADCAST,NOARP> mtu 1500 qdisc noop state DOWN mode DEFAULT group default 
link/ether ... brd ff:ff:ff:ff:ff:ff

# CLEAN UP
root# ip link del dev 123456789012345

(Assuming you have ip from the iproute2 package installed, as is likely on any Linux distribution from within the last decade or so.)

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)