# How to make eth1 named as wlan0?

## heilong

Hello guys. I was wondering... lots of folks keep to referring to their wireless device as wlan0, mine is eth1.

Is there any useful udev rule to name it wlan0 or maybe it's just some drivers do this themselves?

----------

## anime-otaku

That comes partly (or maybe completely) through the driver you use for this. I'm using for example the ndiswrapper with windows driver and have wlan0 as name or with my other pcmcia card I have rt0 as name, because this uses rt2500.

----------

## heilong

I see - kinda like FreeBSD. I'm 95% sure the name can be renamed with a udev rule, but I'm not sure how the rule should look

----------

## JeliJami

if you want to rename your interface, you can do it in /etc/conf.d/net:

```
$ cat /etc/conf.d/net.example

...

# If you are unable to write udev rules, then we do provide a way of renaming

# the interface based on it's MAC address, but it is not optimal.

# Here is how to rename an interface whose MAC address is 00:11:22:33:44:55

# to foo1

#rename_001122334455="foo1"

# You can also do this based on current device name - although this is not

# recommended. Here we rename eth1 to foo2.

#rename_eth1="foo2"

...

```

----------

## NeddySeagoon

heilong,

Unless you define some udev rules o rename the interface, udev uses the name offered by the kernel, which comes from the driver.

You can rename your interfaces to anything you like, like this:-

Create a file  /etc/udev/rules.d/03-local-net.rules 

```
KERNEL=="eth*", SYSFS{address}=="00:26:54:0b:c6:c6", NAME="eth_lan"

KERNEL=="eth*", SYSFS{address}=="00:0c:6e:14:c8:e7", NAME="eth_spare" 
```

This names my interfaces based on their kernel names and MAC addresses.

MAC address need to use lower case letters here.

----------

## heilong

Thanks for the easy way, davjel.

NeddySeagoon, thanks for telling how to write udev rules - I prefer to know stuff like that before allowing

the distribution to config it for me. Where can I find some info on what's available beside SYFS{address}?

Do you think the MAC address matching is the best way to go?

----------

## orionas

Hi,

 In my /etc/modules.d/aliases I use the following

```

# Ethernet

alias eth0 8139too

alias eth1 ipw2100

alias eth2 eth1394

```

Run 

```
# modules-update
```

 once to update /etc/modprobe.conf

and I make sure the modules are loaded in the order above

Then you can guess what happens   :Smile: 

Of course you want the opposite and your modules have different names, but it's

easily adaptable.

Maybe this will work for you!

----------

## UberLord

 *orionas wrote:*   

>  In my /etc/modules.d/aliases I use the following
> 
> ```
> 
> # Ethernet
> ...

 

That does not guarantee those names.

For example, without any modules loaded and you did `modprobe eth2` then your firewire would be assigned eth0.

----------

## NeddySeagoon

heilong,

The MAC address is supposed to be unique, so yes, it should always work.

I had some problems with my interfaces starting in an indetermanate order, this fixed it.

Read about udev rules thats written by a Gentoo Developer.

----------

## heilong

Great URL, thanks!

----------

## acoul

you can also use the "ifrename" utility

----------

## jerkface

 *NeddySeagoon wrote:*   

> heilong,
> 
> Unless you define some udev rules o rename the interface, udev uses the name offered by the kernel, which comes from the driver.
> 
> You can rename your interfaces to anything you like, like this:-
> ...

 

```
KERNEL=="eth*", SYSFS{address}="00:10:a4:85:a9:44", NAME="eth0"

KERNEL=="eth*", SYSFS{address}="00:e0:98:ae:9c:94", NAME="wlan0"
```

 This is what I have in 10-local.rules, but it doesn't work. If I load my wireless module first, wireless is set to eth0 and ethernet is set to eth1, and if I load the ethernet first, ethernet is set to eth0 and wireless is set to eth1_rename . Both MACS were copied and pasted. wtf?   :Twisted Evil:  [/quote]

----------

## PaulBredbury

 *jerkface wrote:*   

> SYSFS{address}=

 

Should be two equals signs - it's a comparison, not setting a value.

----------

## jerkface

d'oh!   :Embarassed: 

----------

## jerkface

Now my ethernet always comes up as eth0, but my wireless always comes up as eth1 instead of wlan0. I don't even have a symlink for net.eth1.   :Twisted Evil: 

----------

## PaulBredbury

I use:

```
SUBSYSTEM=="net", ATTR{address}=="00:14:af:07:a0:80", NAME="wlan"
```

eth1 is probably what the normal udev rules assign it, if your rule does not match because of the bad KERNEL comparison.

Edit: Changed KERNEL=="wlan*" to SUBSYSTEM=="net"Last edited by PaulBredbury on Tue Jan 30, 2007 4:07 pm; edited 1 time in total

----------

## jerkface

I just solved my problem. Every time I loaded the prism54 module, udev read the following line from 70-persistent-net.rules

```
# PCI device 0x1260:0x3890 (yenta_cardbus)

#SUBSYSTEM=="net", DRIVERS=="?*", ATTRS{address}=="00:30:b4:00:00:00", NAME="eth1"
```

I commented it out, but udev just wrote another entry, so I just edited to NAME="wlan0" and it works.

Thanks for the help!   :Twisted Evil: 

----------

## PaulBredbury

You're still better off putting that line in 10-local.rules - because this file will not be played with by udev.

----------

## jerkface

I'm not sure if udev will modify it, because the comments say I can edit it. Just to be on the safe side, I am still going to add this to 10-local.rules.

Thanks.   :Twisted Evil:  

```
# This file was automatically generated by the /lib/udev/write_net_rules

# program, probably run by the persistent-net-generator.rules rules file.

#

# You can modify it, as long as you keep each rule on a single line.
```

----------

