1

Could someone please explain why can't be have 2 interface on same subnet?

Do router use network address to forward traffic?

2
  • A router is deterministic; it must know where to send a packet based on the destination address. A router with two interfaces in the same network would not know which interface to use when forwarding packets to that network. Routers do not guess, they look through a routing table until a match is found for the destination address, so only one interface would be used for the network.
    – Ron Maupin
    Sep 5 at 14:42
  • this match can have multiple entries. OSPF can use ECMP (equal cost multipath). EIGRP can have more options than equal cost.
    – Effie
    Sep 7 at 19:09
3

why can't we have 2 interface on same subnet?

You can (some devices may see that differently though). There are just very few situations where that makes sense. A router forwards in between subnets, so multiple interfaces with the same subnet are rarely useful. (I'm referring to logical interfaces. Multiple physical interfaces commonly make sense when aggregating links, as @Peregrino69 has already pointed out.)

Do router use network address to forward traffic?

Yes, routers forward by a packet's destination network address (usually IP).

1
  1. a router can be physically connected to the same subnetwork with different interfaces.

  2. routers, that implement dynamic routing protocols, may not work if a single router has two interfaces facing the same subent. This has something to do with how information is exchanged and how shortest paths are calculated. Thus a routing protocol may not support a situation where two interfaces are connected to the same subnet. I.e., this protocol will do something incorrectly if this happens. Examples:

    • OSPF RFC, Appendix F more or less says that you actually can. You have to specially configure the router, and from what i read, configuration error can cause incorrect behavior.

    • here is a link testing simple configuration with two interfaces having the same subnet with RIP, EIGRP, and OSPF. According to the link, both RIP and EIGRP work, however IOS version of OSPF fails to compute correct routes

    • this applies to bridges/switches too. STP in particular specifies how to handle situation where two interfaces are connected to the same LAN. In this case the bridge selects one based on this interface identifier.

  3. there is nothing related to forwarding that prevents a router to have two interfaces on the same subnetwork. There is nothing special in a situation where a router has several interfaces that can route traffic to the same destination, and this case is a special case of such situation.

    3.1. first, there is usually more than one physical network path between a given router and a given destination, and different paths go through different interfaces (or different routers which are connected through the same interface, this happens e.g., if routers are connected to the same subnet). The goal of a shortest path routing protocol is to select the best one (based on cost/metric). While doing so it also selects the interface that this path goes through.

    3.2 it also can happen that there are several paths with the same cost. in this case there are two options: a) router selects one (it does not matter which one) , b) router distributes traffic between them all - this is known as Equal Cost Multi-Path (ECMP). AFAIK at least most intra-domain protocols do option b.

11
  • 1
    Re 2. Not all routers by far implement a routing protocol (like RIP, OSPF, IS-IS, BGP). Re 2.3 switches are a totally different situation this question isn't about. Re 3.1 Different paths don't necessarily use different egress interfaces. They might just use a different next hop. Likewise, re 3.2 ECMP can use fewer interfaces than there are paths.
    – Zac67
    Sep 7 at 20:34
  • re 2. what do you mean by routers not implement a routing protocol.? re 3.1/3.2 i added a clarify, but the point is - a single address in a forwarding table can have multiple interface/next hop pairs. this is specified behavior. in this case the router can choose any entry to forward packet to (in theory, in practice router should make sure to select the same entry for packets of the same flow to avoid reordering).
    – Effie
    Sep 7 at 20:46
  • 1
    OSPF etc. are optional routing protocols for dynamic route exchange. Basic routers use static routing without a routing protocol. For 3.2, use should make that "that there are several paths with the same cost". Whether or not ECMP is used depends on a router's capabilities and its configuration, not on any protocol.
    – Zac67
    Sep 7 at 20:54
  • if you use static routing then you can configure your router so it works correctly (or do not use one of the interfaces); Whether on not ECMP is used depends on both. in order to use ECMP your protocol should be capable of computing multiple paths. Then it also should be capable of supporting multiple next hops in forwarding tables, and then it can be configured not to do so.
    – Effie
    Sep 7 at 21:02
  • 1
    A nice writeup. But are you absolutely convinced the OP possesses sufficient understanding to grasp advanced topics like OSPF or ECMP? Or would it be advisable to build a bit of basic knowledge first? Also STP is irrelevant since the whole discussion is only about multiple independent, equal routing interfaces leading into the same subnet without any kind of link aggregation or redundancy methods in any level. Sep 7 at 21:27
0

Here's a much simplified explanation. This applies only in a situation where a router has 2 locally connected interfaces in the same subnet without link aggregation or other bonding method.

There are 2 types of networks and interfaces: physical and logical. A physical interface is the port where you plug a cable in, a physical network is the arrangement of physical devices connected to the network; usually in the same physical location. A logical interface is the IP address used to make forwarding decisions, a logical network is the subnet identified by network address. Logical networks can extend to multiple physical locations.

Assume you have a network 192.168.1.0/24. To route traffic to that network your router must have an interface connected to that network, and the interface must have an IP address. Like this:

                 -------------------------
                 | ROUTER                |
                 |       192.168.1.1 int1--------- 192.168.1.0/24 network
  INTERNET-------int0 10.10.10.10        |
                 -------------------------

The devices in the network will have a routing table instructing them to route all traffic to all unknown networks to IP address 192.168.1.1 (Default Gateway). The router will have a routing table showing:

Route all traffic to network 192.168.1.1 through physical interface int1 (alternatively logical interface 192.168.1.1)
Route all traffic to all other networks through physical interface int0 (alternatively logical interface 10.10.10.10)

Having 2 logical interfaces pointing to the same logical network (192.168.1.0/24) confuses things. Let's assume this situation:

WEB1 2.2.2.2/24
   |
   |
   |2.2.2.1/24
IROUTER
   |1.1.1.1/32
   |
   |               LAN 192.168.1.0/24
---|-------------    --------------
| R0 1.1.1.2/32 |    |            | 
|               |    |            |
| 192.168.1.1 R1------    SW1     ----PC1 
|               |    |            |
| GWROUTER      |    --------------
|               |    --------------
|               |    |            |
| 192.168.1.2 R2-----     SW2     ----PC2 
|               |    |            |
-----------------    --------------

PC1 wants to access a website provided by WEB1 on IP address 2.2.2.2. The server is not in subnet 192.168.1.0/24, so it will send the packet to GWROUTER 192.168.1.1. It doesn't know where the server is either, but it knows that traffic to all unknown destinations must go to IROUTER 1.1.1.1 so it forwards the packet there. IROUTER has direct connection to subnet 2.2.2.0/24, so it will follow instruction "Forward all traffic to 2.2.2.0/24 through locally connected interface", whereupon it will reach the WEB1 server.

WEB1 sends a response. IROUTER doesn't know where the eventual target is, but it knows the request came from GWROUTER so it will forward the response to 1.1.1.2. GWROUTER receives it, and since it's directly connected to 192.168.1.0/24 it will follow instruction "Forward all traffic to 192.168.1.0/24 through locally connected interface".

But there are 2 locally connected interfaces to 192.168.1.0/24. Which one should be used to forward the response?

For redundancy and efficiency purposes there are ways to combine multiple physical interfaces so that they are presented as a single logical interface; for example LACP. Similarly there are ways to combine multiple logical interfaces to use to a single physical interface; for example configuring sub-interfaces to forward traffic to multiple VLANs.

Also it should be noted that any individual manufacturer may well have a solution for connecting one subnet may be via 2 individual logical interfaces, without any kind of bonding or link aggregation. However these are proprietary solutions, not applicable in general level.

25
  • What if 2 logical interface pointing 2 diffrent network like interface a :- 192.168.1.0/24 and interface b:- 192.168.5.0/24 will there be problem in this case?
    – Rohit
    Sep 5 at 9:52
  • To route traffic to that network your router must have an interface connected to that network - larger networks weren't possible like that. To route traffic to that network your router must know a route pointing to that network. The destination network can be behind other gateways. the router might receive an ARP request on interface A, but route the response back through interface B - it wouldn't ever do that.
    – Zac67
    Sep 5 at 10:07
  • @Rohit That is exactly the purpose of a router: forward between multiple interfaces connected to different subnets.
    – Zac67
    Sep 5 at 10:19
  • Rohit - no, in that case no problem. Network x.x.x.0/24 contains IP addresses from x.x.x.1 to x.x.x.255, so 192.168.1.0/24 and 192.168.5.0/24 are different networks, even if they were running on the same network hardware. @Zac67 - you're right, but I did specifically state my explanation's simplified :-) I'm referring to directly connected subnets. Sorry but couldn't come up with a better confusion example due to unbalanced blood levels in my caffeine :-P Sep 5 at 10:23
  • 1
    Router forwards traffic based on IP, not MAC address. Sep 5 at 13:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.