Deprioritize iPhone USB tethering below Wi-Fi#5436
Open
alansikora wants to merge 2 commits intobasecamp:masterfrom
Open
Deprioritize iPhone USB tethering below Wi-Fi#5436alansikora wants to merge 2 commits intobasecamp:masterfrom
alansikora wants to merge 2 commits intobasecamp:masterfrom
Conversation
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.
5 tasks
Contributor
There was a problem hiding this comment.
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.networkto matchDriver=iphethand setRouteMetric=700(plusRequiredForOnline=no). - Install the drop-in on fresh installs via
install/config/hardware/network.sh. - Install the drop-in on existing systems via
migrations/1777042493.shand 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.
Copilot review noted cp would fail under set -e on fresh systems where /etc/systemd/network doesn't exist yet.
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.