光猫内将iptv连接设置为桥接模式:
将上网和iptv绑定到对应的vlan,路由通过vlan区分iptv和上网。
如果光猫不能修改vlan,或不正常,我这个别猫直播黑屏,使用交换机中转并关闭igmp:
跑满千m带宽时iptv有点卡,将iptv端口优先级调高:
openwrt交换机配置vlan:
监听iptv流量获取dhcp认证信息,电视盒mac,主机名和Option60 Vendor class identifier:
openwrt配置iptv dhcp,0x3c即Option60用以发送16进制加密信息,dhcp有选项vendorid但是发送的是字符信息。
这样默认会发送两个Option60,修改文件/lib/netifd/proto/dhcp.sh内${vendorid:+-V "$vendorid"} \为-V '' \即可。
也可以将16进制option60设置vendorid参数并修改为${vendorid:+-V '' "-x 0x3c:$vendorid"}
config interface 'IPTV'
option proto 'dhcp'
option device 'eth1.23'
option hostname 'xxxxxxx'
option sendopts '0x3c:xxxxxxx'
option peerdns '0'
option delegate '0'
option macaddr 'xxxxx'
option defaultroute '0'
config interface 'MODEM'
option proto 'static'
option device 'eth1.22'
list ipaddr '192.168.1.2/24'
list ipaddr '192.168.0.2/24'
option delegate '0'
option defaultroute '0'
使用udpxy或msd_lite将组播转为http单播:
cat /etc/config/msd_lite
config instance
option 'enabled' '1'
# Bind address
list 'address' '0.0.0.0:9999'
#list 'address' '[::]:9999'
# For multicast receive
option 'network' 'IPTV'
# 0 = auto detect
option 'threads' '1'
# Bind threads to CPUs
option 'bind_to_cpu' '0'
# Disconnect slow clients
option 'drop_slow_clients' '0'
# Pre cache size
option 'precache_size' '4096'
# Stream receive ring buffer size
option 'ring_buffer_size' '1024'
# Multicast receive socket buffer size
option 'multicast_recv_buffer_size' '512'
# Multicast receive timeout
option 'multicast_recv_timeout' '2'
# Do IGMP/MLD leave+join every X seconds
option 'rejoin_time' '0'
cat /etc/config/udpxy
config udpxy
option disabled '1'
option respawn '1'
option verbose '0'
option status '1'
#option bind '0.0.0.0'
option port '9999'
option source 'eth1.23'
option max_clients '100'
# option log_file '/var/log/udpxy'
# option buffer_size '4096'
# option buffer_messages '-1'
# option buffer_time '-1'
# option nice_increment '0'
# option mcsub_renew '0'
iptables:
iptables -A INPUT -i eth1.23 -p udp -d 224.0.0.0/4 -j ACCEPT
iptables -A INPUT -i eth1.23 -p igmp -d 224.0.0.0/4 -j ACCEPT
iptables -A INPUT -i eth1.23 -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
iptables -A FORWARD -i eth1.23 -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
当iptv接口重启时重启msd_lite:
cat /etc/hotplug.d/iface/95-msd_lite
#!/bin/bash
if [ $ACTION = "ifup" -a "$INTERFACE" = "IPTV" ]; then
/etc/init.d/msd_lite restart
fi
#[ "$ACTION" = "ifdown" -a "$INTERFACE" = "IPTV" ] && {
#/etc/init.d/msd_lite stop
#}
#[ "$ACTION" = "ifup" -a "$INTERFACE" = "IPTV" ] && {
#/etc/init.d/msd_lite start
#}
openwrt交换机端口镜像抓组播或单播源,相应的端口查看vlan network配置。
switch mirror monitor 1 #镜像到的端口
switch mirror target 2 3 #要镜像的端口,0:off, 1:rx, 2:tx, 3:all
switch mirror target 2 0 #关闭镜像
遇到的问题,同样的方法一台光猫可以,另一台能获取到IPTV IP,直播黑屏,光猫不绑定vlan加管理交换机配置vlan并关闭igmp正常了。
播放时电视连接无线用diyp连接udpxy刚启动时会频繁花屏,有线无问题,无线连msd_lite无问题,但是msd_lite切换频道时偶尔花屏,msd_lite可能有同时最大8个连接数的限制,超过切换频道很慢。
udpx添加-B -R -H会大幅降低cpu占用,具体哪个没详细分析。
参考:
https://www.imyjy.cn/article/10.html