def enable_redirect_rules(port, ipv6=False):
    disable_redirect_rules(ipv6=ipv6)
    try:
        run_iptables_cmd("-t nat -N %s" % REDIRECT_CHAIN, ipv6=ipv6)

        add_local_bypass("nat", REDIRECT_CHAIN, ipv6)
        run_iptables_cmd(
                "-t nat -A PREROUTING --jump %s" % REDIRECT_CHAIN, ipv6=ipv6)

        run_iptables_cmd(
                "-t nat -A %s -p tcp -j REDIRECT --to-ports %s" % (REDIRECT_CHAIN, port),
                ipv6=ipv6)
    except Exception:
        logger.exception("Failed to setup routing rules")
        disable_redirect_rules(ipv6=ipv6)
dataset/ETHPy150Open google/nogotofail/nogotofail/mitm/util/routing.py/enable_redirect_rules/original