Predictable network interface names в debian jessie

Автор Smugo, 20 сентября 2017, 15:42:04

« назад - далее »

0 Пользователи и 1 гость просматривают эту тему.

Smugo

Кто-нибудь включал "predictable" схему именования сетевых интерфейсов в джесси?

systemd-udevd v215, привязку по mac-ам уже поломали, а как запустить «predictable» схему, ладу дать не получается

sysctl говорит, что параметра net.ifnames нет;
Пробовал прописывать GRUB_CMDLINE_LINUX_DEFAULT=«net.ifnames=1» в /etc/default/grub, положительного результата тоже не получил;

Есть ли у кого-нибудь успешный опыт с САБЖем?

ogost

У меня при обновлении на 9 эта фича сама завелась, а я всё не мог понять чего у меня сеть не заводится.

mrgoodvin

#2
У меня после обновления на 9-ку осталось все попрежнему за счет сгенерированного 70-persistent-net.rules.
Открыть содержимое (спойлер)
# This file was automatically generated by the /lib/udev/write_net_rules
# program, run by the persistent-net-generator.rules rules file.
#
# You can modify it, as long as you keep each rule on a single
# line, and change only the value of the NAME= key.

# PCI device 0x1814:/sys/devices/pci0000:00/0000:00:1c.1/0000:02:00.0 (rt2800pci)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="my:ma:ca:dd:re:ss", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="wlan*", NAME="wlan0"

# PCI device 0x10ec:/sys/devices/pci0000:00/0000:00:1c.5/0000:85:00.0 (r8169)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="my:ma:ca:dd:re:ss", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
[свернуть]
А так можно почитать /usr/share/doc/udev/README.Debian.gz, в частности раздел Legacy persistent network interface naming, может поможет:
This documents udev integration Debian specifics. Please see man udev(7) and
its referenced manpages for general documentation.

Network interface naming
~~~~~~~~~~~~~~~~~~~~~~~~
Since version 197 udev has a builtin persistent name generator which checks
firmware/BIOS provided index numbers or slot names (similar to biosdevname),
falls back to slot names (PCI numbers, etc., in the spirit of
/dev/disks/by-path/), and then optionally falls back to MAC address, and
generates names based on these properties. This provides "location oriented"
names for PCI cards such as "enp0s1" for ethernet, or wlp1s0" for a WIFI card
so that replacing a broken network card does not change the name. As location
based naming does not work well for USB devices, these use a MAC based naming
schema (see /lib/udev/rules.d/73-usb-net-by-mac.rules).

This has been enabled by default since udev 220-7, which affects new
installations/hardware. Existing installations/hardware which already got
covered by the old 75-persistent-net-generator.rules will keep their interface
names, see below.

You can disable these stable names and go back to the kernel-provided ones
(which don't have a stable order) in one of two ways:

  - Put "net.ifnames=0" into the kernel command line (e. g. in
    /etc/default/grub's GRUB_CMDLINE_LINUX_DEFAULT, then run "update-grub").

  - Disable the default *.link rules with
    "ln -s /dev/null /etc/systemd/network/99-default.link"
    and rebuild the initrd with "update-initramfs -u".

See this page for more information:
http://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames/

Legacy persistent network interface naming
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Debian releases up to 8 ("Jessie") and Ubuntu up to 15.04 had an udev rule
/lib/udev/rules.d/75-persistent-net-generator.rules which fixed the name of a
network interface that it got when its MAC address first appeared in a
dynamically created /etc/udev/rules.d/70-persistent-net.rules file.

This had inherent race conditions (which sometimes caused collisions and
interface names like "rename1"), required having to write state into /etc
(which isn't possible for read-only root), and did not work in virtualized
environments.

This old schema is deprecated in Debian 9 ("Stretch"), and will not
be supported any more in Debian 10.

Migration to the current network interface naming
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
On package upgrade systems will keep their current names, but they will need to
be manually migrated by Debian 10 / Ubuntu 18.04 LTS.  If you rely on the old
names in custom ifupdown stanzas, firewall scripts or other networking
configuration, these need to be updated to the new names.

First, determine all relevant network interface names: those in
/etc/udev/rules.d/70-persistent-net.rules, or if that does not exist (in
virtual machines), in "ip link" or /sys/class/net/.

Then for every interface name use a command like

  grep -r eth0 /etc

to find out where it is being used.

Then on "real hardware" machines, rename the file to
70-persistent-net.rules.old; on VMs remove the file
/etc/udev/rules.d/80-net-setup-link.rules instead.

Reboot, adjust configuration files, and test your system.

Custom net interface naming
~~~~~~~~~~~~~~~~~~~~~~~~~~~
In some cases it is convenient to define your own specific names for network
interfaces. These can be customized in two different ways:

* You can create your own names via udev rules, based on arbitrary attribute
   and property matches. See man udev(7) for documentation how to write udev
   rules. For example, you can create /etc/udev/rules.d/76-netnames.rules with

   ------------ snip ----------
   # identify device by MAC address
   SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="11:22:aa:bb:cc:33", NAME="eth-dmz"

   # identify by vendor/model ID
   SUBSYSTEM=="net", ACTION=="add", ENV{ID_VENDOR_ID}=="0x8086", \
       ENV{ID_MODEL_ID}=="0x1502", NAME="eth-intel-gb"

   # USB device by path
   # get ID_PATH if not present yet
   ENV{ID_PATH}=="", IMPORT{builtin}="path_id"
   SUBSYSTEM=="net", ACTION=="add", ENV{ID_PATH}=="*-usb-0:3:1*", NAME="eth-blue-hub"
   ------------ snip ----------

   The name of the rules file needs to have a prefix smaller than "80" so that
   it runs before /lib/udev/rules.d/80-net-setup-link.rules, and should have a
   prefix bigger than "75" so that it runs after 75-net-description.rules and
   thus you can use matches on ID_VENDOR and similar properties.

* Unless you disabled net.ifnames, you can change the policy
   (kernel/bios/path/MAC based naming) in an /etc/systemd/network/*.link file,
   for individual devices or entire device classes. See man systemd.link(5) for
   details about this. /lib/systemd/network/99-default.link is the default
   policy, and /lib/systemd/network/01-mac-for-usb.link makes it use MAC based
   names for USB devices.

Any of the above changes require an initrd update with "update-initramfs -u" to
get effective.

Using udev with LDAP or NIS
~~~~~~~~~~~~~~~~~~~~~~~~~~~
If the rules files reference usernames or groups not present in the
/etc/{passwd,group} files and the system is configured to use a
network-based database like LDAP or NIS then udev may fail at boot time
because users and groups are looked up well before the network has been
initialized.
A possible solution is to configure /etc/nsswitch.conf like this:

  passwd:         files ldap [UNAVAIL=return]
  group:          files ldap [UNAVAIL=return]

The nsswitch.conf syntax is documented in the glibc manual.

В просторах советуют (v220):
sudo mv -T /etc/udev/rules.d/70-persistent-net.rules{,.old}
sudo update-initramfs -u

Smugo

Еще раз. У меня не 9-ый дебиан, а 8-ой. В нем уже не udev, а systemd-udevd (v215), по умолчанию именование интерфейсов прежнее (eth).
Проблема - больше не работает привязка имен интерфейсов по mac-ам.

Предполагаемое решение - поменять схему именования интерфейсов на "предсказуемую" (напр., enp5s1).
На 9-ке то понятно, оно должно "из коробки" уже работать, а как сделать это на джесси?

ecc83

Цитата: Smugo от 21 сентября 2017, 09:12:43Проблема - больше не работает привязка имен интерфейсов по mac-ам.

Это у вас в джесси не работает привязка по мас? Очень странно. У меня всё работает.
В каталоге лежит файл с правилом /etc/udev/rules.d/70-persistent-net.rules

Smugo

#5
Цитата: ecc83 от 21 сентября 2017, 09:39:41Это у вас в джесси не работает привязка по мас? Очень странно.
....
В каталоге лежит файл с правилом /etc/udev/rules.d/70-persistent-net.rules
Это так, ошибки быть не может. Столкнулся с такой проблемой впервые, хотя есть много других машин на джесси (естественно, с более чем одной сетевой на борту)
С файлом 70-persistent-net.rules изголялся очень долго - не помогло.
Единственное, чем отличается эта машина от остальных - это обычный системник с добавленной сетевухой.

Так или иначе, решил проблему обходным путем:
Установил ifrename и прописал его в автозагрузку в systemd. 14 последовательных ребутов - полет нормальный.



Cообщение объединено 21 сентября 2017, 14:14:45

Цитата: ecc83 от 21 сентября 2017, 09:39:41У меня всё работает.
Не могу ставить под сомнение это утверждение, тем более, что на других "8-ках" у меня тоже все работает, но
https://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames/

ЦитироватьFor a longer time udev shipped support for assigning permanent "ethX" names to certain interfaces based on their MAC addresses. This turned out to have a multitude of problems, among them: this required a writable root directory which is generally not available; the statelessness of the system is lost as booting an OS image on a system will result in changed configuration of the image; on many systems MAC addresses are not actually fixed, such as on a lot of embedded hardware and particularly on all kinds of virtualization solutions. The biggest of all however is that the userspace components trying to assign the interface name raced against the kernel assigning new names from the same "ethX" namespace, a race condition with all kinds of weird effects, among them that assignment of names sometimes failed. As a result support for this has been removed from systemd/udev a while back.

ecc83

Цитата: Smugo от 21 сентября 2017, 14:02:07Не могу ставить под сомнение это утверждение, тем более, что на других "8-ках" у меня тоже все работает

Я скажу более, у меня это работает на дебиан 9 и на линукс минт, который на базе убунту LTS.

На всякий случай, вот внутренности моего файла, мас адрес поставь свой:

cat /etc/udev/rules.d/70-persistent-net.rules

SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="xx:xx:xx:xx:xx:xx", NAME="wlan0"
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="xx:xx:xx:xx:xx:xx", NAME="eth0"


ek-nfn

Цитата: ecc83 от 21 сентября 2017, 14:32:20Я скажу более, у меня это работает на дебиан 9
На всякий случай, вот внутренности моего файла, мас адрес поставь свой:
cat /etc/udev/rules.d/70-persistent-net.rules
В начисто установленном Debian 9 этого файла нет. Связываю с этим и проблему работы usb wi-fi свистков (пробовал для трех разных чипов). При обновлении же с 8-ки на 9-ку этой пробемы не наблюдал, только после сноса и чистой установки.
Devuan 5 xfce

Smugo

Цитата: ecc83 от 21 сентября 2017, 14:32:20Я скажу более, у меня это работает на дебиан 9...
Цитата: ecc83 от 21 сентября 2017, 14:32:20SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="xx:xx:xx:xx:xx:xx", NAME="wlan0"
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="xx:xx:xx:xx:xx:xx", NAME="eth0"
А как "это" может не работать хоть где-то?

По содержимому вашего файла видно, что у вас нет условий для проявления обсуждаемой проблемы. У вас всего одна сетевая eth и одна wlan, чему там "перепутываться" ?
Речь идет о том, что есть 2 однотипных сетёвки, сейчас первая eth0, вторая eth1 --> ребут --> и теперь первая eth1, а вторая eth0
Цитировать## PCI device
#SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="xx:xx:xx:xx:xx:xx", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

## PCI device
#SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="yy:yy:yy:yy:yy:yy", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"

# PCI device 0x168c:0x0013 (ath5k)
#SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="zz:zz:zz:zz:zz:zz", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="wlan*", NAME="wlan0"
Вот содержимое файла, но ни на что оно влиять не будет. Даже разрабы официально заявляли, что привязку по mac-у средствами этого файла убрали, ссылку я привел выше.

ecc83

Цитата: Smugo от 21 сентября 2017, 16:08:18
По содержимому вашего файла видно, что у вас нет условий для проявления обсуждаемой проблемы. У вас всего одна сетевая eth и одна wlan, чему там "перепутываться" ?

Перепутываться там есть чему, это МАС адресам. Если они путаются, то могут путаться от разных сетевых карт.

Если ближе к делу, то переименовать интерфейсы можно и средствами systemd. Я сейчас не могу посмотреть конфиг, это на другом компе, но если поищешь в гугле, то вероятно сам найдёшь.
А вообще то странно, зачем ломают то, что давно и надёжно работает...