Ubuntu 20.04 修改网卡名称为eth0

查看当前网卡名称

daily@jenkins:~$ ip a
1: lo:  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: enp2s0:  mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 00:e0:4c:21:cc:2d brd ff:ff:ff:ff:ff:ff
    inet 192.168.60.64/24 brd 192.168.60.255 scope global dynamic enp2s0
       valid_lft 2591937sec preferred_lft 2591937sec
    inet6 fe80::2e0:4cff:fe21:cc2d/64 scope link
       valid_lft forever preferred_lft forever

如上,中:
en表示ethernet以太网
PCI接口的物理位置的坐标(bus, slot),其中bus表示总线,slot表示插槽。
所以:
enp2s0表示,Etnernet PCI接口位置:bus=2, slot=0。

修改步骤1:
sudo vi /etc/default/grub
GRUB_CMDLINE_LINUX=""
修改为:
GRUB_CMDLINE_LINUX="net.ifnames=0 biosdevname=0"

修改步骤2:
sudo update-grub

修改步骤3:
sed -i "s/enp2s0/eth0/" /etc/netplan/00-installer-config.yaml

修改步骤4:
sudo reboot

查看修改结果:

daily@jenkins:~/daily/jenkins$ ip a
1: lo:  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:  mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 00:e0:4c:21:cc:2d brd ff:ff:ff:ff:ff:ff
    inet 192.168.60.64/24 brd 192.168.60.255 scope global dynamic eth0
       valid_lft 2591433sec preferred_lft 2591433sec
    inet6 fe80::2e0:4cff:fe21:cc2d/64 scope link
       valid_lft forever preferred_lft forever

你可能感兴趣的:(Linux操作系统,ubuntu,linux,jenkins)