【问题标题】:Redirecting icmp traffic through one gateway and tcp through another通过一个网关重定向 icmp 流量并通过另一个网关重定向 tcp
【发布时间】:2014-03-05 12:50:50
【问题描述】:

我有两台设备连接到网络,但我正在尝试创建自己的小网络。我想路由客户端的 icmp 流量,比如 10.10.10.99 到 10.10.10.50,而 10.10.10.99 的所有其他流量应该不受影响并通过默认网关传递。

我可以通过更改默认网关来路由整个流量,但我不再需要这样了。

【问题讨论】:

    标签: default routes gateway icmp


    【解决方案1】:

    这应该可以在Linux 中通过使用ip route add 添加一个带有新网关的新表和iptables 来标记某些发往specific port 的数据包。然后新表可以对标记的数据包进行操作。

    link on tldp 有一个很好的例子来说明如何实现这一点

    例如,您可以为标记/路由 ICMP 流量执行以下操作:

    iptables -A PREROUTING -i eth0 -t mangle -p icmp -j MARK --set-mark 1
    # create a table icmp.out to handle all icmp traffic
    echo 201 icmp.out >> /etc/iproute2/rt_tables
    ip rule add fwmark 1 table icmp.out
    ip route add default via <gateway> dev <dev> table icmp.out
    

    【讨论】:

    • 你能详细解释一下吗?我是新手。
    猜你喜欢
    • 2015-08-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-12-07
    • 1970-01-01
    • 2023-02-15
    • 1970-01-01
    相关资源
    最近更新 更多