CentOS7修改网卡名
CentOS 7, 或RHEL7
[1] https://www.redhat.com/sysadmin/network-interfaces-linux, The name game: Naming network interfaces in Linux
可以使用nameif, ifrename, ip; centos7上没找到ifrename; nameif根据mac命令; 试过ip, 提示Resource Busy.
[2] http://www.mit.edu/afs.new/sipb/project/merakidev/src/openwrt-meraki/openwrt/build_mips/wireless_tools.28/IFRENAME-VS-XXX.txt
比较了各种方法, 没有操作步骤
[3] 11.2. Understanding the Device Renaming Procedure Red Hat Enterprise Linux 7 | Red Hat Customer Portal
[4] https://www.cyberciti.biz/faq/howto-linux-rename-ethernet-devices-named-using-udev/
我的系统中没有找到/etc/udev/rules.d/70-persistent-net.rules
下面操作根据规则60-net.rules[3]:
A rule in /usr/lib/udev/rules.d/60-net.rules instructs the udev helper utility, /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.
cd /etc/sysconfig/network-scripts/ cp ifcfg-old ifcfg-new ifconfig -a | grep ether # 获取hwaddr vi ifcfg-new # 把DEVICE和NAME改为'new', 添加HWADDR="11:22:...."
如
# cat ifcfg-em0 TYPE="Ethernet" PROXY_METHOD="none" BROWSER_ONLY="no" BOOTPROTO="static" DEFROUTE="yes" IPV4_FAILURE_FATAL="no" IPV6INIT="yes" IPV6_AUTOCONF="yes" IPV6_DEFROUTE="yes" IPV6_FAILURE_FATAL="no" IPV6_ADDR_GEN_MODE="stable-privacy" NAME="em0" UUID="721603be-3ee4-4f93-af05-a3c6eb4cfef0" DEVICE="em0" ONBOOT="yes" IPADDR="172.16.56.103" PREFIX="24" GATEWAY="172.16.56.1" IPV6_PRIVACY="no" HWADDR="00:15:5d:8c:01:06"
重启系统.
有没有不需要重启系统的办法? todo
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· winform 绘制太阳,地球,月球 运作规律
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· AI与.NET技术实操系列(五):向量存储与相似性搜索在 .NET 中的实现
· 超详细:普通电脑也行Windows部署deepseek R1训练数据并当服务器共享给他人
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理