commit 2d76fd754cd64daf9b2159968352d62c65c1cd81 Author: Julian Meyer Date: Mon Jun 3 16:18:25 2024 +0200 base version 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