Skip to content

Deprioritize iPhone USB tethering below Wi-Fi#5434

Closed
alansikora wants to merge 1 commit intobasecamp:masterfrom
alansikora:deprioritize-iphone-tether-route
Closed

Deprioritize iPhone USB tethering below Wi-Fi#5434
alansikora wants to merge 1 commit intobasecamp:masterfrom
alansikora:deprioritize-iphone-tether-route

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.

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings April 24, 2026 14:56
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 kernel driver) from taking over the system default route when an iPhone is plugged in, by lowering its routing priority below Wi‑Fi using a NetworkManager config drop-in.

Changes:

  • Add a NetworkManager drop-in that matches driver:ipheth and sets IPv4/IPv6 route metrics to 700.
  • Install the drop-in during fresh installs.
  • Add a migration to deploy the drop-in on existing systems and reload NetworkManager.

Reviewed changes

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

File Description
default/NetworkManager/conf.d/10-ipheth-low-priority.conf Adds a driver-specific match section to raise ipheth route metrics above Wi‑Fi.
install/config/hardware/network.sh Installs the new NetworkManager drop-in on fresh installs.
migrations/1777042493.sh Migrates existing systems by copying the drop-in into /etc and reloading NetworkManager.

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.


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

Comment thread migrations/1777042493.sh Outdated
Comment thread install/config/hardware/network.sh Outdated
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.
@alansikora alansikora force-pushed the deprioritize-iphone-tether-route branch from 2d5e2a1 to feb86e6 Compare April 24, 2026 15:09
@alansikora
Copy link
Copy Markdown
Contributor Author

alansikora commented Apr 24, 2026

Sorry about this one, Claude hallucinated and created a branch and a PR without being asked to.

@alansikora alansikora closed this Apr 24, 2026
@alansikora alansikora deleted the deprioritize-iphone-tether-route branch April 24, 2026 15:12
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