linux网卡命名规则

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.rhkb.cn/news/74659.html

如若内容造成侵权/违法违规/事实不符,请联系长河编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

CentOS系统启动过程

CentOS系统启动流程图 &#xff08;1&#xff09; 加载 BIOS 计算机电源加电质检&#xff0c;首先加载基本输入输出系统&#xff08;Basic Input Output System&#xff0c;BIOS&#xff09;&#xff0c;BIOS 中包含硬件 CPU、内存、硬盘等相关信息&#xff0c;包含设备启动顺序…

kubernetes之Ingress

一、背景 Ingress是k8s中实现7层负载的实现方式&#xff0c;是公开集群外部流量到集群内服务的HTTP和HTTPS路由 二、Ingress基础 通常Ingress实现由Ingress 控制器和Ingress组成&#xff0c;Ingress控制器负责具体实现反向代理及负载均衡&#xff0c;Ingress负责定义匹配规则和…

线程池相关理论

什么是线程池 线程池是一种利用池化技术思想来实现的线程管理技术&#xff0c;主要是为了复用线程、便利地管理线程和任务、并将线程的创建和任务的执行解耦开来。我们可以创建线程池来复用已经创建的线程来降低频繁创建和销毁线程所带来的资源消耗。在JAVA中主要是使用Thread…

谐波失真(HD)

某一固定信号经过电子元器件后会出现谐波信号&#xff0c;在现实世界中&#xff0c;渴望都是线性的系统。比如&#xff1a;某个信号经过运算放大器放大&#xff0c;理想情况下不应该出现其他谐波信号&#xff0c;但实际上有谐波信号出现&#xff0c;HD(harmonic distortion)在一…

LNMP搭建

LNMP LNMP是目前成熟的企业网站的应用模式之一&#xff0c;指的是一套协同工作的系统和相关软件&#xff0c;能够提供静态页面服务&#xff0c;也可以提供动态Web服务。 LNMP四个字母分别代表的意思&#xff1a; L&#xff1a;Linux系统&#xff0c;操作系统 N&#xff1a;…

jenkins gitlab多分支构建发布

内容背景介绍 这个是新手教程,普及概念为主 公司现在还使用单分支发布测试环境和生产,多人协同开发同一个项目导致测试环境占用等待等情况 测试环境占用等待问题 测试环境代码直接合并到 master,容易导致误发布到生产的情况 避免多版本同时发布测试不完善的情况出现 中间件…

17. Spring 事务

目录 1. 事务定义 2. MySQL 中的事务使用 3. 没有事务时的插入 4. Spring 编程式事务 5. Spring 声明式事务 5.1 Transactional 作用范围 5.2 Transactional 参数说明 5.3 Transactional 工作原理 1. 事务定义 将⼀组操作封装成一个执行单元&#xff08;封装到一起…

Java基础面试题1

Java基础面试题 一、面向对象和集合专题 1. 面向对象和面向过程的区别 面向过程&#xff1a;是分析解决问题的步骤&#xff0c;然后用函数把这些步骤一步一步地实现&#xff0c;然后在使用的时候一一调用则可。性能较高&#xff0c;所以单片机、嵌入式开发等一般采用面向过程…

【C++】开源:matplotlib-cpp静态图表库配置与使用

&#x1f60f;★,:.☆(&#xffe3;▽&#xffe3;)/$:.★ &#x1f60f; 这篇文章主要介绍matplotlib-cpp图表库配置与使用。 无专精则不能成&#xff0c;无涉猎则不能通。——梁启超 欢迎来到我的博客&#xff0c;一起学习&#xff0c;共同进步。 喜欢的朋友可以关注一下&…

AI 绘画Stable Diffusion 研究(五)sd文生图功能详解(下)

大家好&#xff0c;我是风雨无阻。 上一篇文章详细介绍了sd文生图的功能及使用注意事项&#xff0c;感兴趣的朋友可以前往查看&#xff1a;AI 绘画Stable Diffusion 研究&#xff08;四&#xff09;sd文生图功能详解&#xff08;上&#xff09; 。 那今天这篇文章&#xff0c;我…

一文学透设计模式

设计模式是什么&#xff1f; 设计模式是软件开发人员在软件开发过程中面临的一般问题的解决方案&#xff0c;代表了解决一些问题的最佳实践。这些解决方案是众多软件开发人员经过相当长的一段时间的试验和错误总结出来的。 说白了&#xff0c;设计模式对于软件开发人员来说就…

VSCode和QT联合开发

提示&#xff1a;本文为学习记录&#xff0c;若有错误&#xff0c;请联系作者&#xff0c;谦虚受教。 文章目录 前言一、VSCODE下载二、使用步骤1.下载扩展 二、新建工程1.新建文件夹2.新建工程3.UI界面文件操作4.效果 总结 前言 一、VSCODE下载 下载地址 二、使用步骤 1.下…

【Web开发指南】如何用MyEclipse进行JavaScript开发?

由于MyEclipse中有高级语法高亮显示、智能内容辅助和准确验证等特性&#xff0c;进行JavaScript编码不再是一项繁琐的任务。 MyEclipse v2023.1.2离线版下载 JavaScript项目 在MyEclipse 2021及以后的版本中&#xff0c;大多数JavaScript支持都是开箱即用的JavaScript源代码…

瑞吉外卖实战-笔记

软件开发的流程 角色分工 软件环境 开发环境的搭建 数据库环境 maven环境 1.创建完成后&#xff0c;需要检查一下编码、maven仓库、jdk等 <parent><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</a…

牛客网Verilog刷题——VL42

牛客网Verilog刷题——VL42 题目答案 题目 请设计一个可以实现任意小数分频的时钟分频器&#xff0c;比如说8.7分频的时钟信号&#xff0c;注意rst为低电平复位。提示&#xff1a;其实本质上是一个简单的数学问题&#xff0c;即如何使用最小公倍数得到时钟周期的分别频比。设小…

Redis系列二:Clion+MAC+Redis环境搭建

1. ClionMACRedis-3.0-annotated环境搭建 参考&#xff1a; https://github.com/huangz1990/redis-3.0-annotated https://gitee.com/dumpcao/redis-3.0-annotated-cmake-in-clion https://tool.4xseo.com/a/12910.html 1.1 下载并导入Clion git clone https://gitee.com/dum…

链表的总体涵盖以及无哨兵位单链表实现——【数据结构】

&#x1f60a;W…Y&#xff1a;个人主页 在学习之前看一下美丽的夕阳&#xff0c;也是很不错的。 如果觉得博主的美景不错&#xff0c;博客也不错的话&#xff0c;关注一下博主吧&#x1f495; 在上一期中&#xff0c;我们说完了顺序表&#xff0c;并且提出顺序表中的问题 1. 中…

腾讯云TencentOS Server镜像系统常见问题解答

腾讯云TencentOS Server镜像是腾讯云推出的Linux操作系统&#xff0c;完全兼容CentOS生态和操作方式&#xff0c;TencentOS Server操作系统为云上运行的应用程序提供稳定、安全和高性能的执行环境&#xff0c;TencentOS可以运行在腾讯云CVM全规格实例上&#xff0c;包括黑石物理…

[golang gin框架] 40.Gin商城项目-微服务实战之Captcha验证码微服务

本次内容需要 gin框架基础知识, golang微服务基础知识才能更好理解 一.Captcha验证码功能引入 在前面,讲解了微服务的架构等,这里,来讲解前面商城项目的 Captcha验证码 微服务 ,captcha验证码功能在前台,后端 都要用到 ,可以把它 抽离出来 ,做成微服务功能 编辑 这个验证码功能…

echars力引导关系图

效果图 力引导关系图 力引导布局是模拟弹簧电荷模型在每两个节点之间添加一个斥力&#xff0c;每条边的两个节点之间添加一个引力&#xff0c;每次迭代节点会在各个斥力和引力的作用下移动位置&#xff0c;多次迭代后节点会静止在一个受力平衡的位置&#xff0c;达到整个模型…