<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 14 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:SimSun;
panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
{font-family:SimSun;
panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:"\@SimSun";
panose-1:2 1 6 0 3 1 1 1 1 1;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
pre
{mso-style-priority:99;
mso-style-link:"HTML Vorformatiert Zchn";
margin:0cm;
margin-bottom:.0001pt;
font-size:10.0pt;
font-family:"Courier New";}
span.E-MailFormatvorlage17
{mso-style-type:personal-compose;
font-family:"Arial","sans-serif";
color:windowtext;
font-weight:normal;
font-style:normal;}
span.HTMLVorformatiertZchn
{mso-style-name:"HTML Vorformatiert Zchn";
mso-style-priority:99;
mso-style-link:"HTML Vorformatiert";
font-family:"Courier New";}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri","sans-serif";}
@page WordSection1
{size:612.0pt 792.0pt;
margin:70.85pt 70.85pt 2.0cm 70.85pt;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="DE" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-family:"Arial","sans-serif"">Hi,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Arial","sans-serif""><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:"Arial","sans-serif"">up to now I found no way to write an udev rule which renames a specific NIC by using a MAC address that is returned by a bash script. The reason for getting the MAC address by
the bash script is that the renaming NIC rule should be applied to different CPUs (with different MACs).<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:"Arial","sans-serif""><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:"Arial","sans-serif""><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:"Arial","sans-serif"">Here is my udev rule: /etc/udev/rules.d/81-net-rename.rules<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:"Arial","sans-serif""><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:"Courier New"">SUBSYSTEM!="net", GOTO="net_name_slot_end"<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:"Courier New"">ACTION!="add|change", GOTO="net_name_slot_end"<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:"Courier New"">KERNEL=="*", ATTR{type}=="1", PROGRAM="/bin/getMAC_DHCP.sh", ATTR{address}=="%c", NAME="net0"<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:"Courier New"">LABEL="net_name_slot_end"<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:"Arial","sans-serif""><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:"Arial","sans-serif""><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:"Arial","sans-serif"">Here is my bash script:<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:"Arial","sans-serif""><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">#!/bin/bash<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New""><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:"Courier New"">NIC_ID=<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:"Courier New"">MACS=(`cat /sys/class/net/*/address`)<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:"Courier New""><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:"Courier New"">len=${#MACS[*]}<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:"Courier New""><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:"Courier New"">NIC_CNT=0<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:"Courier New"">for ((i=0; i != len; i++)); do<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:"Courier New"">mac_str=${MACS[$i]}<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:"Courier New"">if [ $mac_str != "00:00:00:00:00:00" ]; then<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:"Courier New""> let NIC_CNT=$NIC_CNT+1<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:"Courier New"">fi<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:"Courier New"">done<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:"Courier New""><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:"Courier New"">if [ $NIC_CNT -eq 2 ]; then<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:"Courier New""> NIC_ID="enp1s0"<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:"Courier New"">fi<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:"Courier New"">if [ $NIC_CNT -eq 3 ]; then<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:"Courier New"">NIC_ID="enp3s0"<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:"Courier New"">fi<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:"Courier New"">if [ $NIC_CNT -eq 4 ]; then<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:"Courier New""> NIC_ID="enp3s0"<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:"Courier New"">fi<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:"Courier New"">echo $NIC_ID >> $LOG<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:"Courier New""><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:"Courier New"">cat /sys/class/net/$NIC_ID/address<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:"Arial","sans-serif""><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:"Arial","sans-serif""><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Arial","sans-serif"">Kind regards<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Arial","sans-serif"">Michael<o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<br>______________________________________________________________<br><br>KRONES AG<br>Vorstand: Volker Kronseder (Vors.),<br>Christoph Klenk, Rainulf Diepold, Thomas Ricker, Markus Tischer, Ralf Goldbrunner <br>Vors. des Aufsichtsrates: Ernst Baumann<br>Sitz Neutraubling<br>Registergericht Regensburg HRB 2344<br>______________________________________________________________<br><br>Der Inhalt dieser E-Mail und jeder Anhang ist vertraulich.<br>Diese Inhalte sind nur fuer die benannten Adressaten.<br>Wenn Sie diese E-Mail durch einen Fehler erhalten haben,<br>benachrichtigen Sie sofort Ihren Administrator oder den Absender.<br>Behandeln Sie die E-Mail vertraulich.<br><br>* Diese E-Mail wurde auf Viren und gefaehrlichen Inhalt geprueft. *<br>______________________________________________________________<br><br>The contents of this email and any attachments are confidential.<br>They are intended for the named recipient(s) only.<br>If you have received this email in error please notify the system manager<br>or the sender immediately and do not disclose the contents to anyone or<br>make copies.<br><br>* This e-Mail was scanned for viruses, vandals and malicious content. *</body>
</html>