The Layer 2 defines communication directly or between connected devices across a Layer 2 device (L2 switch), but when you build a large network crossed only L2 switch, all devices is in one broadcast domain and all L2 switch also has many MAC address on the MAC address table, the efficiency of the communication will be very bad.
Therefore, it is needed a mechanism to connect Layer 2 network to each other, and to determine the path which you want to communicate the opponent. The responsible for that is the Routing, which is the role of Layer 3 .
Summary of Routing
In the figure above, because the router is directly connected to the “192.168.0.0/24”, “172.16.0.0/16”, (i.e. because it has the IP that belongs to the segment on the interface, ) if coming the packets of these address bands, performs a resolution by ARP, and you can forward the packet to the destination IP.
However, there is no information with respect to “10.0.0.0/8”. So you should set the following Static route on the router.
“forward the packets destined to 10.0.0.0/8 to the L3 switch”
This setting is the routing.
Although Layer 2 standard now we encounter is almost ethernet, there are some standard else such as PPP, PPPoE, frame relay, ATM, and HDLC, and you can interconnect routing a these Layer 2 standard.
For studying about Network, I recommend below.