Changing Ethernet device names in Suse 10

Recently I put a second, faster network card in a server. On booting OpenSuse 10 assigned the new card the name eth2 and the existing, built-in Ethernet device eth0. A number of applications, for example Samba and dnsmasq, typically bind to an Ethernet name rather than a specific IP or MAC address. It is possible to change the individual configuration files for each of these services but this is a little ugly considering my goal was to install the new hardware and disable the existing device, leaving everything else untouched.

A tidier solution is to assign eth0 to the new card and eth1 to the older (unused) device. Figuring out how to do this is a little confusing, there is no Yast option to configure network names and manually editing /etc/sysconfig/network/ifcfg-eth(mac address) provides no help either. Instead you must edit the file /etc/udev/rules.d/30-net_persistent_names.rules and change the device name associated to the relevant network MAC address. In a two card setup the file will look a little like this (each network device entry is on a single line):

SUBSYSTEM=="net", ACTION=="add", SYSFS{address}=="MAC", IMPORT="/sbin/rename_netiface %k eth0"
SUBSYSTEM=="net", ACTION=="add", SYSFS{address}=="MAC", IMPORT="/sbin/rename_netiface %k eth1"

Where SYSFS{address} is set to the MAC addresses of each ethernet device. Change this file so that the correct names are associated to the appropriate MAC devices and reboot. Afterwards you will find your network cards are named in the order that you desire and all the applications that refer to eth0 work as if nothing has changed. It is a simple change and something that really should figure as part of the advanced network device options in Yast.