linux网卡命名规则

news2024/9/21 22:42:37

Consistent Network Device Naming

Linux provides methods for consistent(一致) and predictable(可预测) network device naming for network interfaces.

These features change the name of network interfaces on a system in order to make locating

and differentiating the interfaces easier.

Traditionally, network interfaces in Linux are enumerated(枚举) as eth[0123]s0, but these names do

not necessarily correspond to actual labels on the chassis.

Modern server platforms with multiple network adapters can encounter non-deterministic(遇到不确定)

and counter-intuitive(反直觉) naming of these interfaces.

This affects both network adapters embedded on the motherboard (Lan-on-Motherboard, or LOM) and

add-in (single and multiport) adapters.

In Linux, udev supports a number of different naming schemes.

The default is to assign fixed names based on firmware, topology(拓扑), and location information.

This has the advantage that the names are fully automatic, fully predictable, that they stay fixed even if hardware

 is added or removed (no re-enumeration takes place), and that broken hardware can be replaced seamlessly(无缝更换).

The disadvantage is that they are sometimes harder to read than the eth or wla names traditionally used.

For example: enp5s0.

Naming Schemes Hierarchy

By default, systemd will name interfaces using the following policy to apply the supported naming schemes:

Scheme 1:  Names incorporating ( 结合 ) Firmware or BIOS provided index numbers for on-board devices (example:  eno1 ),
are applied if that information from the firmware or BIOS is applicable and available, else falling back to scheme 2.
Scheme 2:  Names incorporating Firmware or BIOS provided PCI Express hotplug slot index numbers (example:  ens1 )
are applied if that information from the firmware or BIOS is applicable and available, else falling back to scheme 3.
Scheme 3:  Names incorporating physical location of the connector of the hardware (example:  enp2s0 ),
are applied if applicable, else falling directly back to scheme 5 in all other cases.
Scheme 4:  Names incorporating interface's MAC address (example:  enx78e7d1ea46da ), is not used by default,
but is available if the user chooses.
Scheme 5:  The traditional unpredictable kernel naming scheme, is used if all other methods fail (example:  eth0 ).

Understanding the Device Renaming Procedure

The device name procedure in detail is as follows:

1. A rule in  /usr/lib/udev/rules.d/60-net.rules 
2. A rule in  /usr/lib/udev/rules.d/71-biosdevname.rules

3.A rule in /lib/udev/rules.d/75-net-description.rules

4.A rule in /usr/lib/udev/rules.d/80-net-name-slot.rules 

Understanding the Predictable Network Interface Device Names

The names have two-character prefixes based on the type of interface:

1. en  for Ethernet,
2. wl  for wireless LAN (WLAN),
3. ww  for wireless wide area network (WWAN).

The names have the following types:

o<index>

on-board device index number

s<slot>[f<function>][d<dev_id>]

hotplug slot index number. All multi-function PCI devices will carry the [f<function>] number in the device name, including the function 0 device.

x<MAC>

MAC address

[P<domain>]p<bus>s<slot>[f<function>][d<dev_id>]

PCI geographical location. In PCI geographical location, the [P<domain>] number is only mentioned if the value is not 0. For example:

ID_NET_NAME_PATH=P1enp5s0

[P<domain>]p<bus>s<slot>[f<function>][u<port>][..][c<config>][i<interface>]

USB port number chain. For USB devices, the full chain of port numbers of hubs is composed. If the name gets longer than the maximum number of 15 characters, the name is not exported. If there are multiple USB devices in the chain, the default values for USB configuration descriptors (c1) and USB interface descriptors (i0) are suppressed.

Naming Scheme for VLAN Interfaces

Traditionally, VLAN interface names in the format: interface-name.VLAN-ID are used. The VLAN-ID ranges from 0 to 4096,

 which is a maximum of four characters and the total interface name has a limit of 15 characters.

The maximum interface name length is defined by the kernel headers and is a global limit, affecting all applications.

In Linux , four naming conventions(习惯) for VLAN interface names are supported:

VLAN plus VLAN ID

The word vlan plus the VLAN ID. For example: vlan0005

VLAN plus VLAN ID without padding

The word vlan plus the VLAN ID without padding by means of additional leading zeros. For example: vlan5

Device name plus VLAN ID

The name of the parent interface plus the VLAN ID. For example: enp1s0.0005

Device name plus VLAN ID without padding

The name of the parent interface plus the VLAN ID without padding by means of additional leading zeros. For example: enp1s0.5

 

Consistent Network Device Naming Using biosdevname

The biosdevname program uses information from the system's BIOS, specifically the type 9 (System Slot) and type 41 (Onboard Devices Extended Information) fields contained within the SMBIOS. If the system's BIOS does not have SMBIOS version 2.6 or higher and this data, the new naming convention will not be used. Most older hardware does not support this feature because of a lack of BIOSes with the correct SMBIOS version and field information. For BIOS or SMBIOS version information, contact your hardware vendor;

Install:yum install bisodevname

Boot command:

Disbale:biosdevname=0

Enable:biosdevname=1

 

Controlling the Selection of Network Device Names

Device naming can be controlled in the following manner(方式):

By identifying the network interface device

Setting the MAC address in an ifcfg file using the HWADDR directive enables it to be identified by udev.

The name will be taken from the string given by the DEVICE directive, which by convention is

the same as the ifcfg suffix. For example, ifcfg-enp1s0.

By turning on or off biosdevname

The name provided by biosdevname will be used (if biosdevname can determine one).

By turning on or off the systemd-udev naming scheme

The name provided by systemd-udev will be used (if systemd-udev can determine one).

rules file introduction

60-net.rules

/lib/udev/rename_device, to look into all /etc/sysconfig/network-scripts/ifcfg-suffix files. If it finds an ifcfg file with a HWADDR entry

matching the MAC address of an interface it renames the interface to the name given in the ifcfg file by the DEVICE directive

 

71-biosdevname.rules

biosdevname to rename the interface according

to its naming policy, provided that it was not renamed in a previous step, biosdevname is installed,

and biosdevname=0 was not given as a kernel command on the boot command line.

75-net-dscription.rules

udev to fill in the internal udev device property

values ID_NET_NAME_ONBOARD, ID_NET_NAME_SLOT, ID_NET_NAME_PATH, ID_NET_NAME_MAC by examining

the network interface device. Note, that some device properties might be undefined.

 80-net-name-slot.rules

udev to rename the interface, provided that

it was not renamed in step 1 or 2, and the kernel parameter net.ifnames=0 was not given, according to the

following priority: ID_NET_NAME_ONBOARD, ID_NET_NAME_SLOT, ID_NET_NAME_PATH. It falls through to the

next in the list, if one is unset. If none of these are set, then the interface will not be renamed.

 80-net-setup-link.rules

If NAME is empty and ID_NET_NAME is not empty use ID_NET_NAME

udev 网卡rename 

1.新建文件,数字越大越后面执行

sudo nano /etc/udev/rules.d/99-persistent-net.rules

2.根据MAC地址重命名

SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="00:11:22:33:44:55", NAME="eth0“

3.根据BDF重命名

ACTION=="add", SUBSYSTEM=="net", KERNELS=="0000:15:00.0", NAME="eth0"

4重新生效

sudo udevadm control --reload-rules

reboot

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/815354.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

Java8实战-总结9

Java8实战-总结9 Lambda表达式把Lambda付诸实践&#xff1a;环绕执行模式第1步&#xff1a;记得行为参数化第2步&#xff1a;使用函数式接口来传递行为第3步&#xff1a;执行一个行为第4步&#xff1a;传递Lambda 使用函数式接口PredicateConsumerFunction原始类型特化 Lambda表…

mybatis plus 的一些使用

简介 官网&#xff1a;http://mp.baomidou.com/ 参考教程&#xff1a;https://baomidou.com/pages/24112f/ MyBatis-Plus&#xff08;简称 MP&#xff09;是一个 MyBatis 的增强工具&#xff0c;在 MyBatis 的基础上只做增强不做改变&#xff0c;为简化开发、提高效率而生。 …

web前端框架Javascript之JavaScript 异步编程史

早期的 Web 应用中&#xff0c;与后台进行交互时&#xff0c;需要进行 form 表单的提交&#xff0c;然后在页面刷新后给用户反馈结果。在页面刷新过程中&#xff0c;后台会重新返回一段 HTML 代码&#xff0c;这段 HTML 中的大部分内容与之前页面基本相同&#xff0c;这势必造成…

同样是跨端框架,React会不会被VUE取代?

看到知乎上有比较多的类似问题&#xff0c;正好这两个框架在以往的一些项目中都有实践过&#xff0c;就借着本篇文章说说我个人的看法。 先摆个结论&#xff1a;不会&#xff0c;毕竟各有千秋&#xff0c;除非跨端框架有被更好的概念所替代&#xff0c;又或者App已经彻底过气了…

PoseiSwap:通过 RWA 的全新叙事,反哺 Nautilus Chain 生态

PoseiSwap 是 Nautilus Chain 上的首个 DEX&#xff0c;作为目前行业内模块化区块链叙事的早期奉行者&#xff0c;PoseiSwap 也得到了较高的市场关注。基于 Nautilus Chain&#xff0c;PoseiSwap 打造了一个全新的 Rollup 应用层&#xff0c;并通过零知识证明来建立全新的订单簿…

6个月、21天,GoldenDB分布式数据库核心系统落地中移动

近日&#xff0c;2023“鼎新杯”数字化转型应用大赛入围名单公示&#xff0c;山东移动基于GoldenDB分布式数据库的CRM&BOSS核心系统自主创新实践成功入选。该项目是中兴通讯与中国移动在数据库关键领域的又一个合作范例。 核心系统业务量大&#xff0c;分布式转型迫在眉睫 …

C语言指针进阶-1

本篇文章带来 1. 字符指针 2. 数组指针 3. 指针数组的相关知识详细讲解&#xff01; 如果您觉得文章不错&#xff0c;期待你的一键三连哦&#xff0c;你的鼓励是我创作的动力之源&#xff0c;让我们一起加油&#xff0c;一起奔跑&#xff0c;让我们顶峰相见&#xff01;&#…

Qt信号与槽机制的本质

引入 对象与对象之间的通信有多个方式&#xff0c;如果我们要提供一种对象之间的通信机制。这种机制&#xff0c;要能够给两个不同对象中的函数建立映射关系&#xff0c;前者被调用时后者也能被自动调用。 再深入一些&#xff0c;两个对象如果都互相不知道对方的存在&#xff…

229. 多数元素 II

229. 多数元素 II 原题链接&#xff1a;完成情况&#xff1a;解题思路&#xff1a;参考代码&#xff1a; 原题链接&#xff1a; 229. 多数元素 II https://leetcode.cn/problems/majority-element-ii/description/ 完成情况&#xff1a; 解题思路&#xff1a; 我们用哈希统…

想学嵌入式开发,薪资怎么样?

对于嵌入式工程师来说呢&#xff0c;它重点学习内容就是首先一定要打好基础&#xff0c;如果从编程语言角度来讲&#xff0c;那么可以在语言上选C或者C&#xff0c;你可以选择其中任何一门语言作为你的入门。当然从入门角度来讲&#xff0c;其实C语言要比C要容易一些&#xff0…

flag{网鼎杯之java代码审计入门} - file-in-java[ctf]

一、赛题截图 二、接口测试 我们先上传文件抓包&#xff0c;发送到repeter 响应如下 我们使用下载接口去下载一个不存在的文件&#xff0c;回显“资源被删除” - 说明系统可能去查找了这个文件&#xff0c;那我们能不能去下载/etc/passwd文件&#xff0c;但是还不知道相对…

HTML5中的data-*属性

介绍&#xff1a; data-*全局属性是一类被称为自定义数据属性的属性&#xff0c;它赋予我们在所有 HTML 元素上嵌入自定义数据属性的能力。 data-*的使用 <div class"child" data-name"小红" data-age"18"></div> 在js里有两种获…

无涯教程-jQuery - height( val )方法函数

height(val)方法设置每个匹配元素的CSS高度。 height( val ) - 语法 selector.height( val ) 这是此方法使用的所有参数的描述- val - 这是元素的高度。如果未指定任何显式单位(如em或&#xff05;)&#xff0c;则将" px"连接到该值。 height( val ) - 示例…

Xshell使用是出现全黑或全白问题

Xshell使用是出现全黑或全白问题&#xff0c;这是我实际遇到的问题如图。 解决方式&#xff1a; 设置字体 解决成功&#xff1a;

uniapp uni-combox 下拉提示无匹配项(完美解决--附加源码解决方案及思路)

问题描述 匆匆忙忙又到了周一啦&#xff0c;一大早就来了一个头疼的问题&#xff0c;把我难得团团转&#xff0c;呜呜呜~ 下面我用代码的方式展示出来&#xff0c;看下你的代码是否与我的不同。 解决方案 <uni-forms-item label"名称" name"drugName&quo…

Mybatis-plus集合

目录 mybatis-plus集合1、简介2、特性3、开始使用4、QueryWrapper的使用5、补充 mybatis-plus集合 1、简介 MyBatis-Plus &#xff08;简称 MP&#xff09;是一个 MyBatis的增强工具&#xff0c;在 MyBatis 的基础上只做增强不做改变&#xff0c;为简化开发、提高效率而生。 m…

八股文的天花板,没到 35k 的 Java 开发都值得好好读一读

确实&#xff0c;在当下行情之下&#xff0c;还能保持“有恃无恐”的人&#xff0c;那他自身肯定得有两把刷子。 谁不想当一个“技术大牛”&#xff1f; 谁不想年纪轻轻就“年薪百万”&#xff1f; 但“梦想美好&#xff0c;现实残酷”&#xff0c;不少人实际工作中做的事&a…

C#中 使用yield return 优化大数组或集合的访问

概要 我们在开发过程中&#xff0c;经常需要在一个很大的数组或集合中搜索元素&#xff0c;以满足业务需求。 本文主要介绍通过使用yield return的方式&#xff0c;避免将大量数据全部加载进入内存&#xff0c;再进行处理。从而提高程序的性能。 设计和实现 基本业务场景&a…

如何压缩MP4视频?学会这样压缩很简单

怎么压缩MP4视频大小呢&#xff1f;如果需要将视频存储在手机或平板电脑等设备上&#xff0c;通常也需要将视频大小压缩到适当的大小&#xff0c;以节省存储空间。此时&#xff0c;可以根据设备的存储容量和需要存储的其他文件来选择视频压缩的大小。很多小伙伴不知道怎么压缩视…

24考研数据结构-第三章:栈和队列

目录 第三章 栈和队列3.1栈&#xff08;stack&#xff09;3.1.1栈的基本概念栈的基本概念知识回顾 3.1.2 栈的顺序存储上溢与下溢栈的顺序存储知识回顾 3.1.3栈的链式存储链栈的基本操作 3.2队列&#xff08;Queue&#xff09;3.2.1队列的基本概念3.2.2队列的顺序存储结构3.2.2…