Although switching can learn the MAC address table automatically, routing is basically to consider the network configuration, it is needed to put the manual configuration by network administrator or designer.
Static Routing and Dynamic Routing
The way of setting Routing are two types, one is Static Routing, and another is Dynamic Routing.
Static Routing is needed the direction of each route per NW device, "10.0.0.0/8 is transmitted to NextHop 172.16.1.2" "192.168.0.0/24 is transmitted to NextHop 172.16.1.1" must continue described as, so it is not suitable to scattered fine network or large-scale networks. In addition, because there is no dynamic change, it is difficult to forming the redundant configuration. However, there is no dynamic change, it means it is stable, so this is a merit.
Dynamic Routing will exchange the routing information between NW devices each other by dynamic routing protocol.
Dynamic Routing Overview
There are some kind of the Dynamic Routing Protocols, such as RIP, OSPF, and EIGRP. Setting is similar, when enabled routing protocol interface of the NW device, it issued a packet routing protocol from the interface, and NW address of the interface in the packet, the NW address learned from other routers we will continue to propagate a ride.
In NW device side to be propagated must be the same routing protocol is enabled on the receiving interface.
In the case of RIP version2, upon receipt of the packet, the NextHop of the network address in the packet, and set it to NextHop Field of the IP address to be present in the RIP packet.(In many cases, the same as the source IP address Field of the IP header.) In addition, metric values into one single network address and is supplied, when receiving information from another path, both sprout has become to be able to determine whether close. In stub network which means there is no other Router which RIP is enabled, RIP must enable on this interface but by default RIP packet is sent in waste. "passive-interface" command will set not to send RIP packet enabling RIP on interface.
It is similar the behavior about OSPF and EIGRP, but OSPF sends more detailed information to make the route map, and EIGRP is different from the concept of the metric.
Please refer to the chapter of dynamic routing for more information.
For studying about Network, I recommend below.