Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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.

share|improve this question
add comment

1 Answer 1

up vote 0 down vote accepted

I ended up going with option #1 (dynamically rewriting the various config files that needed ethX). This was easy to do with a simple Ruby script.

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.