(table, chain, position=0, ipv6=False, raise_exc=True)
Get a rule from a chain in a given position. 0=all rules, 1=first, n=nth position
Get a rule from a chain in a given position. 0=all rules, 1=first, n=nth position
Get a rule from a chain in a given position . 0 = all rules 1 = first n = nth position
def get_rule(table, chain, position=0, ipv6=False, raise_exc=True):
    """ Get a rule from a chain in a given position. 0=all rules, 1=first, n=nth position """
    try:
        if position == 0:
            # Return all rules
            return dump_chain(table, chain, ipv6)
        elif position > 0:
            # Return specific rule by position
            iptc_chain = _iptc_getchain(table, chain, ipv6)
            iptc_rule = iptc_chain.rules[position - 1]
            return decode_iptc_rule(iptc_rule, ipv6)
        elif position < 0:
            # Return last rule  -> not available in iptables CLI
            iptc_chain = _iptc_getchain(table, chain, ipv6)
            iptc_rule = iptc_chain.rules[position]
            return decode_iptc_rule(iptc_rule, ipv6)
    except Exception as e:
        if raise_exc: raise
def get_rule ( table , chain , position = 0 , ipv6 = False , raise_exc = True ) : try : if position == 0 : # Return all rules return dump_chain ( table , chain , ipv6 ) elif position > 0 : # Return specific rule by position iptc_chain = _iptc_getchain ( table , chain , ipv6 ) iptc_rule = iptc_chain . rules [ position - 1 ] return decode_iptc_rule ( iptc_rule , ipv6 ) elif position < 0 : # Return last rule  -> not available in iptables CLI iptc_chain = _iptc_getchain ( table , chain , ipv6 ) iptc_rule = iptc_chain . rules [ position ] return decode_iptc_rule ( iptc_rule , ipv6 ) except Exception as e : if raise_exc : raise