Code directly!
#! /Bin/sh
[-F/etc/init. d/functions] &./etc/init. d/functions
### Modify the Nic configuration file name
Function net (){
B0 =-1
Cat/proc/net/dev | grep ':' | grep-v 'Lo' | cut-d:-f1 | sort>/tmp/net_name.txt
Do
C0 = $ line
B0 = 'expr $ b0 + 1'
Mv/etc/sysconfig/network-scripts/ifcfg-$ c0/etc/sysconfig/network-scripts/ifcfg-eth $ b0
# Change the Nic mode to static
Sed-I's/dhcp/static/g'/etc/sysconfig/network-scripts/ifcfg-eth $ b0
# Delete a row containing IPV6
Sed-I '/IPV6/D'/etc/sysconfig/network-scripts/ifcfg-eth $ b0
# Change the Nic DEVICE to eth.
Sed-I's/'$ c0'/eth '$ b0'/g'/etc/sysconfig/network-scripts/ifcfg-eth $ b0
Done </tmp/net_name.txt
}
### Reconfigure grub and update the kernel
Function grub (){
Sed-I's/crashkernel = auto rhgb quiet/crashkernel = auto net. ifnames = 0 biosdevname = 0 rhgb quiet/g'/etc/default/grub
Grub2-mkconfig-o/boot/grub2/grub. cfg
}
### Modifying the naming rules for Nic creation
Function rules (){
B0 =-1
/Sbin/lspci | awk '/net/|/less/{print $1}' | sort | while read line
Do
C0 = $ line
B0 = 'expr $ b0 + 1'
Echo 'action = "add", SUBSYSTEM = "net", BUS = "pci", ID = "0000: '$ c0 '", NAME = "eth '$ b0'"'>/etc/udev/rules. d/70-persistent-net.rules
Done
}
Net
Grub
Rules
The above is a shell code that can quickly modify the name of the NIC. I hope the article will help you.