How to connect two network interfaces on the same subnet?

Solution Unverified - Updated -

Environment

  • Red Hat Enterprise Linux 5, 6, 7, 8, 9
  • Multiple network interfaces, each with an IP address in the same subnet

Issue

  • How to connect two network interfaces on the same subnet?
  • In our environment, there are three bonding devices connected with the same segment.

    +---------------------+
    |       Linux         |
    |   .168      .169    | 
    +-----+--------+------+
          │        │
    +-----+--------+------+
    |       Switch        |
    +---------+-----------+
              │
    +---------+-----------+
    |         .1          |
    |       Gateway       |
    +---------------------+
    
  • We have captured packet and found that packet should be transmitted from bond0 was actually transmitted from bond1

  • Also, it was confirmed that the transmit port staggered even if there was no bonding setting.

Resolution

It is usually not a good idea to connect two interfaces using the same subnet on the system, as you may run into the issues presented in the following two pages:

The recommended solution is to use a single interface or a single bond/team interface, then add the other IP addresses to that interface in the form of an alias IP address. If fault tolerance and/or load balancing is required at the network interface level, then an alias on a bond or team should be used. Please note that teaming is not supported in Red Hat Enterprise Linux 6 or earlier. If fault tolerance and/or load balancing is not needed at the interface level, then you can add the alias IP address to a single interface.

The following page provides steps on how to add an alias IP address: How to assign alias IP addresses to a network card (NIC)?.

The following page provides steps on how to set up a bond interface: How do I configure a bonding device on Red Hat Enterprise Linux (RHEL)?

The following pages provide documentation on teaming:

If your environment necessitates a multi-interface same-subnet solution and the above alias interface approach does not work for your environment, you may perform the steps in the Resolution section of the following two pages to avoid the most common issues when setting up multiple interfaces on the same subnet:

Root Cause

  • When there are 2 interfaces on the same subnet there is no assurance as to which interface will be used to transmit traffic and the machine will accept traffic for either IP on either interface.
  • This is because in Linux the IP address belongs to the host and is not associated with the interface.
  • If you ping with -I DEV, attempting to use a given interface, there is no guarantee the reply packet (if there even is one) will come back to the same interface, so pings done with -I DEV may not work.

Diagnostic Steps

  • Setup system with 2 interfaces on the same subnet.
  • Ping a target and capture packets with tcpdump.

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Comments