0

When I run ip addr show, this will show an interface being named enp3s0f0 or similar.

This name is assigned by udev.

This happens after mounting the / drive.

Thus it happens after luks file encryption.

I wanted to make the password prompt to decrypt available over the network by installing an ssh server, dropbear, into the initramfs. Doing so requires telling dropbear what network interface to listen on, and also enabling dhcp within initramfs. To do so, I need the network interface name.

To my surprise, nowhere could I find a way to easily see what the original name of enp3s0f0 is. If my host has many ports and is slow to boot, trial and error can be cumbersome, requiring two reboots per try.

Is there some command I can run to find this out quickly, after the renaming has already happened?

2
  • What about identifying the interface by MAC address instead? Then you can do something like interface=$(grep -li $MACADDR /sys/class/net/*/address | cut -d/ -f5) to get the interface name.
    – larsks
    Commented Jul 21, 2022 at 12:46
  • That (grepping MAC in /sys/.../address) does not give you the original interface name as known by the early boot (initramfs environment shortly after the kernel boots, but before I guess the OP renames the interface). The OP wants to change kernel ip=XXX arg in grub config and needs the original interface name after the interface names have run (think running a script from multi-user boot to automate modifying the grub config).
    – Juan
    Commented Mar 2 at 17:13

2 Answers 2

1

I don't yet have an answer for the problem the OP posted, but there exists a tool, dracut-sshd, that was written for exactly the task the OP is working on (receive a key over ssh to decrypt an encrypted volume, presumably the root and other data filesystems - instead of entering the decryption passphrase at the boot console).

I will update this answer when I find a good way to automate the reverse lookup from new interface name to the original interface name known when initramfs runs. I have a similar need - it may be that I will have to push the interface renaming into initramfs before it tries to start up the network interface and set the address as directed by the ip= command line arg as documented in kernel docs - nfsroot.txt)

Note: After the interface rename, udevadm info -q property /sys/class/net/<ifname> does not show the original name in any of the properties. Recording the original name before the renaming might be a strategy (if there is a convenient place to store that at the time of the rename - maybe /run?). This is not a technique that involves standard tools - it's a "roll your own" method.

0

You can try to use system journal to see renames history

journalctl -b 0 -g "renamed from"
1
  • sudo journalctl -b 0 | grep -i rename does not show up in my logs. This is on an older kernel (centos 7 at the moment), but this is an indication that grepping logs is a somewhat fragile method. A more reliable (and hopefully friendly to automation) method is needed. I'm looking for this, too.
    – Juan
    Commented Mar 2 at 17:28

You must log in to answer this question.

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