Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to find a way to change the name of my Ralink interface to the usual wlan0.

The application I use is looking for this interface but since we changed our wifi adapter form Intel to ralink we miss the wlan0 because Ralink uses ra0 instead.

On all the forums and blogs I read that you need to change that in /etc/sysconfig/network-scripts/ifcfg-ra0. Ubuntu unfortunately does not have a /etc/sysconfig folder.

share|improve this question
Which application is looking for wlan0? – chili555 Dec 13 '12 at 16:04
A self-made application. wrote it while back, it does exactly what it is supposed to do. I lost the source in a development machine crash (backup of that specific application never happened...) – spambas Dec 17 '12 at 8:00

The device name is created by the kernel, but then you can add a rule to udev in order to rename the interface to the wanted device.

First make a backup of your configuration file

sudo cp /etc/udev/rules.d/70-persistent-net.rules /tmp/70-persistent-net.rules

You will be able to revert to the original state in case of something goes wrong by this command :

sudo cp /tmp/70-persistent-net.rules /etc/udev/rules.d/70-persistent-net.rules

Edit the file 70-persistent-net.rules in the udev rules directory :

sudo nano /etc/udev/rules.d/70-persistent-net.rules

Find the line corresponding to your persistent network device, this is something like that :

SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="xx:xx:xx:xx:xx:xx", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="ra*", NAME="ra0"

Change the name value to the wanted name so you will have a line like :

SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="xx:xx:xx:xx:xx:xx", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="ra*", NAME="wlan0"

Then reboot your computer and check that you have the right interface name.

share|improve this answer
70-persistent-net.rules has two lines for my eth0 and eth1. no ra* device listed... – spambas Dec 17 '12 at 8:01
@spambas Just add a line. – gertvdijk Jan 21 '13 at 15:34
I know how to add a line, but I need to find a structural solution. I have multiple identical computers to which I copy the harddisk. if I just add a line with a mac address, I have to edit the rules on every single computer. That will bore me pretty fast :) I Think I found the solution though. I will check it tomorrow! – spambas Jan 21 '13 at 21:00
@spambas Yeah, well, changes in any way will have you to do this on every machine. If you administer a lot of machines you should be able to manage them centrally, using e.g. Puppet, Landscape, etc. (would be my advice) – gertvdijk Jan 21 '13 at 21:23
That would be a very good suggestion if all the machines would be in an environment where I can actually access them, remote or directly. In my situation we buy a few hundred touchscreen pc's a year, put a hard disk in with our software, and then we sell it and never see it again. the hard disk needs to be generic. If a customer calls in a problem, we go to him, swap out the hard disk, and then the customer can work again. Everyone can do that. If a service engineer has to edit rules it is too hard and too risky. – spambas Jan 22 '13 at 6:58
up vote 1 down vote accepted

The device name is set by the kernel and renamed to a human readable value by udev. udev will run the 75-persistent-net-generator.rules script in /lib/udev/rules/ which will generate the rules file 70-persistent-net.rules in /etc/udev/rules.d/

This the generator script will add new rules to the 70-persistent-net.rules file for every network adapter that is recognized by the kernel. When you replace a network card (ruled eth0) the old card will not be deleted form the rules, the new one is added though (eth1).

In my situation the network adapters are continuously changing. The hard disk is copied and placed in another computer with ecxactly the same setup, but the MAC addresses will be different every time. The position (PCIe) in the computer however will be the same every time. I did the following:

I turned off the rules generator by removing it from udev, but moved it for backup purposes:

sudo mv /lib/udev/rules.d/75-persistent-net-generator.rules /home/user/backup/

The rules will not be generated anymore. Then I edited the udev rules:

sudo nano /etc/udev/rules.d/70-persistent-net.rules

I removed the rules that were set by the generator and replaced them with:

ACTION=="add", SUBSYSTEM=="net", KERNELS=="0000:00:1c.0", NAME="eth0"
ACTION=="add", SUBSYSTEM=="net", KERNELS=="0000:00:1c.1", NAME="eth1"
ACTION=="add", SUBSYSTEM=="net", ATTR{type}==”1”, KERNEL=="ra*", NAME="wlan0"

Now my two network cards on the PCIe bus are named eth0 and eth1, and when I replace them, they will stay the same.

The last line will answer my question. The adapter passed by the kernel with a ra* name will be renamed to wlan0. In /etc/network/interfaces I can call "iface wlan0 inet dhcp"!

For me this is a working solution. I can copy this hard disk and put it in another machine with the same setup. AND IT WORKS! Now I can

share|improve this answer
Uhm... I see an issue here popping up as soon as you plug in another Ralink based wireless device. They'll all be renamed to wlan0 with this rule and very likely to cause problems. – gertvdijk Jan 22 '13 at 9:14
True, but for me this is not a problem, because this never happens. The ralink is an internal PCIe/USB adapter. Another problem that can occur is if I add a third ethernet adapter. This will not show up in my interface list because it is not named. Also not a problem for me... – spambas Jan 22 '13 at 9:47

Your Answer


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.