(net_if)
return rules
Get iptables rules that are specifically applied to a target interface

    Args:
        net_if : network interface name

    Returns:
        list of dictionaries with information of the individual matched rules
Get iptables rules that are specifically applied to a target interface
Get iptables rules that are specifically applied to a target interface
def _get_iptables_rules(net_if):
    """Get iptables rules that are specifically applied to a target interface

    Args:
        net_if : network interface name

    Returns:
        list of dictionaries with information of the individual matched rules

    """
    # Unfortunately, root privileges are required to read the current firewall
    # rules. Hence, we can't read the current rules without eventually asking
    # the root password in dry-run mode. As a workaround, return an empty list
    # as if the rule was not set yet.
    if (runner.dry):
        return []

    # Get rules
    cmd = ["iptables", "-L", "-v", "--line-numbers"]
    res = runner.run(cmd, root=True, capture_output=True).stdout

    # Parse
    header1 = ""
    header2 = ""
    rules = list()
    for line in res.splitlines():
        if ("Chain INPUT" in line.decode()):
            header1 = line.decode()

        if ("destination" in line.decode()):
            header2 = line.decode()

        if (net_if in line.decode()):
            rules.append({
                'rule': line.decode().split(),
                'header1': header1,
                'header2': header2
            })

    return rules
def _get_iptables_rules ( net_if ) : # Unfortunately, root privileges are required to read the current firewall # rules. Hence, we can't read the current rules without eventually asking # the root password in dry-run mode. As a workaround, return an empty list # as if the rule was not set yet. if ( runner . dry ) : return [ ] # Get rules cmd = [ "iptables" , "-L" , "-v" , "--line-numbers" ] res = runner . run ( cmd , root = True , capture_output = True ) . stdout # Parse header1 = "" header2 = "" rules = list ( ) for line in res . splitlines ( ) : if ( "Chain INPUT" in line . decode ( ) ) : header1 = line . decode ( ) if ( "destination" in line . decode ( ) ) : header2 = line . decode ( ) if ( net_if in line . decode ( ) ) : rules . append ( { 'rule' : line . decode ( ) . split ( ) , 'header1' : header1 , 'header2' : header2 } ) return rules