Skip to content

Deprioritize iPhone USB tethering below Wi-Fi#5436

Open
alansikora wants to merge 2 commits intobasecamp:masterfrom
alansikora:iphone-tether-low-priority
Open

Deprioritize iPhone USB tethering below Wi-Fi#5436
alansikora wants to merge 2 commits intobasecamp:masterfrom
alansikora:iphone-tether-low-priority

Conversation

@alansikora
Copy link
Copy Markdown
Contributor

@alansikora alansikora commented Apr 24, 2026

Summary

Plugging an iPhone into USB (even just to charge) loads the ipheth kernel driver, which exposes the phone as a generic USB ethernet device. It then matches /etc/systemd/network/20-ethernet.network (which catches eth*/en*) and gets RouteMetric=100 — beating Wi-Fi at 600 and taking over the default route the moment the phone hands out a DHCP lease. Users lose internet when simply charging their phone if the tether can't actually reach the internet (no data plan, poor signal, tethering disabled upstream).

This PR adds /etc/systemd/network/15-ipheth.network with [Match] Driver=ipheth and RouteMetric=700. systemd-networkd processes .network files in lexical order and uses the first match, so iPhone interfaces hit this file before the generic 20-ethernet.network. Wi-Fi (600) now wins when both are up; if Wi-Fi drops, the tether still takes over automatically. Real USB ethernet dongles use different drivers (CDC-ECM/NCM/RNDIS) and are unaffected.

Changes

  • default/systemd/network/15-ipheth.network — the drop-in (Driver=ipheth, metric 700, RequiredForOnline=no so boot never waits on the phone).
  • install/config/hardware/network.sh — installs the drop-in on fresh systems.
  • migrations/1777042493.sh — installs the drop-in on existing systems and reloads systemd-networkd.

Why driver-based matching

ipheth is a Linux kernel driver specific to Apple's iPhone USB tethering protocol (vendor 05ac, iPhone product IDs). It doesn't bind to iPads, Android phones, or generic USB-ethernet adapters, so Driver=ipheth is a perfect filter for "this interface came from an iPhone."

Test plan

  • Reproduced the original issue: iPhone plugged in → eth0 appears → default route moves to 172.20.10.1 at metric 100 → Wi-Fi deprioritized → internet breaks when tether has no upstream.
  • Apply the drop-in, re-plug iPhone, verify ip route shows default via 192.168.1.1 dev wlan0 ... metric 600 before the iPhone route at metric 700.
  • Turn Wi-Fi off, verify traffic falls over to the iPhone tether automatically.
  • Plug in a real USB-ethernet dongle (non-ipheth), verify it still takes priority as before at metric 100.
  • Run the migration on an existing system, confirm /etc/systemd/network/15-ipheth.network is in place and networkctl reload succeeds.

Plugging an iPhone into USB (even just to charge) loads the ipheth
kernel driver, which exposes the phone as a generic USB ethernet
device. It then matches /etc/systemd/network/20-ethernet.network
(which catches eth*/en*) and gets RouteMetric=100 — beating Wi-Fi
at 600 and taking over the default route the moment the phone hands
out a DHCP lease. This often breaks connectivity when the phone has
no data plan, poor signal, or tethering disabled upstream.

Add 15-ipheth.network with [Match] Driver=ipheth and RouteMetric=700.
systemd-networkd processes .network files in lexical order and uses
the first match, so iPhone interfaces hit this file before the
generic ethernet one. Wi-Fi (600) now wins when both are up; if
Wi-Fi drops, the tether still takes over automatically.

Install on fresh systems via install/config/hardware/network.sh, and
migrate existing systems via a new migration that also reloads
systemd-networkd.
Copilot AI review requested due to automatic review settings April 24, 2026 15:12
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR prevents iPhone USB tethering (via the ipheth driver) from taking over the default route when connected, by shipping a dedicated systemd-networkd match with a higher route metric than Wi‑Fi.

Changes:

  • Add default/systemd/network/15-ipheth.network to match Driver=ipheth and set RouteMetric=700 (plus RequiredForOnline=no).
  • Install the drop-in on fresh installs via install/config/hardware/network.sh.
  • Install the drop-in on existing systems via migrations/1777042493.sh and reload systemd-networkd.

Tip

If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or run gh pr ready --undo.
Click "Ready for review" or run gh pr ready to reengage.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
default/systemd/network/15-ipheth.network Adds a networkd match for ipheth interfaces to deprioritize iPhone tethering routes.
install/config/hardware/network.sh Copies the new .network drop-in into /etc/systemd/network during fresh installs.
migrations/1777042493.sh Migrates existing systems by copying the drop-in and reloading networkd.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread install/config/hardware/network.sh
Comment thread migrations/1777042493.sh
Copilot review noted cp would fail under set -e on fresh systems
where /etc/systemd/network doesn't exist yet.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants