Grub cmdline linux net ifnames 0

Use of Predictable Network Interface Names with alternate kernels

Almost constantly, I use kernels from the Ubuntu kernel PPA, or kernels I have compiled myself, using the Ubuntu kernel configuration. The problem is when I am using the stock kernel it seems to default to using predictable network interface names (i.e. «p4p1»), but when I use any alternate kernel it seems to default to using the old method (i.e. «eth0»). While not really relevant to this question, I had a hard disk failure on my test computer and am doing a new install of Ubuntu Server 14.04.2. I have not been able to determine what is the difference between the kernels. I suspect a kernel configuration parameter, but have been unable to identify which one. My question: How can I make predictable network interface names work consistently across all kernels? Additional notes: Somewhere I saw to disable predictable network interface names to add this to grub:

GRUB_CMDLINE_LINUX_DEFAULT="net.ifnames=0 biosdevname=0" 
GRUB_CMDLINE_LINUX_DEFAULT="net.ifnames=1 biosdevname=1" 

but it made no difference. Actually, I can never get the non-stock kernel to use biosdevname, no matter the setting. And I can never get the stock kernel to generate a /etc/udev/rules.d/70-persistent-net.rules file (even though, that is not what I want), no matter the setting of net.ifnames . If I have net.ifnames=1 , then at least the non-stock kernel doesn’t generate an incorrect /etc/udev/rules.d/70-persistent-net.rules file. Excerpts from /var/log/udev :
stock kernel:

KERNEL[9.216730] add /devices/pci0000:00/0000:00:1c.4/0000:03:00.0/net/p4p1 (net) ACTION=add DEVPATH=/devices/pci0000:00/0000:00:1c.4/0000:03:00.0/net/p4p1 IFINDEX=2 INTERFACE=p4p1 SEQNUM=1945 SUBSYSTEM=net . UDEV [9.241073] add /devices/pci0000:00/0000:00:1c.4/0000:03:00.0/net/p4p1 (net) ACTION=add DEVPATH=/devices/pci0000:00/0000:00:1c.4/0000:03:00.0/net/p4p1 ID_BUS=pci ID_MODEL_FROM_DATABASE=P8P67 and other motherboards ID_MODEL_ID=0x8168 ID_NET_NAME_MAC=enxf46d04652d8e ID_NET_NAME_PATH=enp3s0 ID_OUI_FROM_DATABASE=ASUSTek COMPUTER INC. ID_PCI_CLASS_FROM_DATABASE=Network controller ID_PCI_SUBCLASS_FROM_DATABASE=Ethernet controller ID_VENDOR_FROM_DATABASE=Realtek Semiconductor Co., Ltd. ID_VENDOR_ID=0x10ec IFINDEX=2 INTERFACE=p4p1 
KERNEL[10.772566] add /devices/pci0000:00/0000:00:1c.4/0000:03:00.0/net/eth0 (net) ACTION=add DEVPATH=/devices/pci0000:00/0000:00:1c.4/0000:03:00.0/net/eth0 IFINDEX=2 INTERFACE=eth0 SEQNUM=1962 SUBSYSTEM=net . UDEV [11.185866] add /devices/pci0000:00/0000:00:1c.4/0000:03:00.0/net/eth0 (net) ACTION=add DEVPATH=/devices/pci0000:00/0000:00:1c.4/0000:03:00.0/net/eth0 ID_BUS=pci ID_MODEL_FROM_DATABASE=P8P67 and other motherboards ID_MODEL_ID=0x8168 ID_NET_NAME_MAC=enxf46d04652d8e ID_NET_NAME_PATH=enp3s0 ID_OUI_FROM_DATABASE=ASUSTek COMPUTER INC. ID_PCI_CLASS_FROM_DATABASE=Network controller ID_PCI_SUBCLASS_FROM_DATABASE=Ethernet controller ID_VENDOR_FROM_DATABASE=Realtek Semiconductor Co., Ltd. ID_VENDOR_ID=0x10ec IFINDEX=2 INTERFACE=eth0 SEQNUM=1962 SUBSYSTEM=net USEC_INITIALIZED=3227 

Note: I have temporarily moved past this issue by allowing a /etc/udev/rules.d/70-persistent-net.rules file to be created, and then editing it for proper device names. Ultimately, I would like to get rid of the file.

Читайте также:  Kali linux wifi модуль

Источник

Change Default Network Name (ens33) to eth0 on Debian 10 / Debian 9

ITzGeek

Debian 10 / Debian 9 uses a consistent and predictable device name for network interfaces. This predictable device naming helps us to locate network interfaces where it is connected like whether it is attached to onboard or external.

If you ever interested in changing interface name to eth0 , then this is the tutorial for you.

Current Network Interface Name

Use the ip a command to see the network interfaces.

Interface Name Before Disabling Consistent Device Naming

As you can see in the below output of ip a command, my Debian system is having a network adapter called enp0s3.

This is just the case of VirtualBox and it may vary depends on your system hardware (In the case of VMware, it will be ens33 ) but the procedure to get the ethX back will be the same.

You can confirm that the Ethernet device got renamed during the system boot by using the dmesg command.

Kernel renamed eth0

Disable Consistent Interface Device Naming

To regain the ethX back, edit the grub file.

Look for GRUB_CMDLINE_LINUX line and add net.ifnames=0 biosdevname=0 .

GRUB_CMDLINE_LINUX="net.ifnames=0 biosdevname=0"

Edit GRUB Parameter

Generate a new grub configuration file using the grub-mkconfig command.

sudo grub-mkconfig -o /boot/grub/grub.cfg

Generate GRUB Configuration

Update Network Interface Configurations

Network Manager

If your system uses NetworkManager for network configuration, then you do not have to modify any settings. You can go ahead and reboot the system.

Interfaces File

Edit the interface file and change the name of the network device so that you will have a DHCP/static IP address for ethX .

DHCP

If your machine is on a DHCP network, then,

sudo nano /etc/network/interfaces

Update below lines in interface files so that the network card can get an IP address from the DHCP server.

auto ens33 iface ens33 inet dhcp
auto eth0 iface eth0 inet dhcp

Static

If your infrastructure does not have a DHCP server, then you may need to configure a static IP address for the network interface.

sudo nano /etc/network/interfaces
auto ens33 iface ens33 inet static address 192.168.0.10 netmask 255.255.255.0 dns-nameservers 192.168.0.1 gateway 192.168.0.1
auto eth0 iface eth0 inet static address 192.168.0.10 netmask 255.255.255.0 dns-nameservers 192.168.0.1 gateway 192.168.0.1

Verify Network Interface Name

After the system reboot, go and check whether you have got the eth0 back.

Interface Name After Disabling Consistent Interface Device Naming

Conclusion

That’s All. Please drop your feedbacks in the comments section.

Источник

Переименование сетевых интерфейсов в Debian 11

Несколько лет назад писал об изменении имён сетевых интерфейсов, по сути с того времени старый способ работает, но если не повезёт, то до поры до времени. После установки или обновления каких-нибудь пакетов связанных с ядром или драйверами, вы можете очень расстроиться, что .rules’ы больше не работают или работают не полностью.

Читайте также:  Поднять linux dhcp сервер

Вообще если разобраться, с точки логики работы именования интерфейсов, например, вида enp2s0 — тут всё красиво, как-бы номер слота в мамке + номер устройства в слоте. И один из аргументов, тех кто за это топит, то что в случае замены неисправной сетевой карты, новая получит тоже имя, что было у старой — наше enp2s0.

Но, если я захочу переставить карту в другой слот? Если интерфейсов несколько, что тогда начнётся? А уж какой это кайф, писать что-то вроде «enp4s0f3» в конфигах и командах консоли, ммм.

Итак, меняем имена. Для смены имён у меня для вас два проверенных рабочих варианта (kernel 5.10.0-18 на сентябрь 2022).

  1. Передаём ядру net.ifnames=0
  2. Делаем линки для переименования сетевых интерфейсов с помощью systemd.

Теперь подробнее. Первый вариант заключается в добавлении параметра net.ifnames=0 в загрузчик. Идём в /etc/default/grub, делаем так

#grub-mkconfig -o /boot/grub/grub.cfg

Перезагружаемся и получаем имена наших интерфейсов по порядку, вида eth0, eth1, eth2. и т.д.

Второй вариант подходит не только для переименования сетевых интерфейсов, а также для привязки-переименования usb-модемов, создания бриджей и многого другого (подробнее можете почитать по ссылкам ниже). Заключается он в создании файлов с расширением .link в /etc/systemd/network (директория имеет приоритет над другими) с таким содержимым:

Пояснять что тут я думаю не надо. На каждый интерфейс — свой .link, в имени файла нужно выставлять приоритет (как в .rules), например 10-renameint-enp5s0f0-net.link, чтобы он был приоритетнее какого-нибудь 99-default.link.

Для более глубокого погружения и понимания, советую ознакомиться с материалами раз, два, три.

Источник

Change default network name (ens33) to old “eth0” on Ubuntu 18.04 / Ubuntu 16.04

ITzGeek

Just after the Ubuntu installation, I came to know that the network interface name got changed to ens33 from old school eth0.

If you ever interested in changing interface names to old type ethX, here is the tutorial for you.

As you can see in the following command, my system is having a network adapter called ens33.

This is just the case of VMware environment, it may vary depends on the hardware but the steps to get back ethX will be the same.

$ ip a 1: lo: mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1 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: ens33: mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 link/ether 00:0c:29:05:a3:e2 brd ff:ff:ff:ff:ff:ff inet 192.168.12.12/24 brd 192.168.12.255 scope global dynamic ens33 valid_lft 1683sec preferred_lft 1683sec inet6 fe80::20c:29ff:fe05:a3e2/64 scope link valid_lft forever preferred_lft forever

From the dmesg command, you can see that the device got renamed during the system boot.

$ dmesg | grep -i eth [ 3.050064] e1000 0000:02:01.0 eth0: (PCI:66MHz:32-bit) 00:0c:29:05:a3:e2 [ 3.050074] e1000 0000:02:01.0 eth0: Intel(R) PRO/1000 Network Connection [ 3.057410] e1000 0000:02:01.0 ens33: renamed from eth0

To get an ethX back, edit the grub file.

Читайте также:  Восстановление корневой файловой системы linux

Look for “ GRUB_CMDLINE_LINUX ” and add the following” net.ifnames=0 biosdevname=0 “.

GRUB_CMDLINE_LINUX="net.ifnames=0 biosdevname=0"

Generate a new grub file using the following command.

$ sudo grub-mkconfig -o /boot/grub/grub.cfg Generating grub configuration file . Warning: Setting GRUB_TIMEOUT to a non-zero value when GRUB_HIDDEN_TIMEOUT is set is no longer supported. Found linux image: /boot/vmlinuz-4.4.0-15-generic Found initrd image: /boot/initrd.img-4.4.0-15-generic Found memtest86+ image: /memtest86+.elf Found memtest86+ image: /memtest86+.bin done

Edit the interface file and change the network device name so that you will have a DHCP or static IP address for ethX.

Assign IP Address

For Ubuntu 18.04

You can assign an IP address to the system using netplan – a new network configuration tool.

For Ubuntu 16.04 / Older

DHCP:

If your infrastructure has a DHCP server and you want to leverage that, then:

$ sudo nano /etc/network/interfaces

Update below lines in /etc/network/interfaces files so that the network card can get an IP address from DHCP server.

auto ens33 iface ens33 inet dhcp
auto eth0 iface eth0 inet dhcp

Static:

If your infrastructure does not have a DHCP server, then you will need to configure a static IP address for all network interfaces on your Ubuntu machine.

$ sudo nano /etc/network/interfaces
auto ens33 iface ens33 inet static address 192.168.12.12 netmask 255.255.255.0 dns-nameservers 192.168.12.2 gateway 192.168.12.2
auto eth0 iface eth0 inet static address 192.168.12.12 netmask 255.255.255.0 dns-nameservers 192.168.12.2 gateway 192.168.12.2

After the system reboot, just check whether you have an ethX back.

$ ip a 1: lo: mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1 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 pfifo_fast state UP group default qlen 1000 link/ether 00:0c:29:05:a3:e2 brd ff:ff:ff:ff:ff:ff inet 192.168.12.12/24 brd 192.168.12.255 scope global eth0 valid_lft forever preferred_lft forever inet6 fe80::20c:29ff:fe05:a3e2/64 scope link valid_lft forever preferred_lft forever

Источник

Оцените статью
Adblock
detector