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: 14

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: 1228
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: 3412

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: 14

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: 14

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: 433
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: 3412

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
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