# How do you change udev rules without restarting (e.g. to change eth1 to eth0)?

TLDR; How do you apply changes to /etc/udev/rules.d/70-persistent-net.rules without restarting? (See this documentation about ethernet interface logical names.)

Long version:

I have a bootable USB flash drive running an image made by remastersys of 11.04. I want to be able to use this bootable USB drive to run a DHCP server from any computer. To do this, I have to assign a static IP address to eth0 in /etc/network/interfaces and reference eth0 in /etc/default/isc-dhcp-server.

However, the network card is assigned ethX based on MAC address, so this only works on the first computer where the USB flash drive is used -- each subsequent computer's NIC will be assigned to eth1, eth1, etc.

It seems that there are two strategies that could work to solve this problem:

1. Dynamically rewrite /etc/network/interfaces and /etc/default/isc-dhcp-server based on the first ethX that comes up when you run ifconfig -- this should be whatever NIC is actually in the computer.
2. Rewrite /etc/udev/rules.d/70-persistent-net.rules so that whatever MAC address is assigned to the NIC is named eth0.

I know I can do #1 because changes to these files can be applied by restarting networking and isc-dhcp-server.

However, #2 seems cleaner to me as I believe the /etc/udev/rules.d/70-persistent-net.rules will build up a bunch of crud as this USB drive is used in different computers.

Any help would be appreciated.

If the script doing the dynamic rewrite is startup.rb, I created a wrapper called startup-wrapper.rb that calls the actual script with exec 'sudo startup.rb' so that startup.rb runs with root permissions.
I then created an entry in Startup Applications with the following command: gnome-terminal -e /path/to/startup-wrapper.rb. This will prompt the user for their password for the sudo on boot.