Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Giving wlan0 priority over eth0
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Gentoo on ARM
View previous topic :: View next topic  
Author Message
thegrind
n00b
n00b


Joined: 22 Sep 2024
Posts: 22

PostPosted: Wed Nov 06, 2024 5:12 am    Post subject: Giving wlan0 priority over eth0 Reply with quote

I have installed Gentoo on my RPi5. The Pi has a connection for the ethernet cable and wifi. I have them both connected and they both have different local ips so for example eth0 has 192.168.1.10 and wlan0 has 192.168.1.11. My wifi connection is faster so I would like to use this is as the default interface but every time I boot it defaults to eth0. Does anyone know how I can set this up. I did it before with NetworkManager by using nmcli and setting a priority so I'd like to see if I could do something similar with iwd instead of having to switch to NM.
Back to top
View user's profile Send private message
pingtoo
Veteran
Veteran


Joined: 10 Sep 2021
Posts: 1251
Location: Richmond Hill, Canada

PostPosted: Wed Nov 06, 2024 7:19 am    Post subject: Reply with quote

Have you tried with nmcli?

I don't use wifi for my rpi5, but nmcli does show
Code:
rpi5 ~ # nmcli
end0: connected to Wired connection 1
        "end0"
        ethernet (macb), 2C:xx:xx:xx:xx:xx, hw, mtu 1500
        ip4 default
        inet4 192.168.xx.xx/24
        route4 192.168.xx.0/24 metric 100
        route4 default via 192.168.xx.xx metric 100

docker0: connected (externally) to docker0
        "docker0"
        bridge, 02:42:C0:5D:C6:4F, sw, mtu 1500
        inet4 172.17.0.1/16
        route4 172.17.0.0/16 metric 0
        inet6 fe80::42:c0ff:fe5d:c64f/64
        route6 fe80::/64 metric 256

lo: connected (externally) to lo
        "lo"
        loopback (unknown), 00:00:00:00:00:00, sw, mtu 65536
        inet4 127.0.0.1/8
        inet6 ::1/128

wlan0: unavailable
        "Broadcom Wi-Fi"
        wifi (brcmfmac), xx:xx:xx:xx:xx:xx, sw disabled, hw, mtu 1500

DNS configuration:
        servers: 192.168.xx.xx
        domains: home
        interface: end0

Use "nmcli device show" to get complete information about known devices and
"nmcli connection show" to get an overview on active connection profiles.

Consult nmcli(1) and nmcli-examples(7) manual pages for complete usage details.
rpi5 ~ #


And networkcli show
Code:
rpi5 ~ # networkctl
IDX LINK    TYPE     OPERATIONAL SETUP   
  1 lo      loopback -           unmanaged
  2 end0    ether    -           unmanaged
  3 wlan0   wlan     -           unmanaged
  4 docker0 bridge   -           unmanaged

4 links listed.
Back to top
View user's profile Send private message
szatox
Advocate
Advocate


Joined: 27 Aug 2013
Posts: 3439

PostPosted: Wed Nov 06, 2024 9:01 am    Post subject: Reply with quote

1) Why not just unplug the wire if you don't want to use it anyway?
2) What do you use to manage wired connection? I though iwd handles wireless part and is a replacement for wpa_supplicant rather than networkmanager, am I wrong about it?
_________________
Make Computing Fun Again
Back to top
View user's profile Send private message
thegrind
n00b
n00b


Joined: 22 Sep 2024
Posts: 22

PostPosted: Thu Nov 07, 2024 1:56 am    Post subject: Reply with quote

pingtoo wrote:
Have you tried with nmcli?

I don't use wifi for my rpi5, but nmcli does show
Code:
rpi5 ~ # nmcli
end0: connected to Wired connection 1
        "end0"
        ethernet (macb), 2C:xx:xx:xx:xx:xx, hw, mtu 1500
        ip4 default
        inet4 192.168.xx.xx/24
        route4 192.168.xx.0/24 metric 100
        route4 default via 192.168.xx.xx metric 100

docker0: connected (externally) to docker0
        "docker0"
        bridge, 02:42:C0:5D:C6:4F, sw, mtu 1500
        inet4 172.17.0.1/16
        route4 172.17.0.0/16 metric 0
        inet6 fe80::42:c0ff:fe5d:c64f/64
        route6 fe80::/64 metric 256

lo: connected (externally) to lo
        "lo"
        loopback (unknown), 00:00:00:00:00:00, sw, mtu 65536
        inet4 127.0.0.1/8
        inet6 ::1/128

wlan0: unavailable
        "Broadcom Wi-Fi"
        wifi (brcmfmac), xx:xx:xx:xx:xx:xx, sw disabled, hw, mtu 1500

DNS configuration:
        servers: 192.168.xx.xx
        domains: home
        interface: end0

Use "nmcli device show" to get complete information about known devices and
"nmcli connection show" to get an overview on active connection profiles.

Consult nmcli(1) and nmcli-examples(7) manual pages for complete usage details.
rpi5 ~ #


And networkcli show
Code:
rpi5 ~ # networkctl
IDX LINK    TYPE     OPERATIONAL SETUP   
  1 lo      loopback -           unmanaged
  2 end0    ether    -           unmanaged
  3 wlan0   wlan     -           unmanaged
  4 docker0 bridge   -           unmanaged

4 links listed.

I didn't install NetworkManager on this install thus I don't have nmcli as I am just using iwd. I had it working on my previous microsd with NM as it was fairly easy. The problem I've been having with the PI5 on both Arch (using wpa_supplicant) and Getntoo (NM) is the network interfaces freezing up randomly. Sometimes after a half day sometimes after a couple of days. I would like to try to make it work with iwd but I'm not sure if this is doable.
Back to top
View user's profile Send private message
thegrind
n00b
n00b


Joined: 22 Sep 2024
Posts: 22

PostPosted: Thu Nov 07, 2024 2:01 am    Post subject: Reply with quote

szatox wrote:
1) Why not just unplug the wire if you don't want to use it anyway?
2) What do you use to manage wired connection? I though iwd handles wireless part and is a replacement for wpa_supplicant rather than networkmanager, am I wrong about it?

1. It seems any large emerge doesn't do well with wifi so I like to keep plugged in and then I can just up or down the network interface I don't want to use.
2. I'm not sure what manages eth0. Naturally the wifi is managed by iwd. This is probably why I can't set a priority since they are two different managers. I'll just try to work off wifi and see how it goes or buy a new wall outlet ethernet connection with a high speed one as my current one is 100MB/sec
Back to top
View user's profile Send private message
flexibeast
Guru
Guru


Joined: 04 Apr 2022
Posts: 452
Location: Naarm/Melbourne, Australia

PostPosted: Thu Nov 07, 2024 4:52 am    Post subject: Reply with quote

Since you use `networkctl` i presume you're on a systemd-based setup. i'm not a systemd user myself, so i can't help with specifics, but what i can say is that you need to specify a routing metric for each interface so that the wired interface has a higher priority. (On an OpenRC+netifrc system, like i have, one specifies these metrics in the /etc/conf.d/net configuration file.)
_________________
https://wiki.gentoo.org/wiki/User:Flexibeast
Back to top
View user's profile Send private message
szatox
Advocate
Advocate


Joined: 27 Aug 2013
Posts: 3439

PostPosted: Thu Nov 07, 2024 8:51 am    Post subject: Reply with quote

Well, the rules for selecting the outgoing interface go like this:
1 Find all interfaces with routing rules containing the destination
2 Order them by mask (longer mask = higher priority)
3 Break ties with metrics (lower cost/number = higher priority)

Wifi's default metric is like 600, and ethernet's default metric depends on interface speed, but will always be lower. And here comes trick from OpenVPN:
add 2 routes to your wifi, to 0.0.0.0/1 and 128.0.0.0/1
Those will override the default gateway ( 0/0 ) regardless of metrics. And you can do the same with ipv6 address space. It is a bit of a hack, but other things are unlikely to mess this setup up even if they try.

Quote:
I'm not sure what manages eth0
Ah, I'm not sure what. Yes, this one is known to cause problems.

Quote:
It seems any large emerge doesn't do well with wifi

That's weird. Can you explain that part more? This also looks like the actual problem you should be solving instead of doing workarounds on your network. What's going wrong there?
One thing that comes to my mind is that maybe your power supply is not strong enough to radiate power while spinning all cores at full throttle.
_________________
Make Computing Fun Again
Back to top
View user's profile Send private message
thegrind
n00b
n00b


Joined: 22 Sep 2024
Posts: 22

PostPosted: Fri Nov 08, 2024 5:18 am    Post subject: Reply with quote

flexibeast wrote:
Since you use `networkctl` i presume you're on a systemd-based setup. i'm not a systemd user myself, so i can't help with specifics, but what i can say is that you need to specify a routing metric for each interface so that the wired interface has a higher priority. (On an OpenRC+netifrc system, like i have, one specifies these metrics in the /etc/conf.d/net configuration file.)

Thanks for the help. I am not using systemd as I am using openrc. I tried the adding the priority to the /etc/conf.d/net but this didn't change. I assume that Netifrc can't control wlan0 at least I didn't see it in the Wiki. I don't have networkctl as a command.
Back to top
View user's profile Send private message
thegrind
n00b
n00b


Joined: 22 Sep 2024
Posts: 22

PostPosted: Fri Nov 08, 2024 5:25 am    Post subject: Reply with quote

szatox wrote:
Well, the rules for selecting the outgoing interface go like this:
1 Find all interfaces with routing rules containing the destination
2 Order them by mask (longer mask = higher priority)
3 Break ties with metrics (lower cost/number = higher priority)

Wifi's default metric is like 600, and ethernet's default metric depends on interface speed, but will always be lower. And here comes trick from OpenVPN:
add 2 routes to your wifi, to 0.0.0.0/1 and 128.0.0.0/1
Those will override the default gateway ( 0/0 ) regardless of metrics. And you can do the same with ipv6 address space. It is a bit of a hack, but other things are unlikely to mess this setup up even if they try.

Quote:
I'm not sure what manages eth0
Ah, I'm not sure what. Yes, this one is known to cause problems.

Quote:
It seems any large emerge doesn't do well with wifi

That's weird. Can you explain that part more? This also looks like the actual problem you should be solving instead of doing workarounds on your network. What's going wrong there?
One thing that comes to my mind is that maybe your power supply is not strong enough to radiate power while spinning all cores at full throttle.


I'm not sure what the problem is. I had the same issue when trying to do a git pull as it would stall and give me a timeout error. I was trying to dl the kernel so I could compile. I dl the kernel sources by hooking up my Pi directly to the router. I ended up cross compiling in the end as I have a hdd on my Manjaro PC amd64. I am using the same power supply I had with my 3+ I think it is 4W and I think the Pi 5 wants 5W. I figured I wasn't connecting any disks to it so I thought would be okay.

I figured from reading that it would chose the wlan0 as it is twice as fast as my eth0 but it still defaults to eth0.

How do you do the OpenVPN trick? That's ultimately what I would like to do.
Back to top
View user's profile Send private message
flexibeast
Guru
Guru


Joined: 04 Apr 2022
Posts: 452
Location: Naarm/Melbourne, Australia

PostPosted: Fri Nov 08, 2024 5:51 am    Post subject: Reply with quote

thegrind wrote:
[I am not using systemd as I am using openrc.

Oh, sorry, i read your command `networkcli` as `networkctl`. :-/ i definitely need new glasses!

thegrind wrote:
I tried the adding the priority to the /etc/conf.d/net but this didn't change. I assume that Netifrc can't control wlan0 at least I didn't see it in the Wiki.

It definitely can; i do so on my own system (well, the interface is actually called `wlp2s0`, but without persistent names, it's `wlan0`, and i've used netifrc to configure both). But for this to happen, you need to have configured your system appropriately, including creating a symlink for each interface you want netifrc to manage, configuring which program you want to use for a given interface (e.g `wpa_supplicant` or `iwd`), and starting an OpenRC service for each interface via those symlinks. i recommend reading the netifrc wiki page in full to understand what needs to be done.

i currently configure netifrc to use wpa_supplicant for the wifi interface; i haven't got it working with iwd yet.
_________________
https://wiki.gentoo.org/wiki/User:Flexibeast
Back to top
View user's profile Send private message
szatox
Advocate
Advocate


Joined: 27 Aug 2013
Posts: 3439

PostPosted: Fri Nov 08, 2024 10:39 am    Post subject: Reply with quote

You can check routing table with
ip route
Add and remove rules manually with ip route add/del <rule> respectively.
Doing it automatically requires you to know what manages your network, so you can configure that thing to do your bidding correctly.

I still think you're over-engineering it though. If you want to use wifi because it's faster, but disable it for updates, you might just as well use wifi and enable eth for updates.
Also, depending on your actual use patterns, that speed difference between eth and wifi might not even matter, making the cable a better choice overall.
_________________
Make Computing Fun Again
Back to top
View user's profile Send private message
thegrind
n00b
n00b


Joined: 22 Sep 2024
Posts: 22

PostPosted: Tue Nov 19, 2024 6:06 pm    Post subject: Reply with quote

Code:
k@localhost ~ $ rc-update -v show
       NetworkManager |
               agetty |
                  atd |      default
               binfmt | boot
            bluetooth |      default
             bootlogd |
             bootmisc | boot
              cgroups |                                 sysinit
              chronyd |      default
          consolefont |
                 dbus |
                dcron |      default
                devfs |                                 sysinit
               dhcpcd |      default
                dmesg |                                 sysinit
                 fsck | boot
           git-daemon |
             hostname | boot
              hwclock | boot
            ip6tables |
             iptables |
                  iwd | boot
              keymaps | boot
            killprocs |                        shutdown
    kmod-static-nodes |                                 sysinit
                 kodi |      default
                local |      default nonetwork
           localmount | boot
             loopback | boot
              metalog |
      mit-krb5kadmind |
          mit-krb5kdc |
       mit-krb5kpropd |
         modemmanager |
              modules | boot
             mount-ro |                        shutdown
                 mtab | boot
           net-online |
             net.eth0 |
               net.lo |
            net.wlan0 |
             netmount |      default
           nullmailer |
              numlock |
              openvpn |
              osclock |
               procfs | boot
           pydoc-3.12 |
           pydoc-3.13 |
                 root | boot
               rsyncd |
             runsvdir |
            s6-svscan |
                samba |      default
         save-keymaps | boot
    save-termencoding | boot
            savecache |                        shutdown
              seedrng | boot
                 sshd |      default
                 swap | boot
              swclock |
               sysctl | boot
                sysfs |                                 sysinit
 systemd-tmpfiles-setup | boot
 systemd-tmpfiles-setup-dev |                                 sysinit
         termencoding | boot
                 udev |                                 sysinit
          udev-settle |
         udev-trigger |                                 sysinit
       wpa_supplicant |


I am looking to bond wlan0 (started with iwd) and eth0 but I cannot tell what is starting my ethernet connection as it's [/code]not started by net.lo.
Back to top
View user's profile Send private message
Ralphred
l33t
l33t


Joined: 31 Dec 2013
Posts: 654

PostPosted: Tue Nov 19, 2024 6:28 pm    Post subject: Reply with quote

thegrind wrote:
but I cannot tell what is starting my ethernet connection
It doesn't matter if you bond them, you can delete both the net.eth0 and net.wlan0 symlinks from /etc/init.d/ in favour of net.bond0
Back to top
View user's profile Send private message
pingtoo
Veteran
Veteran


Joined: 10 Sep 2021
Posts: 1251
Location: Richmond Hill, Canada

PostPosted: Tue Nov 19, 2024 6:29 pm    Post subject: Reply with quote

I think it is dhcpcd start it.

Check dmesg for dhcpcd messages.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Gentoo on ARM All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum