(net_if, ports, igmp=False, prompt=True)
Configure iptables rules to accept blocksat traffic on a DVB-S2 interface

    Args:
        net_if : DVB network interface name
        ports  : ports used for blocks traffic and API traffic
        igmp   : Whether or not to configure rule to accept IGMP queries
        prompt : Ask yes/no before applying any changes
Configure iptables rules to accept blocksat traffic on a DVB-S2 interface
Configure iptables rules to accept blocksat traffic on a DVB - S2 interface
def _configure_iptables(net_if, ports, igmp=False, prompt=True):
    """Configure iptables rules to accept blocksat traffic on a DVB-S2 interface

    Args:
        net_if : DVB network interface name
        ports  : ports used for blocks traffic and API traffic
        igmp   : Whether or not to configure rule to accept IGMP queries
        prompt : Ask yes/no before applying any changes

    """

    cmd = [
        "iptables",
        "-I",
        "INPUT",
        "-p",
        "udp",
        "-i",
        net_if,
        "--match",
        "multiport",
        "--dports",
        ",".join(ports),
        "-j",
        "ACCEPT",
    ]

    util.fill_print(
        "A firewall rule is required to accept Blocksat traffic arriving " +
        "through interface {} towards UDP ports {}.".format(
            net_if, ",".join(ports)))

    if (runner.dry):
        util.fill_print("The following command would be executed:")

    if (not _is_iptables_udp_rule_set(net_if, cmd)):
        if (runner.dry or (not prompt) or util.ask_yes_or_no(
                "Add the corresponding ACCEPT firewall rule?")):
            _add_iptables_rule(net_if, cmd)
        else:
            print("\nFirewall configuration cancelled")

    # We're done, unless we also need to configure an IGMP rule
    if (not igmp):
        return

    # IGMP rule supports standalone DVB receivers. The host in this case will
    # need to periodically send IGMP membership reports in order for upstream
    # switches between itself and the DVB receiver to continue delivering the
    # multicast-addressed traffic. This overcomes the scenario where group
    # membership timeouts are implemented by the intermediate switches.
    cmd = [
        "iptables",
        "-I",
        "INPUT",
        "-p",
        "igmp",
        "-i",
        net_if,
        "-j",
        "ACCEPT",
    ]

    print()
    util.fill_print(
        "A firewall rule is required to accept IGMP queries arriving from the "
        "standalone DVB-S2 receiver on interface {}.".format(net_if))

    if (runner.dry):
        util.fill_print("The following command would be executed:")

    if (not _is_iptables_igmp_rule_set(net_if, cmd)):
        if (runner.dry or (not prompt) or util.ask_yes_or_no(
                "Add the corresponding ACCEPT firewall rule?")):
            _add_iptables_rule(net_if, cmd)
        else:
            print("\nIGMP firewall rule cancelled")
def _configure_iptables ( net_if , ports , igmp = False , prompt = True ) : cmd = [ "iptables" , "-I" , "INPUT" , "-p" , "udp" , "-i" , net_if , "--match" , "multiport" , "--dports" , "," . join ( ports ) , "-j" , "ACCEPT" , ] util . fill_print ( "A firewall rule is required to accept Blocksat traffic arriving " + "through interface {} towards UDP ports {}." . format ( net_if , "," . join ( ports ) ) ) if ( runner . dry ) : util . fill_print ( "The following command would be executed:" ) if ( not _is_iptables_udp_rule_set ( net_if , cmd ) ) : if ( runner . dry or ( not prompt ) or util . ask_yes_or_no ( "Add the corresponding ACCEPT firewall rule?" ) ) : _add_iptables_rule ( net_if , cmd ) else : print ( "\nFirewall configuration cancelled" ) # We're done, unless we also need to configure an IGMP rule if ( not igmp ) : return # IGMP rule supports standalone DVB receivers. The host in this case will # need to periodically send IGMP membership reports in order for upstream # switches between itself and the DVB receiver to continue delivering the # multicast-addressed traffic. This overcomes the scenario where group # membership timeouts are implemented by the intermediate switches. cmd = [ "iptables" , "-I" , "INPUT" , "-p" , "igmp" , "-i" , net_if , "-j" , "ACCEPT" , ] print ( ) util . fill_print ( "A firewall rule is required to accept IGMP queries arriving from the " "standalone DVB-S2 receiver on interface {}." . format ( net_if ) ) if ( runner . dry ) : util . fill_print ( "The following command would be executed:" ) if ( not _is_iptables_igmp_rule_set ( net_if , cmd ) ) : if ( runner . dry or ( not prompt ) or util . ask_yes_or_no ( "Add the corresponding ACCEPT firewall rule?" ) ) : _add_iptables_rule ( net_if , cmd ) else : print ( "\nIGMP firewall rule cancelled" )