title: automatic renaming and numbering of nics using udev
body: <p>I'm writing on an udev-rule to automatically rename and number NICs with specific MAC addresses.</p>
  
  <p>The resulting rule should do nearly the same <code>75-persistent-net-generator.rules</code> does (match first 3 bytes of the MAC address of card, name it 'mycard*' depending on how much cards of this vendor are installed, write the renaming-rule into <code>70-persistent-net.rules</code>).</p>
  
  <p>This is how far I've come until now:</p>
  
  <pre><code># udev rules to name rename cards to mycard
  
  ACTION!="add", GOTO="persistent_mycard_generator_end"
  SUBSYSTEM!="net", GOTO="persistent_mycard_generator_end"
  
  # ignore the interface if a name has already been set
  NAME=="mycard*", GOTO="persistent_mycard_generator_end"
  
  # device name whitelist
  KERNEL!="eth*", GOTO="persistent_mycard_generator_end"
  
  # read MAC address
  ENV{MATCHADDR}="$attr{address}"
  
  # match interface type
  ENV{MATCHIFTYPE}="$attr{type}"
  
  # ignore non mycard MAC addresses
  ENV{MATCHADDR}!="00:11:22:*", GOTO="persistent_mycard_generator_end"
  
  # default comment
  ENV{COMMENT}=="", ENV{COMMENT}="mycard connected through ($attr{driver})"
  
  #### THIS IS THE PART I DON'T GET ####
  
  # write rule
  DRIVERS=="?*", IMPORT{program}="write_net_rules"
  
  # rename interface if needed
  ENV{INTERFACE_NEW}=="?*", NAME="mycard*"
  
  #### THIS IS THE END OF THE PART I DON'T GET ####
  
  LABEL="persistent_mycard_generator_end
  </code></pre>
  
  <p>The task "THE PART I DON'T GET" should do is to rename a card (lets say it's eth3) to mycard0 or if it's the second card in the system with a matching MAC address mycard1 and so on.</p>
  
  <p>Thanks in advance,
  flokra</p>