[ubuntu-studio-users] new name for eth0 after update

Ralf Mardorf ralf.mardorf at alice-dsl.net
Thu Apr 27 02:00:43 UTC 2017


Hi,

what you want is a cheap workaround:

  https://askubuntu.com/questions/767786/changing-network-interfaces-name-ubuntu-16-04

But you shouldn't use it, because the workarounds could stop working.

If you are using scripts, consider to replace the device name by a
command detecting the device name.

This not necessarily works, but might work in most cases:

  $(netstat -i|grep e|tail -1|awk '{print $1}')

for example

  [rocketmouse at archlinux ~]$ echo $(netstat -i|grep e|tail -1|awk '{print $1}')
  enp3s0

If it shouldn't work, you need to fix   |grep e|tail -1|awk '{print $1}'
with something that works.

For the script you could use   ip link show   or   ifconfig -a   or whatever else,
instead of   netstat -i   , even   ls  might do the job.

  $(basename $(ls -d /sys/class/net/e*))

for example

  [rocketmouse at archlinux ~]$ echo $(basename $(ls -d /sys/class/net/e*))
  enp3s0

But you might need to pipe through   tail  ,  head  and/or other
commands to separate a single device.

You need to test what command you could use for a script and how to pipe
it, to make it work on all machines.

Consider to get rid of the kernel names (eth) on all machines. After that
scripts still require something like

  $(ls -d /sys/class/net/enp?s0)

because removing or mounting a PCI card could change the numeration.

If you aren't using scripts, but a tool such as networkmanager, you might
need to use a script to change the configuration file/s. Maybe tools like
networkmanager provide options to detect devices. I don't know, since I'm
using scripts and btw. no kernel names at all, so my scripts are using
$(basename $(ls -d /sys/class/net/enp?s0))   , if I would use kernel names,
too, I would tend to use
$(basename $(ls -d /sys/class/net/e*))   .

Now no dummy example using   echo   , instead real world examples:

   dhcpcd $(basename $(ls -d /sys/class/net/enp?s0))

or

   modprobe -v pppoe; ip link set $(basename $(ls -d /sys/class/net/enp?s0)) up

I'm starting my scripts by systemd units during startup. You didn't mention
if all your machines are using systemd. If they should do, you shouldn't
use the kernel names on any machine.

Regards,
Ralf



More information about the ubuntu-studio-users mailing list