How to route TCP/IP responses through a different interface?

后端 未结 2 687
鱼传尺愫
鱼传尺愫 2021-02-09 05:25

I have two machines each with two valid network interfaces, an Ethernet interface eth0 and a tun/tap interface gr0. The goal is to start a TCP connecti

相关标签:
2条回答
  • 2021-02-09 06:09

    You may be interested in enabling logging of martian packets net.ipv4.conf.all.log_martians, and disable reverse path filtering net.ipv4.conf.<interface>.rp_filter on the affected interfaces.

    This sysctl vars are accesible via the sysctl utility and/or the /proc filesystem.

    0 讨论(0)
  • 2021-02-09 06:13

    You could add an additional address to the lo interface on each system and use these new addresses as the TCP connection endpoints. You can then use static routes to direct which path each machine takes to get to the other machine's lo address.

    For example:

    Machine A:
      ip addr add 1.1.1.1/32 dev lo
      ip route add 2.2.2.2/32 dev eth0 via <eth0 default gateway>
    
    Machine B:
      ip addr add 2.2.2.2/32 dev lo
      ip route add 1.1.1.1/32 dev gr0
    

    Then bind to 1.1.1.1 on machine A and connect to 2.2.2.2.

    0 讨论(0)
提交回复
热议问题