CentOS7 modify network card name and network repair

CentOS7 modify network card name##

# Switch to the network card configuration directory
cd /etc/sysconfig/network-scripts/
# Copy the network card configuration file to ifcfg-eth0
cp -a ifcfg-ens33 ifcfg-eth0
# Back up the original file to the opt directory
mv ifcfg-ens33 /opt/
# View all files in the current directory
[ root@localhost network-scripts]# ls
ifcfg-eth0   ifdown-ipv6    ifdown-TeamPort  ifup-ippp   ifup-routes       network-functions
ifcfg-lo     ifdown-isdn    ifdown-tunnel    ifup-ipv6   ifup-sit          network-functions-ipv6
ifdown       ifdown-post    ifup             ifup-isdn   ifup-Team
ifdown-bnep  ifdown-ppp     ifup-aliases     ifup-plip   ifup-TeamPort
ifdown-eth   ifdown-routes  ifup-bnep        ifup-plusb  ifup-tunnel
ifdown-ib    ifdown-sit     ifup-eth         ifup-post   ifup-wireless
ifdown-ippp  ifdown-Team    ifup-ib          ifup-ppp    init.ipv6-global
root@localhost network-scripts]# vim ifcfg-eth0 #Modify the configuration file
TYPE="Ethernet"
PROXY_METHOD="none"
BROWSER_ONLY="no"
BOOTPROTO="static"     #Connection mode (static/dhcp)
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="eth0"        #Network card name, centos7 defaults to ens33
UUID="453ef40b-c53f-44d1-a677-d1aa1817c111"
DEVICE="eth0"    #Device name, centos7 defaults to ens33
ONBOOT="yes"    #Whether to load
IPADDR=192.168.233.99     #Static ip address
GATEWAY=192.168.233.2     #Gateway
NETMASK=255.255.255.0    #The writing method of subnet mask centos7 (PREFIX=24)
DNS1=180.76.76.76        #Primary DNS
DNS2=124.251.124.251    #Backup DNS
[ root@localhost ~]# source /etc/sysconfig/network-scripts/ifcfg-eth0 
[ root@localhost ~]# cat /etc/resolv.conf 
# Generated by NetworkManager
nameserver 180.76.76.76
nameserver 124.251.124.251
# Modify the grub file (turn off the consistent naming rule), commonly known as the automatic discovery function
root@localhost network-scripts]# cd /etc/default/[root@localhost default]# ls
grub  nss  useradd
[ root@localhost default]# vim grub 
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="crashkernel=auto rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet net.ifnames=0 biosdevname=0" 
# Add net in double quotes.ifnames=0 biosdevname=0
GRUB_DISABLE_RECOVERY="true"
[ root@localhost default]# grub2-mkconfig -o /boot/grub
grub/  grub2/[root@localhost default]# grub2-mkconfig -o /boot/grub2/grub
grub.cfg  grubenv
# Update the grub configuration file and load the new parameters
[ root@localhost default]# grub2-mkconfig -o /boot/grub2/grub.cfg 
Generating grub configuration file ...
Found linux image:/boot/vmlinuz-3.10.0-862.el7.x86_64
Found initrd image:/boot/initramfs-3.10.0-862.el7.x86_64.img
Found linux image:/boot/vmlinuz-0-rescue-ab4dc40e801c4059bf95d9a36e28d173
Found initrd image:/boot/initramfs-0-rescue-ab4dc40e801c4059bf95d9a36e28d173.img
done
[ root@localhost default]# 
reboot #Restart the system
# After restarting the system, the network card name has been changed to eth0
[ root@localhost ~]# ip address show
1: lo:<LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
 inet 127.0.0.1/8 scope host lo
  valid_lft forever preferred_lft forever
 inet6 ::1/128 scope host 
  valid_lft forever preferred_lft forever
2: eth0:<BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
 link/ether 00:0c:29:cc:e1:91 brd ff:ff:ff:ff:ff:ff
 inet 192.168.233.99/24 brd 192.168.233.255 scope global noprefixroute eth0
  valid_lft forever preferred_lft forever
 inet6 fe80::8d56:af45:bfeb:db65/64 scope link noprefixroute 
  valid_lft forever preferred_lft forever
3: virbr0:<NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default qlen 1000
 link/ether 52:54:00:aa:fa:dd brd ff:ff:ff:ff:ff:ff
 inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0
  valid_lft forever preferred_lft forever
4: virbr0-nic:<BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast master virbr0 state DOWN group default qlen 1000
 link/ether 52:54:00:aa:fa:dd brd ff:ff:ff:ff:ff:ff
[ root@localhost ~]# 

Road Repair Network##

root@localhost network-scripts]# nmcli connection delete eth0
Connection 'eth0'(453ef40b-c53f-44d1-a677-d1aa1817c111) successfully deleted.
[ root@localhost network-scripts]# nmcli connection add con-name eth666 type ethernet ifname eth0 autoconnect yes 
Connection 'eth666'(577dc8f5-8efa-40a3-8ecf-b2a134e2e405) successfully added.
[ root@localhost network-scripts]# nmcli connection show 
NAME                UUID                                  TYPE      DEVICE 
Wired connection 101806e22-d18f-3434-9d4e-757711fa509a  ethernet  eth0   
virbr0              f749af6e-b9aa-4f29-a100-4a86e68724d7  bridge    virbr0 
eth666              577dc8f5-8efa-40a3-8ecf-b2a134e2e405  ethernet  --
[ root@localhost network-scripts]# nmcli connection modify eth666 ipv4.method auto 
[ root@localhost network-scripts]# cat ifcfg-eth666 
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=dhcp
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=eth666
UUID=577dc8f5-8efa-40a3-8ecf-b2a134e2e405
DEVICE=eth0
ONBOOT=yes
[ root@localhost network-scripts]# 
[ root@localhost network-scripts]# ping allms.cn
PING allms.cn.localdomain(115.159.76.237)56(84) bytes of data.64 bytes from115.159.76.237(115.159.76.237): icmp_seq=1 ttl=128 time=54.8 ms
64 bytes from115.159.76.237(115.159.76.237): icmp_seq=2 ttl=128 time=54.4 ms
64 bytes from115.159.76.237(115.159.76.237): icmp_seq=3 ttl=128 time=64.9 ms
64 bytes from115.159.76.237(115.159.76.237): icmp_seq=4 ttl=128 time=55.3 ms
64 bytes from115.159.76.237(115.159.76.237): icmp_seq=5 ttl=128 time=55.7 ms
64 bytes from115.159.76.237(115.159.76.237): icmp_seq=6 ttl=128 time=55.0 ms
64 bytes from115.159.76.237(115.159.76.237): icmp_seq=7 ttl=128 time=55.5 ms
64 bytes from115.159.76.237(115.159.76.237): icmp_seq=8 ttl=128 time=62.8 ms
64 bytes from115.159.76.237(115.159.76.237): icmp_seq=9 ttl=128 time=54.9 ms
64 bytes from115.159.76.237(115.159.76.237): icmp_seq=10 ttl=128 time=55.3 ms
64 bytes from115.159.76.237(115.159.76.237): icmp_seq=11 ttl=128 time=55.2 ms
64 bytes from115.159.76.237(115.159.76.237): icmp_seq=12 ttl=128 time=54.4 ms
64 bytes from115.159.76.237(115.159.76.237): icmp_seq=13 ttl=128 time=119 ms
64 bytes from115.159.76.237(115.159.76.237): icmp_seq=14 ttl=128 time=55.2 ms
64 bytes from115.159.76.237(115.159.76.237): icmp_seq=15 ttl=128 time=469 ms
^ C
- - - allms.cn.localdomain ping statistics ---15 packets transmitted,15 received,0% packet loss, time 14027ms
rtt min/avg/max/mdev =54.440/88.190/469.652/103.181 ms
[ root@localhost network-scripts]# 

Recommended Posts

CentOS7 modify network card name and network repair
CentOS7 modify the network card name
Centos7 change the network card name
Centos7.6 dual network card configuration and switching test
CentOS8 network card configuration file
Centos7 configuration host name and IP address
VMware Fusion install CentOS7 and configure the network
CentOS7.0 network configuration
CentOS 7.0 network configuration
CentOS6.5 network settings
Modify CentOS hostname
IP and network settings of CentOS Linux 7 VMware
Tencent cloud centos 8.0 single network card configuration multiple IP
Vmware-install and start Centos 8
Vmware-install and start Centos 7
Ubuntu 18.04 network card configuration
CentOS 7 network settings --- connectivity
Set the network card to bridge mode under CentOS6.3 KVM
How to support TL-WDN7200H wireless USB network card in CentOS8?