What is the allowed range of characters in Linux network interfaces names? I've searched around but did not find any definition or clarification. Are uppercase characters allowed? Are uppcase and lowercase letters different?
-
1See also lists.gt.net/linux/kernel/1987417Stéphane Chazelas– Stéphane Chazelas2018-06-22 18:56:09 +00:00Commented Jun 22, 2018 at 18:56
-
@Stéphane: interesting link!TheDiveO– TheDiveO2018-06-22 18:58:43 +00:00Commented Jun 22, 2018 at 18:58
-
Related - Network device name separatorsChris Davies– Chris Davies2018-06-24 19:30:54 +00:00Commented Jun 24, 2018 at 19:30
-
Related - unix.stackexchange.com/questions/677469/…Technophile– Technophile2022-10-11 15:52:04 +00:00Commented Oct 11, 2022 at 15:52
2 Answers
The iproute2 tools do the following checks for a valid interface name:
- The name must not be empty
- The name must be less than 16 (
IFNAMSIZ) characters - The name must not contain
/or any whitespace characters
Using upper-case and lower-case characters are OK and names are case sensitive (e.g. if0 and IF0 are distinct).
If you want more flexibility in names, you can set an alias using ip link DEV set alias .... This will appear in the output of ip link show.
Trying some experiments with such names as in ip link set XXX name test\\[]{}.,ä@€ (where XXX is the previous/original name of the network interface), it seems as if Linux will happily accept anything, as long as it is not an embedded \0.
So there don't seem to be any restrictions on what chars can be used, even with UTF-8 encoding you could store Unicode ... but then, not all tools might properly deal with UTF-8 but instead only see the byte soup.