傳入的 UDP 多播流在 macOS 上的固定時間後停止
我的 ISP 提供 IPTV 功能,流範例:
udp://@239.255.2.97:5500
. 我想在 macOS 上觀看 IPTV,所以我使用了 VLC。最初,IPTV 根本不起作用。起初我以為它以某種方式鎖定到了 ISP 的媒體盒。然後我在各種設備上進行了測試,它無處不在:執行 Windows 的同一台 Mac、Apple TV、Redmi 手機和各種 iOS 設備。經過一番Google搜尋後,我找到了解決方案:
sudo sysctl net.inet.igmp.sendra=0
在終端中執行使 VLC 播放流。(不需要強制預設版本為 2)但後來我注意到流恰好在 04:20 ±1 秒後停止,只有重新啟動流才能讓它再次播放。這不會發生在上面提到的任何其他設備/平台上。我有 2 台 Mac——mbp 執行 Mojave(SIP 關閉)和 mini 執行 Catalina(SIP 開啟)——兩者都發生,有線/無線連接沒有區別,以及使用的軟體(嘗試過 VLC 和 Kodi)。
我完全不知道如何解決這個問題,並且在網際網路上找不到任何相關的東西,非常感謝您的幫助。
我會提供您需要的任何資訊,最好請發布必要的命令以獲得所需的資訊。
兩台 Mac 上的預設 IGMP 設置相同:
❯ sysctl net.inet.igmp net.inet.igmp.recvifkludge: 1 net.inet.igmp.sendra: 1 net.inet.igmp.sendlocal: 1 net.inet.igmp.v1enable: 1 net.inet.igmp.v2enable: 1 net.inet.igmp.legacysupp: 0 net.inet.igmp.default_version: 3 net.inet.igmp.gsrdelay: 10 net.inet.igmp.debug: 0
ifconfig -a
如果有幫助,這是我的 Mac:無線 MBP:
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384 options=1203<RXCSUM,TXCSUM,TXSTATUS,SW_TIMESTAMP> inet 127.0.0.1 netmask 0xff000000 inet6 ::1 prefixlen 128 inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1 nd6 options=201<PERFORMNUD,DAD> gif0: flags=8010<POINTOPOINT,MULTICAST> mtu 1280 stf0: flags=0<> mtu 1280 EHC250: flags=0<> mtu 0 EHC253: flags=0<> mtu 0 en0: flags=8963<UP,BROADCAST,SMART,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500 options=b<RXCSUM,TXCSUM,VLAN_HWTAGGING> ether 58:b0:35:f4:e6:de nd6 options=201<PERFORMNUD,DAD> media: autoselect (none) status: inactive en1: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500 ether 58:b0:35:7a:2f:13 inet6 fe80::108d:a3b7:c229:4e24%en1 prefixlen 64 secured scopeid 0x7 inet 192.168.1.69 netmask 0xffffff00 broadcast 192.168.1.255 inet6 2a00:1370:8131:b399:803:904:7e51:a50b prefixlen 64 autoconf secured inet6 2a00:1370:8131:b399:7944:3d6c:3303:58b prefixlen 64 autoconf temporary inet6 2a00:1370:8131:b399:f628:52b3:28ae:8d54 prefixlen 64 dynamic nd6 options=201<PERFORMNUD,DAD> media: autoselect status: active fw0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 4078 lladdr d8:30:62:ff:fe:f0:e9:aa nd6 options=201<PERFORMNUD,DAD> media: autoselect <full-duplex> status: inactive p2p0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 2304 ether 0a:b0:35:7a:2f:13 media: autoselect status: inactive utun0: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> mtu 2000 inet6 fe80::83e0:2ce2:8c0d:e1a7%utun0 prefixlen 64 scopeid 0xa nd6 options=201<PERFORMNUD,DAD> bridge100: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500 options=3<RXCSUM,TXCSUM> ether 5a:b0:35:4f:b0:64 inet 192.168.2.1 netmask 0xffffff00 broadcast 192.168.2.255 inet6 fe80::58b0:35ff:fe4f:b064%bridge100 prefixlen 64 scopeid 0xb Configuration: id 0:0:0:0:0:0 priority 0 hellotime 0 fwddelay 0 maxage 0 holdcnt 0 proto stp maxaddr 100 timeout 1200 root id 0:0:0:0:0:0 priority 0 ifcost 0 port 0 ipfilter disabled flags 0x2 member: en0 flags=3<LEARNING,DISCOVER> ifmaxaddr 0 port 6 priority 0 path cost 0 nd6 options=201<PERFORMNUD,DAD> media: <unknown type> status: inactive
有線迷你:
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384 options=1203<RXCSUM,TXCSUM,TXSTATUS,SW_TIMESTAMP> inet 127.0.0.1 netmask 0xff000000 inet6 ::1 prefixlen 128 inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1 nd6 options=201<PERFORMNUD,DAD> gif0: flags=8010<POINTOPOINT,MULTICAST> mtu 1280 stf0: flags=0<> mtu 1280 en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500 options=50b<RXCSUM,TXCSUM,VLAN_HWTAGGING,AV,CHANNEL_IO> ether 14:9d:99:7c:63:cc inet6 fe80::ee:83f2:5357:c607%en0 prefixlen 64 secured scopeid 0x4 inet6 2a00:1370:8131:b399:4b6:9a5b:7712:e480 prefixlen 64 autoconf secured inet6 2a00:1370:8131:b399:b837:ed92:a5dc:5859 prefixlen 64 autoconf temporary inet6 2a00:1370:8131:b399:2846:2489:ad80:fc9b prefixlen 64 dynamic inet 192.168.1.65 netmask 0xffffff00 broadcast 192.168.1.255 nd6 options=201<PERFORMNUD,DAD> media: autoselect (1000baseT <full-duplex,flow-control>) status: active en6: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500 ether ac:de:48:00:11:22 inet6 fe80::aede:48ff:fe00:1122%en6 prefixlen 64 scopeid 0x5 nd6 options=201<PERFORMNUD,DAD> media: autoselect (100baseTX <full-duplex>) status: active ap1: flags=8802<BROADCAST,SIMPLEX,MULTICAST> mtu 1500 options=400<CHANNEL_IO> ether 3e:22:fb:a8:1b:69 media: autoselect status: inactive en1: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500 options=400<CHANNEL_IO> ether 3c:22:fb:a8:1b:69 inet6 fe80::805:ed7:b180:94c0%en1 prefixlen 64 secured scopeid 0x7 inet 169.254.31.79 netmask 0xffff0000 broadcast 169.254.255.255 nd6 options=201<PERFORMNUD,DAD> media: autoselect (<unknown type>) p2p0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 2304 options=400<CHANNEL_IO> ether 0e:22:fb:a8:1b:69 media: autoselect status: inactive awdl0: flags=8943<UP,BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1484 options=400<CHANNEL_IO> ether a6:cb:ac:da:de:6b inet6 fe80::a4cb:acff:feda:de6b%awdl0 prefixlen 64 scopeid 0x9 nd6 options=201<PERFORMNUD,DAD> media: autoselect status: active llw0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500 options=400<CHANNEL_IO> ether a6:cb:ac:da:de:6b inet6 fe80::a4cb:acff:feda:de6b%llw0 prefixlen 64 scopeid 0xa nd6 options=201<PERFORMNUD,DAD> media: autoselect status: active en2: flags=8963<UP,BROADCAST,SMART,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500 options=460<TSO4,TSO6,CHANNEL_IO> ether 82:fa:d0:e2:c0:01 media: autoselect <full-duplex> status: inactive en3: flags=8963<UP,BROADCAST,SMART,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500 options=460<TSO4,TSO6,CHANNEL_IO> ether 82:fa:d0:e2:c0:00 media: autoselect <full-duplex> status: inactive en4: flags=8963<UP,BROADCAST,SMART,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500 options=460<TSO4,TSO6,CHANNEL_IO> ether 82:fa:d0:e2:c0:05 media: autoselect <full-duplex> status: inactive en5: flags=8963<UP,BROADCAST,SMART,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500 options=460<TSO4,TSO6,CHANNEL_IO> ether 82:fa:d0:e2:c0:04 media: autoselect <full-duplex> status: inactive bridge0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500 options=63<RXCSUM,TXCSUM,TSO4,TSO6> ether 82:fa:d0:e2:c0:01 Configuration: id 0:0:0:0:0:0 priority 0 hellotime 0 fwddelay 0 maxage 0 holdcnt 0 proto stp maxaddr 100 timeout 1200 root id 0:0:0:0:0:0 priority 0 ifcost 0 port 0 ipfilter disabled flags 0x0 member: en2 flags=3<LEARNING,DISCOVER> ifmaxaddr 0 port 11 priority 0 path cost 0 member: en3 flags=3<LEARNING,DISCOVER> ifmaxaddr 0 port 12 priority 0 path cost 0 member: en4 flags=3<LEARNING,DISCOVER> ifmaxaddr 0 port 13 priority 0 path cost 0 member: en5 flags=3<LEARNING,DISCOVER> ifmaxaddr 0 port 14 priority 0 path cost 0 nd6 options=201<PERFORMNUD,DAD> media: <unknown type> status: inactive utun0: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> mtu 1380 inet6 fe80::93a6:b158:9d1a:86ee%utun0 prefixlen 64 scopeid 0x10 nd6 options=201<PERFORMNUD,DAD> utun1: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> mtu 2000 inet6 fe80::fef3:61fc:6994:82c4%utun1 prefixlen 64 scopeid 0x11 nd6 options=201<PERFORMNUD,DAD> en8: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500 options=400<CHANNEL_IO> ether da:1c:79:6f:03:9d inet6 fe80::18db:f66f:c81d:54d0%en8 prefixlen 64 secured scopeid 0x14 inet 169.254.172.225 netmask 0xffff0000 broadcast 169.254.255.255 nd6 options=201<PERFORMNUD,DAD> media: autoselect (100baseTX <full-duplex>) status: active
解決方案。將以下規則添加到
/etc/pf.conf
:anchor "multicast" { pass proto igmp allow-opts pass quick from any to { 224.0.0.0/4 ff00::/8 } allow-opts }
(也可以將規則放在單獨的文件中並將它們附加到錨點,請參閱 PF 手冊)
sudo sysctl net.inet.igmp.sendra=0
黑客不再需要。問題的來源。Private Internet Access 應用程序啟用 PF 防火牆並載入其自己的規則,這些規則顯然禁用了 IGMP / 多播。即使 PIA 應用程序未執行,也會發生這種情況。我已經聯繫了 PIA 支持,希望他們能修復它。
調查細節。
tcpdump
透露 Mac 不會響應來自路由器的 IGMP 請求。- 神奇的 04:20 時間是 125 * 2 + 10,其中 125 是查詢間隔,10 是我路由器上 IGMP 代理中設置的查詢響應超時。
- 我發現 macOS 有預設禁用的 PF 防火牆,但在兩台機器上都啟用了它。
sudo pfctl -d
通過固定的 IPTV 和 IGMP 響應禁用它。- 在(Apple 預設規則)中找到的禁用規則
/etc/pf.conf
沒有任何效果,然後我通過sudo pfctl -sr
:發現了 PIA 的規則anchor "com.privateinternetaccess.vpn/*" all
。- 從 Murus(PF 的 UI)抓取 IGMP + 多播規則(在解決方案中列出),瞧!