Deprioritize iPhone USB tethering below Wi-Fi#5434
Closed
alansikora wants to merge 1 commit intobasecamp:masterfrom
Closed
Deprioritize iPhone USB tethering below Wi-Fi#5434alansikora wants to merge 1 commit intobasecamp:masterfrom
alansikora wants to merge 1 commit intobasecamp:masterfrom
Conversation
Contributor
There was a problem hiding this comment.
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:iphethand 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.
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.
2d5e2a1 to
feb86e6
Compare
Contributor
Author
|
Sorry about this one, Claude hallucinated and created a branch and a PR without being asked to. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Plugging an iPhone into USB (even just to charge) loads the
iphethkernel driver, which exposes the phone as a generic USB ethernet device. It then matches/etc/systemd/network/20-ethernet.network(which catcheseth*/en*) and getsRouteMetric=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.networkwith[Match] Driver=iphethandRouteMetric=700. systemd-networkd processes.networkfiles in lexical order and uses the first match, so iPhone interfaces hit this file before the generic20-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=noso 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
iphethis a Linux kernel driver specific to Apple's iPhone USB tethering protocol (vendor05ac, iPhone product IDs). It doesn't bind to iPads, Android phones, or generic USB-ethernet adapters, soDriver=iphethis a perfect filter for "this interface came from an iPhone."Test plan
eth0appears → default route moves to172.20.10.1at metric 100 → Wi-Fi deprioritized → internet breaks when tether has no upstream.ip routeshowsdefault via 192.168.1.1 dev wlan0 ... metric 600before the iPhone route at metric 700./etc/systemd/network/15-ipheth.networkis in place andnetworkctl reloadsucceeds.🤖 Generated with Claude Code