3

I have multiple ARM devices on which Debian runs. I have a single image saved from the SD Card and intend to use it on all devices.

Now I have the problem that, each time the MAC address of the eth, wlan, etc... port changes, it adds a new entry to the 70-persistent-net.rules file. For me this is a problem because in my /etc/network/interfaces file I only have eth0 set up. If the interface then gets linked to eth1, it won't connect to the network. Since no screen is connected it is a hassle to redo this process every time.

Is there a way to tell the OS to always use eth0 when the MAC address of the ethernet interface changes?

3 Answers 3

2

This is what I put in my 70-persistent-net.rules file; you might only need the first two:

SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="*", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth0", NAME="eth0"
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="*", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth1", NAME="eth1"
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="*", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth2", NAME="eth2"
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="*", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth3", NAME="eth3"
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="*", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth4", NAME="eth4"
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="*", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth5", NAME="eth5"
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="*", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth6", NAME="eth6"
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="*", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth7", NAME="eth7"
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="*", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth8", NAME="eth8"
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="*", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth9", NAME="eth9"
0
2
  1. Delete your current interface name prescriptions:

    # rm /etc/udev/rules.d/70-persistent-net.rules
    
  2. Make sure they don't get regenerated:

    # touch /etc/udev/rules.d/75-persistent-net-generator.rules
    
  3. That's it.

2
  • I've been softlinking 70-persistent-net.rules to /dev/null as a hack. Will a null generator stanza work the same and ensure the 70-rules file stays blank? That's excellent, if so. Jan 28, 2020 at 17:26
  • Symlinking to /dev/null is probably clearer than creating an empty file, though both should work. If you deactivate the generator by either means, nothing will create or modify 70-persistent-net.rules anymore. Jan 29, 2020 at 0:08
1

At the end of /etc/rc.local

 if ifconfig | grep -q eth0 
 then
   : > /etc/udev/rules.d/70-persistent-net.rules
   reboot
 fi

This sould do the job, and in case you reboot on same devices, you reboot only once.

As a faster alternatives, you can delete 70-persistent-net.rules on shutdown, this suppose you only do scheduled shutdown.

1
  • So using wildcards like * in the MAC adress field in the 70-persistent-net.rules file is not allowed?
    – ap0
    Sep 21, 2015 at 8:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .