Assign fixed interface name to a MAC address

1

I'm working with a raspberry pi which only has one network card (an ethernet port). To have more network cards, I use external devices that convert from USB to ethernet. The problem is that each time the raspberry is rebooted, it randomly assigns the interface name to the device.

I would like to make it somehow raspberry to detect that it is a MAC (the one I want) assigned the interface name that I want; that is, for example the MAC 00:50:56:c0:00:08 with the interface name eth2

I have tried to create a file called 70-persistent-net.rules in /etc/udev/rules.d and include the following rule:

  

SUBSYSTEM == "net", ACTION == "add", DRIVERS == "? ",   ATTR {address} == "00: 50: 56: c0: 00: 08", ATTR {dev_id} == "0x0",   ATTR {type} == "1", KERNEL == "eth ", NAME="eth2"

Restarting the raspberry does not assign the MAC with the name of the interface.

Would there be any other possibility to carry it out?

Thank you.

    
asked by Nfernandez 05.09.2017 в 12:26
source

1 answer

0

To change the name of the network interface you must do the following:

  • Check the name of the network interface using the ifconfig

    command

  • Once you know the mac addresses you have to modify the name of the network interface. Edit the file /etc/udev/rules.d/10-network.rules For example: sudo nano /etc/udev/rules.d/10-network.rules and add the following text, in your case ...

  •   

    SUBSYSTEM == "net", ACTION == "add", ATTR {address} == "00: 50: 56: c0: 00: 08", NAME="eth2"

  • Next you have to access the configuration file / etc / network / interfaces and edit it. For example: sudo nano /etc/network/interfaces and modify those mentions to the old network interfaces by the new names of them.
  • answered by 05.09.2017 в 13:52