def add_local_bypass(table, chain, ipv6):
 run_iptables_cmd(('-t %s -A %s -p tcp -m socket -j RETURN' % (table, chain)), ipv6=ipv6)
 (v4_addrs, v6_addrs) = get_interface_addresses()
 for addr in v4_addrs:
  run_iptables_cmd(('-t %s -A %s -p tcp -d %s -j RETURN' % (table, chain, addr)), ipv6=False)
 for addr in v6_addrs:
  run_iptables_cmd(('-t %s -A %s -p tcp -d %s -j RETURN' % (table, chain, addr)), ipv4=False, ipv6=ipv6)

def add_local_bypass ( table , chain , ipv6 ) : run_iptables_cmd ( ( '-t %s -A %s -p tcp -m socket -j RETURN' % ( table , chain ) ) , ipv6 = ipv6 ) ( v4_addrs , v6_addrs ) = get_interface_addresses ( ) for addr in v4_addrs : run_iptables_cmd ( ( '-t %s -A %s -p tcp -d %s -j RETURN' % ( table , chain , addr ) ) , ipv6 = False ) for addr in v6_addrs : run_iptables_cmd ( ( '-t %s -A %s -p tcp -d %s -j RETURN' % ( table , chain , addr ) ) , ipv4 = False , ipv6 = ipv6 )
add rules to skip anything destined for a local address to avoid breaking connections to ourselves .