# Wlan predictable names

**URL:** <https://forums.balena.io/t/wlan-predictable-names/17422>\
**Category:** balenaOS\
**Created:** [July 2, 2019, 11:42am UTC](https://forums.balena.io/t/wlan-predictable-names/17422 "2019-07-02T11:42:43Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![MarcoAbi](https://avatars.discourse-cdn.com/v4/letter/m/dfb087/32.png) [@MarcoAbi](https://forums.balena.io/u/MarcoAbi)\
**Post date:** [July 2, 2019, 11:42am UTC](https://forums.balena.io/t/wlan-predictable-names/17422/1 "2019-07-02T11:42:43Z")

</div>

Hello, I have a rpi3 with two usb wifi dongles attached, and I have wifi-connect running as well.  
The system seems to have systemd-predictable mechanism switched off and at every reboot, ifconfig shows wlan0, wlan1 and wlan2 referring every time to different hardware devices.

I need to activate systemd-predictable mechanism in order to allow to use wifi-connect only over wlan0 and allow my software to work with the specific dongles on wlan1 and wlan2

I’ve setup --portal-interface argument variable for wifi-connect, however it doesn’t seems to work (see below printout) and considering that wlan0 at every reboot refers to different hardware… is difficult to get it running predictably

this is what i see from inside the wifi-connect container and what the balenaos has as interfaces:

```
root@485b1c6:~# balena ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
0aff7fb97ee9 2a4b40f80667 "/usr/bin/entry.sh /…" About an hour ago Up 3 hours scheduler_61_44
08d0a9064053 817e59585503 "/usr/bin/entry.sh b…" About an hour ago Up 3 hours wifi-connect_59_44
24d23e95a9cb balena/armv7hf-supervisor:v9.15.0 "./entry.sh" 5 weeks ago Up 8 minutes (healthy) resin_supervisor
root@485b1c6:~# balena exec -t -i 08d0a9064053 /bin/bash 
root@485b1c6:/usr/src/app# ls
start.sh ui wifi-connect
root@485b1c6:/usr/src/app# echo $PORTAL_INTERFACE
wlan0
root@485b1c6:/usr/src/app# exit
exit
root@485b1c6:~# ifconfig
[... output cut ....]
wlan0 Link encap:Ethernet HWaddr 66:45:74:19:9A:DE  
          UP BROADCAST MULTICAST MTU:1500 Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)

wlan1 Link encap:Ethernet HWaddr 00:00:F6:00:78:B1  
          inet addr:172.22.15.70 Bcast:172.22.15.255 Mask:255.255.254.0
          inet6 addr: fe80::2c09:ae26:7ac9:3cd3/64 Scope:Link
          UP BROADCAST RUNNING PROMISC MULTICAST MTU:1500 Metric:1
          RX packets:42345 errors:0 dropped:0 overruns:0 frame:0
          TX packets:3872 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:5799484 (5.5 MiB) TX bytes:657109 (641.7 KiB)

```

this is ifconfig after a reboot:

```
root@485b1c6:~# ifconfig
    [... output cut ....]
wlan0 Link encap:Ethernet HWaddr 00:00:F6:00:78:B1  
          inet addr:172.22.15.70 Bcast:172.22.15.255 Mask:255.255.254.0
          inet6 addr: fe80::b5f7:dd97:a5d7:d6ae/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
          RX packets:8704 errors:0 dropped:0 overruns:0 frame:0
          TX packets:650 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:1472943 (1.4 MiB) TX bytes:102376 (99.9 KiB)

wlan1 Link encap:Ethernet HWaddr 2E:41:F6:19:EB:40  
          UP BROADCAST PROMISC MULTICAST MTU:1500 Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)

```

Do you have any clue on how to do that?  
thanks!  
Marco

---

<div class="post-metadata">

**Author:** ![majorz](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/majorz/32/639_2.png) [@majorz](https://forums.balena.io/u/majorz)\
**Post date:** [July 2, 2019, 3:29pm UTC](https://forums.balena.io/t/wlan-predictable-names/17422/5 "2019-07-02T15:29:44Z")

</div>

A while ago we looked into predictable interface naming for Raspberry Pi devices and we found out that it was not working very well with the Raspberry kernel.

I can recommend adding UDEV rules instead. Here is an example with renaming according to driver name used:

```auto
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="brcmfmac", NAME="wint"
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="ath9k_htc", NAME="wext"

```

UDEV rules are quite configurable and you may configure them according to your specific needs. They have a bit of steep learning curve unfortunately.

On balenaOS additional UDEV rules could be added through `config.json`: [https://github.com/balena-os/meta-balena#udevrules](https://github.com/balena-os/meta-balena#udevrules)

`udevadm info --attribute-walk -p <SYSFSPATH>` is a useful command for building up custom rules.

Please let us know if you have any questions.

---

<div class="post-metadata">

**Author:** ![ejohnso49](https://avatars.discourse-cdn.com/v4/letter/e/dc4da7/32.png) [@ejohnso49](https://forums.balena.io/u/ejohnso49)\
**Post date:** [July 3, 2019, 1:17am UTC](https://forums.balena.io/t/wlan-predictable-names/17422/7 "2019-07-03T01:17:16Z")

</div>

We implemented udev rules in our product and it is working great. When we were working on this, I did run into problems using names of the form `wlan*`. Even with udev rules, naming was not consistent. From the research I was able to do that’s because of a problem within the kernel. We ended up using `wireless*` for our stuff and have not had any problems once we moved away from `wlan*` interface names.

---

<div class="post-metadata">

**Author:** ![mikesimos](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/mikesimos/32/1418_2.png) [@mikesimos](https://forums.balena.io/u/mikesimos)\
**Post date:** [July 3, 2019, 11:14am UTC](https://forums.balena.io/t/wlan-predictable-names/17422/8 "2019-07-03T11:14:25Z")

</div>

Thanks for sharing @ejohnso49!

---

<div class="post-metadata">

**Author:** ![MarcoAbi](https://avatars.discourse-cdn.com/v4/letter/m/dfb087/32.png) [@MarcoAbi](https://forums.balena.io/u/MarcoAbi)\
**Post date:** [July 23, 2019, 11:22pm UTC](https://forums.balena.io/t/wlan-predictable-names/17422/11 "2019-07-23T23:22:41Z")

</div>

Ok, sorry to reply so late. so this is what I have reached so far:

- i’ve used UDEV rules to give predictable names and using “wiseless\*” names.
- using @ejohnso49 approach actually the system looks more stable and “wireless0” always get paired with the internal wifi network card

However, now I’m facing the issue that all the cards get connected with the wifi network, and I don’t know how to tell NetworkManager to use only 1 specific device.  
I’m also using wifi-connect’s container and I’ve set the internal wifi as default wifi to be used.

Thanks

---

<div class="post-metadata">

**Author:** ![tacLog](https://avatars.discourse-cdn.com/v4/letter/t/ecae2f/32.png) [@tacLog](https://forums.balena.io/u/tacLog)\
**Post date:** [July 24, 2019, 12:55am UTC](https://forums.balena.io/t/wlan-predictable-names/17422/12 "2019-07-24T00:55:13Z")

</div>

You can prevent network manager from setting up wifi connections with  
`nmcli dev set NAME_OF_INTERFACE managed no`

from within a container with network-manager installed see [here](https://www.balena.io/docs/reference/OS/network/2.x/#changing-the-network-at-runtime).

I just unmange all the devices I don’t want network manager to mess with.

You can also use udev rules to make the usb dongle named something different than the onboard wifi.  
You can even maintain %.

What is the make and model of the dongles you are using? I would love to test them.

-Thomas
