I need to adjust some database tables in order to accommodate 50+ character long network interface names. I wonder if there is a standard on how long an interface name can be, so I can map it correctly.
Asked
Active
Viewed 2.5k times
35
-
3If you look at: http://msdn.microsoft.com/en-us/library/windows/desktop/aa366062%28v=vs.85%29.aspx it seems like an adapter name could have a max length of 256 characters. – Cyclonecode Jul 24 '14 at 11:19
-
1It seams 16 chars is correct of some flavors of Linux (tested on Centos 5), but not sure for the rest. I need to support both win/unix. – Andrei Matei Jul 24 '14 at 11:50
-
In that case I would go for 256 characters which seems to support both linux and windows. – Cyclonecode Jul 24 '14 at 11:58
2 Answers
45
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.)

Digital Trauma
- 15,475
- 3
- 51
- 83

CitizenB
- 849
- 8
- 9
-
2See also: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=704072 (Linux DHCP client has problems if device name has 14 or more characters and the `ip` command fails if device name has 16 or more characters.) – Mikko Rantalainen Feb 17 '21 at 11:02
9
Also, if you want to use the interface with DHCP, the name must have length < 14, due to this issue:

jonseymour
- 1,006
- 1
- 12
- 22
-
1That has allegedly been fixed in 2015, in version `4.3.2-1`, at least according to https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=704072. – András Korn Jul 27 '21 at 10:20