Configuring IPTV in OpenWRT

    Although I practically do not watch TV, sometimes an irresistible desire appears to watch what is being broadcast in the news. Often this desire arises when the daughter is sleeping, and the TV is already out of range. As you know, there is only one way out - IPTV.

    By a fortunate coincidence, I have a tariff plan with a free IPTV package and a Netgear WNDR-3800 router. The router has firmware OpenWrt Backfire 10.03.1.
    Since comments appeared that udpxy is not such a necessary thing, it is worth noting separately that I watch IPTV exclusively via WiFi, and some devices do not support 802.11n, and when using multicast, the picture crumbles on them.
    On a habr there were many articles about OpenWrt, about network setup in OpenWrt , setupIPTV broadcasts , and some others, but unfortunately in them the process of setting up the IPTV itself, if described, without any details. And although this process is not at all complicated, I hope my topic will reduce the time to search and read the necessary manuals, which are plentiful on the network. This is not the first time I’ve made these settings, because sometimes during the experiments with VPN, Wi-Fi and other goodies, the router died and was restored in emergency mode. Therefore, be careful and careful not to have to go to the recovery procedure.

    We will make all the settings from the console, because For some time now I do not trust LuCI. It is assumed that you are connected to the router via ssh under the root.

    First, install udpxy:
    opkg update
    opkg install udpxy

    After a successful installation, verify that udpxy starts:
    / usr / bin / udpxy

    This command will display the udpxy version and its main options. By the way, a detailed description of all the options can be found here .

    Let's proceed to the actual setup. 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 OpenWrt startup scripts 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, start-stop-daemon is used - a utility for controlling the start and stop of system services. In IGMP_BIN we indicate what and where to start, PID_F - where to write the PID so that you can follow it later, IGMP_OPTS - settings for the service to be started.

    Before specifying settings, I advise you to try running udpxy with these settings, and only after that transfer them to the config, this will help you not to be a victim of a typo, and possibly save a little 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 if udpxy has started using the command
    ps | grep udpxy

    If you see only one line as a result, go back to the settings and check what you did wrong. If everything is correct, 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 browser page http://192.168.1.1:8888/status to verify that udpxy works.
    Now you can register our startup script at startup. 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 also check if the script has been added to startup at the same time with the command
    /etc/init.d/udpxy enabled && echo “enabled”

    if everything is fine you will get a “enabled” response.

    The only thing left is to create rules for udp traffic:
    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

    It is also possible to reboot the router itself, in order to make sure that all the necessary services are launched, 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 udpxy manual:
    http: // {address}: {port} / {protocol} / {channel_addr}: {channel_port}

    that is, if your channel list indicates
    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.

    Also popular now: