📜 ⬆️ ⬇️

Setting up IPTV in OpenWRT

Although I practically do not watch TV, sometimes there is an overwhelming desire to see what is now being broadcast in the news. Often this desire arises when the daughter is asleep, and the TV is already out of range. As you understand the only way out is IPTV.

By a happy coincidence, I have a tariff plan with a free IPTV package and a Netgear WNDR-3800 router. The router has OpenWrt Backfire 10.03.1 firmware.
Since comments have appeared in the comments about the fact that udpxy is not such a necessary thing, it should be noted separately that I watch IPTV exclusively over WiFi, and some devices do not support 802.11n and the picture crumbles when using multicast.
On Habré there were many articles about OpenWrt, about setting up a network in OpenWrt , setting up IPTV broadcasts , and some others, but unfortunately in them the process of setting up IPTV itself, if described, then without any details. And although this process is not complicated at all, I hope my topic will shorten the time for searching and reading the necessary manuals, which are plenty in the network. I’m not making these settings for the first time, because sometimes in the process of experimenting with VPN, Wi-Fi and other buns, the router died and was restored in emergency mode. Therefore, be careful and careful that you would not have to go to the recovery procedure.

All settings will be made from the console, because I have not trusted LuCI for some time now. It is assumed that you are connected to the router via ssh under the root.

First, install udpxy:
  opkg update
 opkg install udpxy 

After successful installation, check that udpxy starts:
  / usr / bin / udpxy 

This command will output the udpxy version and its main options. By the way, a detailed description of all the options can be found here .
')
Let's go to the actual setting. In the /etc/init.d folder, create the udpxy file:
  cd /etc/init.d
 vi udpxy 

This file is the udpxy startup script. Learn more about the startup scripts OpenWrt here .
The contents of our file will be something like this:
  #! / bin / sh /etc/rc.common
 # Copyright (C) 2010 OpenWrt.org

 START = 99
 STOP = 10

 IGMP_OPTS = "- a br-lan -m eth1 -p 8888 -M 600"
 IGMP_BIN = "/ usr / bin / udpxy"
 PID_F = "/ var / run / udpxy.pid"

 start () {
         echo "Starting udpxy"
         start-stop-daemon -S -x $ IGMP_BIN -p $ PID_F -b -m - $ IGMP_OPTS
 }

 stop () {
         echo "Stopping udpxy"
         start-stop-daemon -K -x $ IGMP_BIN -q
 } 

To start the service, use the start-stop-daemon - a utility to control the start and stop of system services. In IGMP_BIN, we specify what to start from where, PID_F - where to write the PID so that it could be monitored for it later, IGMP_OPTS - the settings of the service being started.

Before specifying the settings, I advise you to try to run udpxy with these settings, and only after that transfer them to the config, it will help you avoid becoming a victim of a typo, and it may save you some time.

After all the settings are completed, close the udpxy file and start the service with the command
  /etc/init.d/udpxy start 

You can check whether udpxy started using the command
  ps | grep udpxy 

If you see only one line in the result, go back to the settings and check what you did wrong. If everything is correct, it should be something like
  1637 root 804 S / usr / bin / udpxy -a br-lan -m eth1 -p 8888 -M 600 
 29984 root 1372 S grep udpxy 

You can also open the http://192.168.1.1:8888/status page in your browser to check that udpxy is working.
Now you can set our startup script to autoload. To do this, just run the command:
  /etc/init.d/udpxy enable 

after that, a symbolic link of the form S99udpxy should appear in the /etc/rc.d folder. You can check whether the script was added to autoload by the same command
  /etc/init.d/udpxy enabled && echo "enabled" 

if everything is ok, you will get “enabled” in response.

The case remains for the small - to create rules for traffic udp:
  config rule
         option src wan
         option proto igmp
         option target ACCEPT
 config rule
         option src wan
         option proto udp
         option dest_ip 224.0.0.0/4
         option target ACCEPT 

These rules must be added to / etc / config / firewall, and then restart the service with the command:
  /etc/init.d/firewall restart 

You can also restart the router itself to make sure that all the necessary services are running, and everything works exactly as we intended.
Now we take the channel list from the provider, and convert all the links as described in the manual to udpxy:
  http: // {address}: {port} / {protocol} / {channel_addr}: {channel_port} 

that is, if you have indicated in the channel list
  rtp: //@111.22.33.44: 1234 
then the output should be
  http://192.168.1.1:8888/udp/111.22.33.44:1234 


After that, open the channel list with any suitable player and enjoy.

Source: https://habr.com/ru/post/138735/


All Articles