Raspbian – udev rename eth0 ?

Mentre i Radiohead annunciano il loro ritiro da internet il mio Raspberry PI avrà pensato di allinearsi, condividendo la sfida.

Avevo da poco aggiornato il firmware con kernel 4.4.8+ e tutto sembrava filare liscio, così spengo l’aggeggio e mi preparo a fare un backup della SD che solitamente faccio ogni mese ma ultimente i lunghi uptime mi avevano fatto saltare qualche operazione.

Il mio PI ha come unica via di accesso la scheda eth0, pertanto se non riesco ad accedere con una sessione SSH devo arrangiarmi smontando il cavo HDMI della WII per inserirlo sulla seconda presa del mio monitor e usando una tastiera USB.

La sorte mi ha voluto far testare la porta HDMI perché dalla rete non ricevevo segni di vita anche se i led sul PI sembravano OK.

Dopo le prime smanettate da shell scopro che non ho più eth0 ma emxb914effef333, urka !!! vediamo ora di far ripartire l’accrocchio.

Appena avuta la shell indaghiamo per vedere com’è la rete

$ sudo ifconfig
emxb914effef333

non c’è eth0, e in attesa di scoprire chi l’ha rinominata facciamo una prova, cambiamo il nome dell’interfaccia in /etc/network/interfaces mettendo emxb914effef333 al posto di eth0 (ho una configurazione statica) e riavviamo la rete

#/etc/init.t/networking restart

una prova di ping e la connessione funziona, ora resta da vedere come rimettere il nome a posto, ovvero come era prima e come voglio che sia.

Da una prima veloce ricerca pare che udev sia implicato in questa brutta storia, le ricerche portano qui :

$ ls /etc/udev/rules.d/
40-scratch.rules  80-net-setup-link.rules  99-input.rules

così

$ cat /etc/udev/rules.d/80-net-setup-link.rules 
# This machine is most likely a virtualized guest, where the old persistent
# network interface mechanism (75-persistent-net-generator.rules) did not work.
# This file disables /lib/udev/rules.d/80-net-setup-link.rules to avoid
# changing network interface names on upgrade. Please read
# /usr/share/doc/udev/README.Debian.gz about how to migrate to the currently
# supported mechanism.

andiamo bene ! vediamo leggerci la documentazione.

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/systemd/network/01-mac-for-usb.link).

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, then run "update-grub"

Disable the default *.link rules with
 "ln -s /dev/null /etc/udev/rules.d/80-net-setup-link.rules"
 and rebuild the initrd with "update-initramfs -u"

Non avendo GRUB e initramfs cerco oltre

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

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

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.

qui andiamo meglio, così mi preparo il mio file:

#touch /etc/udev/rules.d/76-puppa-netnames.rules

e ci butto dentro i dati

SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="g7:35:ed:de:d3:71", NAME="eth0"

l’indirizzo della vostra scheda lo vedete dal comando ifconfig e resta lo stesso medesimo anche se cambia il nome ( urca !).

Avendo premura di aver rimesso a posto i file precedentemente modificati mi preparo al riavvio.

Tutto è tornato come prima.

 

Esperimento riuscito

 

PS: marcomg fare nuovi admin e nuovi mod non pare aver dato grossi benefici, se ti impegni ancora un pochetto riesci a far chiudere debianizzati entro la fine dell’anno solare WOW !

😉

2 risposte a “Raspbian – udev rename eth0 ?”

  1. Non so cosa è succeso, non ne sono dentro.
    Però sembra che il cambio generazionale invece di portare nuova linfa abbia meso in crisi.
    La front page puzza di cadavere da tempo.
    il forum- rss fermi da 3 settimane, scarsa partecipazione e argomenti poco interessanti
    il planet- a parte le mie poche news, quelle di un admin danno da 6 mesi : Errore nello stabilire una connessione al database
    il wiki- maniacale aggiornemnto ma poche guide nuove
    IRC – chiuso da tempo
    ezine- chiusa da tempo
    identi.ca- esiste ancora ?

    pensi che presentarsi con link inesistenti o vecchi possa essere interessante ?

Rispondi

Questo sito usa Akismet per ridurre lo spam. Scopri come i tuoi dati vengono elaborati.