# Sorting of network interfaces

**URL:** <https://forums.rockylinux.org/t/sorting-of-network-interfaces/8130>\
**Category:** Rocky Linux Help & Support\
**Created:** [December 3, 2022, 5:15pm UTC](https://forums.rockylinux.org/t/sorting-of-network-interfaces/8130 "2022-12-03T17:15:41Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![vecino](https://avatars.discourse-cdn.com/v4/letter/v/a587f6/32.png) [@vecino](https://forums.rockylinux.org/u/vecino)\
**Post date:** [December 3, 2022, 5:15pm UTC](https://forums.rockylinux.org/t/sorting-of-network-interfaces/8130/1 "2022-12-03T17:15:41Z")

</div>

Hello everyone, I know this is probably a stupid question, but I would like to solve it.

How can I get the interfaces to line up one after the other … ie: vlan102, vlan103, vlan600 and vlan1000 ?

I came from Debian 11 and it sorts automatically there. I haven’t figured out a way to achieve this yet. Can someone advise me?

```auto
[root@router ~]# ip -4 a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
2: enp1s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    inet 10.107.x.x/30 brd 10.107.x.x scope global noprefixroute enp1s0
       valid_lft forever preferred_lft forever
5: vlan600@enp1s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    inet 10.20.x.x/26 brd 10.20.x.x scope global noprefixroute vlan600
       valid_lft forever preferred_lft forever
6: vlan103@enp1s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    inet 10.107.x.x/29 brd 10.107.x.x scope global noprefixroute vlan103
       valid_lft forever preferred_lft forever
7: vlan1000@enp1s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    inet 10.123.x.x/29 brd 10.123.x.x scope global noprefixroute vlan1000
       valid_lft forever preferred_lft forever
8: vlan102@enp1s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    inet 10.107.x.x/29 brd 10.107.x.x scope global noprefixroute vlan102
       valid_lft forever preferred_lft forever

```

Thanks

vecino

---

<div class="post-metadata">

**Author:** ![jlehtone](https://avatars.discourse-cdn.com/v4/letter/j/e9a140/32.png) [@jlehtone](https://forums.rockylinux.org/u/jlehtone)\
**Post date:** [December 3, 2022, 6:03pm UTC](https://forums.rockylinux.org/t/sorting-of-network-interfaces/8130/2 "2022-12-03T18:03:15Z")

</div>

I’ve never even realized that there should/could be some order. Hence, no idea.

Furthermore, network configuration is by NetworkManager by default. While `ip` remains a useful “What do we have?”, the NM offers others. For example:

```nohighlight
nmcli
nmcli c s
nmcli d s
nmcli d show

```

Is it possible that order is as the interfaces were created and that Debian creates them in “apparently sorted” order?

---

<div class="post-metadata">

**Author:** ![vecino](https://avatars.discourse-cdn.com/v4/letter/v/a587f6/32.png) [@vecino](https://forums.rockylinux.org/u/vecino)\
**Post date:** [December 3, 2022, 6:36pm UTC](https://forums.rockylinux.org/t/sorting-of-network-interfaces/8130/3 "2022-12-03T18:36:38Z")

</div>

Debian ranks them in order. Even if I add the vlans differently, not consecutively.

Thanks for the tip on nmcli, it’s totally new to me. I will look at it.

```auto
[root@router ~]# nmcli d s
DEVICE TYPE STATE CONNECTION 
enp1s0 ethernet connected enp1s0     
vlan1000 vlan connected vlan1000   
vlan600 vlan connected vlan600    
vlan102 vlan connected vlan102    
vlan103 vlan connected vlan103    
wg0 wireguard connected WireGuard  
enp2s0 ethernet unavailable --         
enp3s0 ethernet unavailable --         
lo loopback unmanaged -- 

```

I don’t think there’s anywhere for NetworkManager to say in which order it should sort it, right?

There are /org/freedesktop/NetworkManager/Devices/1 - 9, but I don’t know if I can interfere in any way…

```auto
Dec 03 18:51:52 router NetworkManager[731]: <info> [1670089912.4983] manager: (lo): new Generic device (/org/freedesktop/NetworkManager/Devices/1)
Dec 03 18:51:52 router NetworkManager[731]: <info> [1670089912.5081] manager: (enp1s0): new Ethernet device (/org/freedesktop/NetworkManager/Devices/2)
Dec 03 18:51:52 router NetworkManager[731]: <info> [1670089912.5123] device (enp1s0): state change: unmanaged -> unavailable (reason 'managed', sys-iface-state: 'external')
Dec 03 18:51:52 router NetworkManager[731]: <info> [1670089912.5571] manager: (vlan600): new VLAN device (/org/freedesktop/NetworkManager/Devices/3)
Dec 03 18:51:52 router NetworkManager[731]: <info> [1670089912.6871] device (vlan600): state change: unmanaged -> unavailable (reason 'managed', sys-iface-state: 'external')
Dec 03 18:51:52 router NetworkManager[731]: <info> [1670089912.7185] manager: (vlan103): new VLAN device (/org/freedesktop/NetworkManager/Devices/4)
Dec 03 18:51:52 router NetworkManager[731]: <info> [1670089912.7537] device (vlan103): state change: unmanaged -> unavailable (reason 'managed', sys-iface-state: 'external')
Dec 03 18:51:52 router NetworkManager[731]: <info> [1670089912.7813] manager: (vlan1000): new VLAN device (/org/freedesktop/NetworkManager/Devices/5)
Dec 03 18:51:52 router NetworkManager[731]: <info> [1670089912.7990] device (vlan1000): state change: unmanaged -> unavailable (reason 'managed', sys-iface-state: 'external')
Dec 03 18:51:52 router NetworkManager[731]: <info> [1670089912.8135] manager: (vlan102): new VLAN device (/org/freedesktop/NetworkManager/Devices/6)
Dec 03 18:51:52 router NetworkManager[731]: <info> [1670089912.8354] device (vlan102): state change: unmanaged -> unavailable (reason 'managed', sys-iface-state: 'external')
Dec 03 18:51:52 router NetworkManager[731]: <info> [1670089912.8619] manager: (enp2s0): new Ethernet device (/org/freedesktop/NetworkManager/Devices/7)
Dec 03 18:51:52 router NetworkManager[731]: <info> [1670089912.8661] device (enp2s0): state change: unmanaged -> unavailable (reason 'managed', sys-iface-state: 'external')
Dec 03 18:51:52 router NetworkManager[731]: <info> [1670089912.9245] manager: (enp3s0): new Ethernet device (/org/freedesktop/NetworkManager/Devices/8)
Dec 03 18:51:52 router NetworkManager[731]: <info> [1670089912.9284] device (enp3s0): state change: unmanaged -> unavailable (reason 'managed', sys-iface-state: 'external')
Dec 03 18:51:52 router NetworkManager[731]: <info> [1670089912.9923] manager: (wg0): new WireGuard device (/org/freedesktop/NetworkManager/Devices/9)

```

---

<div class="post-metadata">

**Author:** ![zaffiro](https://avatars.discourse-cdn.com/v4/letter/z/0ea827/32.png) [@zaffiro](https://forums.rockylinux.org/u/zaffiro)\
**Post date:** [December 4, 2022, 12:06pm UTC](https://forums.rockylinux.org/t/sorting-of-network-interfaces/8130/4 "2022-12-04T12:06:14Z")

</div>

I think you can try the brief option of ip command, then pipe through sort and play with its options, like:

```auto
ip -br addr show | sort

```

---

<div class="post-metadata">

**Author:** ![vecino](https://avatars.discourse-cdn.com/v4/letter/v/a587f6/32.png) [@vecino](https://forums.rockylinux.org/u/vecino)\
**Post date:** [December 4, 2022, 2:46pm UTC](https://forums.rockylinux.org/t/sorting-of-network-interfaces/8130/5 "2022-12-04T14:46:23Z")

</div>

Thanks for the tip - I’ll definitely try it.

Do you think the ordering is affected by udev or directly by NetworkManager? I would like to look at the source codes if it would be possible to modify it.

---

<div class="post-metadata">

**Author:** ![zaffiro](https://avatars.discourse-cdn.com/v4/letter/z/0ea827/32.png) [@zaffiro](https://forums.rockylinux.org/u/zaffiro)\
**Post date:** [December 4, 2022, 3:12pm UTC](https://forums.rockylinux.org/t/sorting-of-network-interfaces/8130/6 "2022-12-04T15:12:13Z")

</div>

As far as I know, it’s the udev that decides the naming scheme. Because we don’t have problem with naming scheme here, but rather how to display it, I think we should look at or modify the command that does the display, i.e. “ip addr” command. But I’m not an expert on this so I might be wrong 🙂

---

<div class="post-metadata">

**Author:** ![vecino](https://avatars.discourse-cdn.com/v4/letter/v/a587f6/32.png) [@vecino](https://forums.rockylinux.org/u/vecino)\
**Post date:** [December 4, 2022, 6:29pm UTC](https://forums.rockylinux.org/t/sorting-of-network-interfaces/8130/7 "2022-12-04T18:29:01Z")

</div>

A friend of mine who is very experienced in Linux explained it to me:

> The whole thing is created by ip addr ordering it according to ifIndex, which is created by how interfaces are added. Nmcli adds it all at once in parallel, the init script is loaded lined up - that’s why init runs nicely. The whole problem with init is that almost any change requires a reboot, which nmcli solves.

So it makes no sense to deal with it and it is better to reorient to NetworkManager / nmcli.

---

<div class="post-metadata">

**Author:** ![vecino](https://avatars.discourse-cdn.com/v4/letter/v/a587f6/32.png) [@vecino](https://forums.rockylinux.org/u/vecino)\
**Post date:** [December 30, 2022, 10:22pm UTC](https://forums.rockylinux.org/t/sorting-of-network-interfaces/8130/8 "2022-12-30T22:22:17Z")

</div>

Hi, I found a solution: [https://developer-old.gnome.org/NetworkManager/stable/settings-connection.html](https://developer-old.gnome.org/NetworkManager/stable/settings-connection.html)

**autoconnect-priority**  
`The autoconnect priority. If the connection is set to autoconnect, connections with higher priority will be preferred. Defaults to 0. The higher number means higher priority.`

So, depending on how you want to sort the vlans, you can set, for example:

vlan100 = autoconnect-priority 100  
vlan200 = autoconnect-priority 90  
vlan300 = autoconnect-priority 80  
etc

Yes, I know it’s probably stupid for you, but it made me happy. 🙂

---

<div class="post-metadata">

**Author:** ![zaffiro](https://avatars.discourse-cdn.com/v4/letter/z/0ea827/32.png) [@zaffiro](https://forums.rockylinux.org/u/zaffiro)\
**Post date:** [January 14, 2023, 4:20pm UTC](https://forums.rockylinux.org/t/sorting-of-network-interfaces/8130/9 "2023-01-14T16:20:46Z")

</div>

Haha, not at all. Thank you for sharing. Just curious, maybe you have OCD? I think I also have one, so I understand why you want things in a specific order 🙂

---

<div class="post-metadata">

**Author:** ![vecino](https://avatars.discourse-cdn.com/v4/letter/v/a587f6/32.png) [@vecino](https://forums.rockylinux.org/u/vecino)\
**Post date:** [January 14, 2023, 7:45pm UTC](https://forums.rockylinux.org/t/sorting-of-network-interfaces/8130/10 "2023-01-14T19:45:10Z")

</div>

What OCD? Damn, I have to go straighten the clothes in the closet again (last time I did it 5 minutes ago)… 😂

I have, for example, more than 10 VLANs on one router … and thanks to this arrangement, it is much clearer for me.

---

<div class="post-metadata">

**Author:** ![zaffiro](https://avatars.discourse-cdn.com/v4/letter/z/0ea827/32.png) [@zaffiro](https://forums.rockylinux.org/u/zaffiro)\
**Post date:** [January 16, 2023, 2:11am UTC](https://forums.rockylinux.org/t/sorting-of-network-interfaces/8130/11 "2023-01-16T02:11:05Z")

</div>

Well, looks like you really have OCD. It’s obsessive compulsive disorder. You can search and read more about it. It’s nothing to worry about though. I’ve just recently realized that I may also have it because of the needs to check things over and over again 🙂

---

<div class="post-metadata">

**Author:** ![vecino](https://avatars.discourse-cdn.com/v4/letter/v/a587f6/32.png) [@vecino](https://forums.rockylinux.org/u/vecino)\
**Post date:** [January 16, 2023, 7:02am UTC](https://forums.rockylinux.org/t/sorting-of-network-interfaces/8130/12 "2023-01-16T07:02:57Z")

</div>

I was joking of course. I didn’t mean it. It’s called humor. 😃

---

<div class="post-metadata">

**Author:** ![brian](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.rockylinux.org/brian/32/5777_2.png) [@brian](https://forums.rockylinux.org/u/brian)\
**Post date:** [August 25, 2023, 3:28am UTC](https://forums.rockylinux.org/t/sorting-of-network-interfaces/8130/13 "2023-08-25T03:28:09Z")

</div>


