54

I've changed the name of my eth1 interface to eth0. How to ask udev now to re-read the config?

service udev restart

and

udevadm control --reload-rules

don't help. So is there any valid way except of rebooting? (yes, reboot helps with this issue)

  • yes, I know I should prepend the commands with sudo, but either one I posted above changes nothing in ifconfig -a output: I still see eth1, not eth0.

  • I just changed the NAME property of udev-rule line. Don't know any reason for this to be ineffective.

There is no any error in executing of both commands I've posted above, but they just don't change actual interface name in ifconfig -a output. If I perform reboot - then interface name changes as expected.

For development purposes I write some script that clones virtual machines (VirtualBox-driven) and pre-sets them up in some way.

So I perform a command to clone VM, start it and as long as network interface MAC is changed - udev adds the second rule to network persistent rules. Right after machine is booted for the first time there are 2 rules:

  • eth0, which does not exist, as long as it existed in the original VM image MAC
  • eth1, which exists, but all the configuration in all files refers to eth0, so it is not that good for me

So I with sed delete the line with eth0 (it is obsolete and useless in cloned image) and replace eth1 with eth0. So currently I have valid persistent rule, but there is still eth1 in /dev.

The issue: I don't want to reboot the machine (it will take another time, which is not good thing on building-VM-stage) and just want to have my /dev rebuilt with some command so I have ready-to-use VM without any reboots.

9
  • How did you change eth1 to eth0? Did you just rename the device file? If so, that's not an effective way to do it (and you should expect the change to be reverted by a successful restart of the udev daemon). If you used some other method, please describe it in detail, and please also give the complete and exact text of any error messages you're seeing when you run the commands you've tried (for restarting the udev daemon or reloading its rules). You can edit your question to provide this information. Nov 25, 2011 at 1:11
  • @Eliah Kagan: updated. ps: why should it be reverted? It shouldn't ;-)
    – zerkms
    Nov 25, 2011 at 1:13
  • udev dynamically generates your devices in /dev. If you restart it, it will regenerate them according to its rules. Changes made directly to them are not, generally speaking, persistent. It looks like restarting udev is working fine, but that you just haven't properly changed the device names. Nov 25, 2011 at 1:15
  • @Eliah Kagan: udev only adds (not modifies) new rules if it cannot find the one for particular device. If there is a rule that matches - it just follows it without modifications.
    – zerkms
    Nov 25, 2011 at 1:17
  • @Eliah Kagan: and I changed it properly. Just believe I do can change one char in a line ;-) (also reboot helpes, and this proves that everything is fine with rules)
    – zerkms
    Nov 25, 2011 at 1:19

10 Answers 10

35

I don't know if this helps in reloading the network configuration, but when I modified /etc/udev/rules.d/70-persistent-cd.rules to correct the DVD device link from /dev/dvd1 to /dev/dvd, I had to run

sudo udevadm trigger

to get have the new links created.

3
22

You have to combine all the advice given here in the right order:

  1. Bring down the network service networking stop
  2. Unload the driver module from the kernel
    1. Find the name of the module lspci -v and look for "Kernel driver in use:"
    2. modprobe -r <driver module>
  3. Reload the udev rules udevadm control --reload-rules
  4. Trigger the new rules udevadm trigger
  5. Load driver modprobe <driver module>
  6. Restart the network service networking start
  7. (optional) Re-run any iptables scripts that referenced the eth interface name before it was up.

I suspect either step 4 or step 5 isn't really needed, but these steps worked for me. You could check after step 4 with step 2.1 to see if the trigger command already did step 5, edit this answer to reflect your findings if you do.

1
  • 1
    Ubuntu 15.04 with all devices listed in /etc/network/interfaces (so Network Manager leaves them alone): All I needed to do was edit /etc/udev/rules.d/70-persistent-net.rules then do #2, #3, #5. No need to stop all networking; no need for anything else. Jul 21, 2015 at 18:13
6

I had a similar problem. Since I didn't want to take the time to reboot, I ran a one liner using Chris Wesseling's suggestion.

/etc/init.d/networking stop && modprobe -r tg3 && udevadm control --reload-rules && udevadm trigger && modprobe tg3 && /etc/init.d/networking start

This worked for me using Ubuntu 12.04.02 server. My nics were using the tg3 kernel module driver, so change tg3 to the module your interfaces are using. I found the ones mine used in /etc/udev/rules.d/70-persistent-net.rules:

PCI device 0x14e4:/sys/devices/pci0000:00/0000:00:1c.4/0000:02:00.1 (tg3) <-kernel module driver for the nic

The one issue I had was a bad route which I fixed with a simple route add command. Thanks for the help Chris!

5

This worked for me (without rebooting)

udevadm control --reload-rules ; udevadm trigger

Kudos to the author of this page: http://memoryfail.wordpress.com/2013/04/02/renaming-network-device-names/

3

sudo /etc/init.d/udev restart should do the trick. Some of the commands you had tried, if run with sudo, might be effective as well.

1
  • Nope, ifconfig -a still shows me old eth1 interface
    – zerkms
    Nov 25, 2011 at 1:05
3

This should do it safely:

sudo reload udev

As I have used this command with no issues.

1
  • Nope, ifconfig -a still shows me old eth1 interface
    – zerkms
    Nov 25, 2011 at 1:05
1

I've been researching this for a while with pretty much the same purpose, and I haven't been able to find a way to change the network interface name in a live system.

The workaround I have gone for is to delete the /etc/udev/rules.d/70-persistent-net.rules file in the template, which means that on the next boot it will see any network card as eth0.

1

You need to reload udev to trigger the rule change, but the device won't be renamed unless you unload/reload the driver module.

So modprobe -r e1000 && modprobe e1000 after udev reload should do the trick. Of course, don't do that if you need the network and have only e1000 interfaces.

0

So for me on VirtualBox with Ubuntu 12.04, I often switch between ethernet and wireless.

So when my connection changes, I must choose the Bridged Adapter from Devices > Network Settings. Either 'Intel 82579LM Gigabit Network Connection' or 'Intel Centrino Ultimate-N 6300 AGN'.

After doing this, I can run

sudo modprobe -r e1000
sudo service udev restart
sudo modprobe e1000
ping google.com # To test I ran this between each command.

This is just an explanation of my results after reading all the answers above.

0

I followed the instructions in this guide: How to regenerate the /etc/udev/rules.d/70-persistent-net.rules file on Debian/Ubuntu

The solution consists in using the command:

udevadm trigger

that regenerates the /etc/udev/rules.d/70-persistent-net.rules file.

1
  • 1
    Welcome to Ask Ubuntu! Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference.
    – Braiam
    Aug 30, 2013 at 2:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .