What length can a network interface name have? What length can a network interface name have? windows windows

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 SLATEroot# ip link ls dev 123456789012345Device "123456789012345" does not exist.root# ip link ls dev 1234567890123456Device "1234567890123456" does not exist.# FAILroot# ip link add dev 1234567890123456 type dummyError: argument "1234567890123456" is wrong: "name" too longroot# ip link ls dev 1234567890123456Device "1234567890123456" does not exist.# PASSroot# ip link add dev 123456789012345 type dummyroot# ip link ls dev 12345678901234540: 123456789012345: <BROADCAST,NOARP> mtu 1500 qdisc noop state DOWN mode DEFAULT group default link/ether ... brd ff:ff:ff:ff:ff:ff# CLEAN UProot# 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.)


Also, if you want to use the interface with DHCP, the name must have length < 14, due to this issue:

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=858580