Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What length can a network interface name have?

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.

like image 349
Andrei Matei Avatar asked Jul 24 '14 11:07

Andrei Matei


People also ask

How are network interfaces named?

Network interface names are based on whether the interface is a physical or virtual network interface. Physical interfaces are assigned names based on the slot number of the adapter. Interface group names are user specified. VLANs are named by combining the interface name and VLAN ID.

What is Ethernet interface name?

Each network interface has a name. This usually consists of a few letters that relate to the type of interface, which may be followed by a number if there is more than one interface of that type. Examples might be lo (the loopback interface) and eth0 (the first Ethernet interface).


1 Answers

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.)

like image 130
CitizenB Avatar answered Sep 19 '22 13:09

CitizenB