From 2d76fd754cd64daf9b2159968352d62c65c1cd81 Mon Sep 17 00:00:00 2001 From: Julian Meyer Date: Mon, 3 Jun 2024 16:18:25 +0200 Subject: [PATCH] base version --- pin-interface-names.sh | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 pin-interface-names.sh diff --git a/pin-interface-names.sh b/pin-interface-names.sh new file mode 100644 index 0000000..e546fe7 --- /dev/null +++ b/pin-interface-names.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +# Verzeichnis für die systemd-Netzwerk-Units +output_dir="/etc/systemd/network" + +# Überprüfen, ob das Ausgabe-Verzeichnis existiert, ansonsten erstellen +if [ ! -d "$output_dir" ]; then + mkdir -p "$output_dir" +fi + +# Alle Netzwerk-Interfaces auslesen und unerwünschte Interfaces herausfiltern +interfaces=$(ls /sys/class/net | grep -Ev '^(lo|tap|vlan|vmbr|bonding|fw|veth)') + +# Für jedes Interface ein systemd-Netzwerk-File erstellen +for interface in $interfaces; do + mac_address=$(cat /sys/class/net/$interface/address) + file="$output_dir/10-$interface.link" + cat < $file +[Match] +MACAddress=$mac_address + +[Link] +Name=$interface +EOF + echo "Datei erstellt: $file" +done + +echo "systemd-Netzwerk-Units wurden erfolgreich in $output_dir erstellt." \ No newline at end of file