René's URL Explorer Experiment


Title: `async_update_interfaces()` does not recover an interface that was re-created with the same address · Issue #1947 · python-zeroconf/python-zeroconf · GitHub

Open Graph Title: `async_update_interfaces()` does not recover an interface that was re-created with the same address · Issue #1947 · python-zeroconf/python-zeroconf

X Title: `async_update_interfaces()` does not recover an interface that was re-created with the same address · Issue #1947 · python-zeroconf/python-zeroconf

Description: Summary When a network interface disappears and comes back with the same IP address (driver reset, PCI remove/rescan, USB NIC replug, ip link del + re-add), the kernel gives it a new ifindex. The existing responder socket and the listen ...

Open Graph Description: Summary When a network interface disappears and comes back with the same IP address (driver reset, PCI remove/rescan, USB NIC replug, ip link del + re-add), the kernel gives it a new ifindex. The e...

X Description: Summary When a network interface disappears and comes back with the same IP address (driver reset, PCI remove/rescan, USB NIC replug, ip link del + re-add), the kernel gives it a new ifindex. The e...

Opengraph URL: https://github.com/python-zeroconf/python-zeroconf/issues/1947

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`async_update_interfaces()` does not recover an interface that was re-created with the same address","articleBody":"### Summary\n\nWhen a network interface disappears and comes back with the same IP address (driver reset, PCI remove/rescan, USB NIC replug, `ip link del` + re-add), the kernel gives it a new ifindex. The existing responder socket and the listen socket's group membership still refer to the old ifindex, so mDNS on that interface stops working: nothing is received, and sends fail with `[Errno 101] Network unreachable`.\n\n`async_update_interfaces()` (added in #1797) doesn't recover from this. It diffs on `(address, scope_id)`, and for IPv4 (and global IPv6, scope 0) that key is the same before and after the interface is re-created, so the call is a no-op.\n\n### Reproduction\n\nzeroconf 0.154.0, Python 3.13, Linux 6.8. The script below uses a veth pair and a network namespace, so it has to run as root, e.g. `docker run --rm --privileged python:3.13-alpine` with `iproute2` installed.\n\n\u003cdetails>\u003csummary>repro.py\u003c/summary>\n\n```python\n\"\"\"Reproduce: async_update_interfaces() does not recover an interface that was\nre-created with the same address (new ifindex). Run as root (needs netns).\n\n  server: Zeroconf bound to 10.9.0.1 on veth \"va\", registers a service\n  client: a fresh Zeroconf in netns \"peer\" (10.9.0.2 on \"vb\") resolves it\n\"\"\"\nimport asyncio, os, socket, subprocess, sys\nfrom zeroconf import IPVersion, __version__\nfrom zeroconf.asyncio import AsyncServiceInfo, AsyncZeroconf\n\nTYPE, NAME = \"_test._tcp.local.\", \"Repro._test._tcp.local.\"\n\ndef sh(cmd):\n    subprocess.run(cmd, shell=True, check=True)\n\ndef make_veth():\n    sh(\"ip link add va type veth peer name vb && ip link set vb netns peer\"\n       \" && ip addr add 10.9.0.1/24 dev va && ip link set va up\"\n       \" && ip netns exec peer sh -c 'ip addr add 10.9.0.2/24 dev vb && ip link set vb up && ip link set lo up'\")\n\ndef ifindex():\n    return socket.if_nametoindex(\"va\")\n\nasync def resolve():\n    # Fresh client process each time so nothing is answered from a cache.\n    code = (\"import asyncio\\nfrom zeroconf import IPVersion\\nfrom zeroconf.asyncio import AsyncZeroconf, AsyncServiceInfo\\n\"\n            \"async def m():\\n\"\n            \" zc = AsyncZeroconf(interfaces=['10.9.0.2'], ip_version=IPVersion.V4Only)\\n\"\n            f\" i = AsyncServiceInfo('{TYPE}', '{NAME}')\\n\"\n            \" print('found' if await i.async_request(zc.zeroconf, 3000) else 'NOT FOUND')\\n\"\n            \" await zc.async_close()\\n\"\n            \"asyncio.run(m())\\n\")\n    p = await asyncio.create_subprocess_exec(\"ip\", \"netns\", \"exec\", \"peer\", sys.executable, \"-c\", code,\n                                             stdout=asyncio.subprocess.PIPE)\n    out, _ = await p.communicate()\n    return out.decode().strip()\n\nasync def main():\n    print(\"zeroconf\", __version__)\n    sh(\"ip netns add peer\")\n    make_veth()\n    aiozc = AsyncZeroconf(interfaces=[\"10.9.0.1\"], ip_version=IPVersion.V4Only)\n    info = AsyncServiceInfo(TYPE, NAME, addresses=[socket.inet_aton(\"10.9.0.1\")], port=1234,\n                            server=\"repro.local.\")\n    await aiozc.async_register_service(info)\n    print(f\"1. initial (va ifindex {ifindex()}):\", await resolve())\n\n    sh(\"ip link del va\")  # what a driver reset / PCI rescan / USB replug does\n    make_veth()\n    print(f\"2. va re-created, same address (ifindex {ifindex()}):\", await resolve())\n\n    await aiozc.zeroconf.async_update_interfaces()\n    print(\"3. after async_update_interfaces():\", await resolve())\n\n    await aiozc.zeroconf.async_update_interfaces(interfaces=[])\n    await aiozc.zeroconf.async_update_interfaces(interfaces=[\"10.9.0.1\"])\n    print(\"4. after update_interfaces([]) then (['10.9.0.1']):\", await resolve())\n    await aiozc.async_close()\n\nasyncio.run(main())\n```\n\u003c/details>\n\nOutput:\n\n```\nzeroconf 0.154.0\n1. initial (va ifindex 3): found\n2. va re-created, same address (ifindex 5): NOT FOUND\n3. after async_update_interfaces(): NOT FOUND\n4. after update_interfaces([]) then (['10.9.0.1']): found\n```\n\nMeanwhile the server logs `Error with socket ... (('10.9.0.1', 5353))): [Errno 101] Network unreachable` for its sends.\n\n### Why\n\nFor IPv4, `IP_ADD_MEMBERSHIP` and `IP_MULTICAST_IF` given an address are resolved to a device when the socket option is set. Once that device is unregistered, the membership is gone and the socket's multicast interface points at a dead ifindex. A new device with the same address doesn't revive either one. Global IPv6 addresses (scope 0) should be affected the same way. Link-local IPv6 already works, because its scope_id is the ifindex and changes with it.\n\n### Real-world impact\n\nHome Assistant runs on a host whose Intel I226 (`igc`) NIC occasionally drops its link. A watchdog recovers it with a PCI remove/rescan, so `eno1` comes back with the same address and a new index. After that, everything HA advertises over mDNS (the HomeKit bridge, `_home-assistant._tcp`) disappears from the LAN until HA restarts.\n\n### Workaround\n\nForce a full re-bind: call `async_update_interfaces(interfaces=[])`, then call it again with the real list. The caller also has to detect the re-creation itself, e.g. by polling `socket.if_nameindex()`.\n\n### Possible fix\n\nInclude the interface index in the reconcile key for IPv4 and global IPv6 too, e.g. `(address, scope_id, ifindex)`:\n- **Desired side:** resolve each address to its adapter index (`ifaddr` already exposes `adapter.index`) in `normalize_interface_choice`.\n- **Current side:** record the index when the responder socket is created, next to `multicast_index`.\n\nA changed index would then make the sender look like remove + add, and the existing code paths already handle that, including the re-announce. I'm happy to send a PR if that direction sounds right.\n","author":{"url":"https://github.com/jpc","@type":"Person","name":"jpc"},"datePublished":"2026-11-19T12:51:08Z","url":"https://github.com/python-zeroconf/python-zeroconf/issues/1947"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:ea5a8bba-5571-4e5d-574a-f59c42a27cd1
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idBC28:25CAB3:45F4:5C5B:6B007D38
html-safe-nonce3f9175f9ca3fda6a4c75c5729510de256bcb84f66e4dfffb6811bb2531136709
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCQzI4OjI1Q0FCMzo0NUY0OjVDNUI6NkIwMDdEMzgiLCJ2aXNpdG9yX2lkIjoiNjA1MjE4ODc3MjUwODkyNTI0MSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmaced542ad3e469a811f8c52c9958de303384f2078f976ee1336a769726beb41e60
hovercard-subject-tagissue:6489980688
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python-zeroconf/python-zeroconf/1947/issue_layout
twitter:imagehttps://opengraph.githubassets.com/57f339b703f96ce7c1cda923a802dd4f28d2ac013012163281ff927c9a465eff/python-zeroconf/python-zeroconf/issues/1947
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/57f339b703f96ce7c1cda923a802dd4f28d2ac013012163281ff927c9a465eff/python-zeroconf/python-zeroconf/issues/1947
og:image:altSummary When a network interface disappears and comes back with the same IP address (driver reset, PCI remove/rescan, USB NIC replug, ip link del + re-add), the kernel gives it a new ifindex. The e...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamejpc
hostnamegithub.com
expected-hostnamegithub.com
None82c186f13e104004ab7bdb779f3195e59dd38bfde531aaa74b76470fc2462b83
turbo-cache-controlno-preview
go-importgithub.com/python-zeroconf/python-zeroconf git https://github.com/python-zeroconf/python-zeroconf.git
octolytics-dimension-user_id120192235
octolytics-dimension-user_loginpython-zeroconf
octolytics-dimension-repository_id21548731
octolytics-dimension-repository_nwopython-zeroconf/python-zeroconf
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id21548731
octolytics-dimension-repository_network_root_nwopython-zeroconf/python-zeroconf
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
released1bc2aa1939001689f5ce935982c10a6138f745c
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/python-zeroconf/python-zeroconf/issues/1947#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython-zeroconf%2Fpython-zeroconf%2Fissues%2F1947
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython-zeroconf%2Fpython-zeroconf%2Fissues%2F1947
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=python-zeroconf%2Fpython-zeroconf
Reloadhttps://github.com/python-zeroconf/python-zeroconf/issues/1947
Reloadhttps://github.com/python-zeroconf/python-zeroconf/issues/1947
Reloadhttps://github.com/python-zeroconf/python-zeroconf/issues/1947
python-zeroconfhttps://github.com/python-zeroconf
python-zeroconfhttps://github.com/python-zeroconf/python-zeroconf
Codehttps://github.com/python-zeroconf/python-zeroconf
Issues50 (50)https://github.com/python-zeroconf/python-zeroconf/issues
Pull requests16 (16)https://github.com/python-zeroconf/python-zeroconf/pulls
Discussionshttps://github.com/python-zeroconf/python-zeroconf/discussions
Actionshttps://github.com/python-zeroconf/python-zeroconf/actions
Projectshttps://github.com/python-zeroconf/python-zeroconf/projects
Wikihttps://github.com/python-zeroconf/python-zeroconf/wiki
Security and quality5 (5)https://github.com/python-zeroconf/python-zeroconf/security
Insightshttps://github.com/python-zeroconf/python-zeroconf/insights
https://github.com/python-zeroconf/python-zeroconf
New issuehttps://github.com/login?return_to=https://github.com/python-zeroconf/python-zeroconf/issues/1947
New issuehttps://github.com/login?return_to=https://github.com/python-zeroconf/python-zeroconf/issues/1947
#1948https://github.com/python-zeroconf/python-zeroconf/pull/1948
async_update_interfaces() does not recover an interface that was re-created with the same addresshttps://github.com/python-zeroconf/python-zeroconf/issues/1947#top
#1948https://github.com/python-zeroconf/python-zeroconf/pull/1948
https://github.com/jpc
jpchttps://github.com/jpc
on Nov 19, 2026https://github.com/python-zeroconf/python-zeroconf/issues/1947#issue-6489980688
#1797https://github.com/python-zeroconf/python-zeroconf/pull/1797
jpchttps://github.com/jpc
on Nov 19, 2026https://github.com/python-zeroconf/python-zeroconf/issues/1947#event-36652008421
fix: re-bind an interface that was re-created with the same addresshttps://github.com/jpc/python-zeroconf/commit/588869f5eca725020753a6c96fa88af3000e2482
https://docs.github.com/articles/closing-issues-via-commit-messages
588869fhttps://github.com/jpc/python-zeroconf/commit/588869f5eca725020753a6c96fa88af3000e2482
Sign up for freehttps://github.com/signup?return_to=https://github.com/python-zeroconf/python-zeroconf/issues/1947
Sign in to commenthttps://github.com/login?return_to=https://github.com/python-zeroconf/python-zeroconf/issues/1947
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.