Create / Initialize network interfaces on first (next) boot?

I’m wondering if there’s a(n easy) way to have an installation create and initialize network interfaces on boot? I’m using LEAP 15.4 on a NUC5, have set up the basic build as I want it, and would like to just copy the SSD over to a couple of new SSD’s for the purpose of having other machines be the same setup. Is there an easy way to have the eth0 and wlan0 interfaces created at boot up with the correct MAC addresses, or am I just going to have to log in to each new system and delete the interfaces from the original build and create the new ones manually?

I am not sure I understand your question: MAC addresses are typically not configured in the OS but are a property of the network device and these device adressen are (supposed to be) unique.

Thanks for the response.

MAC addresses are associated to the specific network controller. While they can be overridden (“spoofed”), the default is to use the hardware address associated to the controller from the factory (and it’s unique across systems). Let me walk you through an example of the situation I am encountering…

I’m using Leap-15.4 on a batch of Intel NUC5 boxes. I initially set things up to use Wicked, but it refused to connect to any WiFi network regardless of settings. I switched to Network Manager and WiFi works perfectly. The situation I have run into, however, occurs regardless of Wicked/NM…

Once the OS installed, I launch “yast lan” to get to the networking setup. It shows two interfaces (one wired, one wireless) via their full device names and a status for each of “Not Configured.” I set up the WiFi adapter and it becomes known to the OS as “wlan0” and works perfectly. Shut down the machine, remove the SSD, install it in a different NUC and boot it up.

Not only does the networking not work, but “wlan0” does not show as an interface when running “ifconfig” but “wlan1” does. Launch “yast lan” and I have the same two “Not Configured” adapters as before but I also have “eth0” and “wlan0” (I set both of them up) showing - and viewing them shows the MAC addresses associated with the NUC the original installation was done on.

I believe that there is a file somewhere that’s indicating that the WiFi card has been configured and it contains the MAC address from the original machine. I need to locate this and reset it or whatever so that the device will be recognized correctly in the new machine with no or minimal configuration. I have enough of these to set up that I want to mirror an initially well-built drive but not so many that I have any interest whatsoever in creating an AutoYast install routine.

Hope that adds some clarity…

To get wlan0 each time - you will need to clear this file in Leap - it does it automatically in Tumbleweed.

The file is /etc/udev/rules.d/70-persistent-net.rules.

I clone dozens of machines - I want eth0 each time and deleting the line with eth0 will do that for me.

You want to delete the line with wlan0. Do it before the reboot or on the SSD you clone from before you clone it.

VM1:/etc/udev/rules.d # cat 70-persistent-net.rules
# This file was automatically generated by the /usr/lib/udev/write_net_rules
# program,run by the persistent-net-generator.rules rules file.
#
# You can modify it,as long as you keep each rule on a single
# line,and change only the value of the NAME= key.

# PCI device 0x1af4:0x1000 (virtio-pci)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="08:09:99:98:f8:88", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
VM1:/etc/udev/rules.d # 

Thanks for the pointer - I will definitely check this out.

Any reason to -not- wipe the eth0 line if it’s present? I think that both interfaces are currently configured in my source system…

Also - since it seems that this will leave the interface out at boot time, and make it show as “Not Configured”, is there any reason that I couldn’t also add a script to query the interface, collect its MAC, and update that line in the file then reboot? That would give me a WiFi connection right away in a newly cloned machine - no? Not sure that’s what I ultimately want, but not having to touch the machine directly on initial boot would be nice as I could then just SSH into it to do the things I would want for initial configuration.

Hi
If using NetworkManager, it’s just a flat file for the network configuration, you could (like MicroOS/ALP) add ignition.firstboot=1 at grub and have the iso image on a USB device to use. The other one is combustion but I’ve found iginition suffices for my needs, ssh keys, ssh access, hostname, network and locatime.

Are these systems coming up via DHCP, if so why not just configure the MAC address on the dhcp server?

If I use DHCP, I do tend to create reservations for those systems that I need to access remotely from time to time. This would be a similar situation since they are intended to be small “service” providing systems that will run headless.

The gap in what you’re describing is getting -ANY- interface to be properly loaded, configured, and connected without a lot of manual intervention right now. I would like to have the system, post cloning, be able to apply a level of configuration to remove pieces that remain from the source system (which is how/why this thread started) and then insert the pieces needed for the new system. It seems that I could have a first-boot script run that would be able to edit the existing lines in the rules file to replace the MAC addresses from the source system with those of the new destination system then reboot. THAT is the point at which a DHCP reservation would be useful since the interface would actually be active…

It seems… That I can accomplish what I want quite easily by simply deleting that file.

Since I already have both of the interfaces configured to use DHCP, and I have a configuration file for wlan0 that has the PSK and SSID info, I can simply delete the file and reboot. When the system boots up, that file is recreated on the fly and wlan0 is activated and connects to the SSID.