# changing names from eth0 to eth1 and viceversa?

## larand54

I'm on kernel 2.6.17 and using udev.

I have one machine that has three ethernet cards.

Now I want eth0 and eth1 to exchange their names.

How can I do that?

----------

## desultory

Network interfaces can be assigned names using udev.

----------

## blu3bird

Create a file named /etc/iftab

including:

```
eth1    mac 00:00:00:00:00:00
```

left side = new name

right side = mac address

create a line for every card you want to rename.

You can also define the names by the drivers they use but since a mac address is unique i'd prefer this.

more information: man ifrename

----------

## larand54

Thanks!

I've tried both methods but not working 100%

Using iftab didn't work at all. It need some packages that I havn't installed. Did not find any.

Trying to let udev change the name eth0 to eth1  and viceversa didnt work. It clamed that the devices already existed. I need a way to remove them before renaming them probably. How?

I had to give them other names so now I got:

```
eth0  -> lan0

eth1  -> adsl

eth2  -> wlan

```

Maybe more meaningful names but not standard.

Now I got another problem:

samba wil not start, nmbd says:

```
[2006/09/18 17:15:58, 0] lib/interface.c:load_interfaces(225)

  WARNING: no network interfaces found

```

But I changed the smb.conf where interfaces now is set to wlan and lan0.

How can that be?  :Question: 

Maybe it's because nmbd is still running! It had been stopped several times and I hadn't recognized it was still running. I can't kill it either so I suppose I have to reboot. Not so funny this time  :Sad: Last edited by larand54 on Mon Sep 18, 2006 3:19 pm; edited 1 time in total

----------

## truc

could you share with us,the udev rules you've tested ?

----------

## larand54

Ok, that's simple..The new rules:

```
KERNEL=="eth*", SYSFS{address}=="00:nn:nn:nn:nn:00", NAME="lan0"

KERNEL=="eth*", SYSFS{address}=="nn:nn:nn:nn:nn:01", NAME="adsl"

KERNEL=="eth*", SYSFS{address}=="nn:nn:nn:nn:nn:02", NAME="wlan"
```

The rules I tried first:

```
KERNEL=="eth*", SYSFS{address}=="00:nn:nn:nn:nn:00", NAME="eth1"

KERNEL=="eth*", SYSFS{address}=="nn:nn:nn:nn:nn:01", NAME="eth0"

KERNEL=="eth*", SYSFS{address}=="nn:nn:nn:nn:nn:02", NAME="eth2"
```

[/code]

~

----------

## truc

I don't know if it's important or not, but with udev-100-r2, I have ATTR{address}== instead of SYSFS{address}==

in the output of  udevinfo -a -p /sys/class/net/eth0

----------

## larand54

 *truc wrote:*   

> I don't know if it's important or not, but with udev-100-r2, I have ATTR{address}== instead of SYSFS{address}==
> 
> in the output of  udevinfo -a -p /sys/class/net/eth0

 

Aahh, well good to know but I think it still works this way, I also got samba work since I rebooted the system. The only way to get rid of the old nmbd it seems.

So now everything seems to work as expected, except for dnsmasq, the host names is not resolved any longer but I havn't time now to look at that. I'll come back in another thread later probably.

But thanks anyway!  :Smile: 

----------

