There are three ways a router learns how to forward a packet
1. Static Routes - Configured by the administrator manually. The administrator must also update the table manually every time a change to the network takes place. Static routes are commonly used when routing from a network to a stub (a network with a single route) network.
A static route adds an entry to the routing table for a specific destination IP address or subnet.
To configure a static route, issue the
ip route prefix mask {ip-address | interface-type interface-number [ip-address]} [distance] [name] [permanent] [tag tag]
command in global configuration mode
Static Routing: It may be implemented in either one of two ways by using ip route command:
I. By using the next-hop address
Ex: Router(config)#ip route 192.204.1.64 255.255.255.240 192.204.1.2
192.204.1.64 = destination network
255.255.255.240 = subnet mask
192.204.1.2 = next-hop address
Remember this by reading as: To get to the destination network of 192.204.1.64, with a subnet mask of 255.255.255.240, send all packets to 192.204.1.2
II. By using the exit interface
Router(config)#ip route 192.204.1.64 255.255.255.240 s0/0
192.204.1.64 = destination network
255.255.255.240 = subnet mask
s0/0 = exit interface
Remember this by reading as: To get to the destination network of 192.204.1.64, with a subnet mask of 255.255.255.240, send all packets out interface Serial 0/0
You must specify either the output interface (the interface on which all packets are sent to the destination network) or the next-hop address in a fully specified static route. You can use a fully specified static route when the output interface is a multi-access interface and you need to identify the next-hop address. The next-hop address must be directly attached to the specified output interface.
2. Default Routes - The default route (gateway of last resort) is used when a route is not known or is infeasible. The command is
ip route 0.0.0.0 0.0.0.0 165.44.56.5
Here 165.44.56.5 is the gateway of last resort to network 0.0.0.0
3. Dynamic Routes - As soon as dynamic routing is enabled, the routing tables are automatically updated. Dynamic routing uses broadcasts and multicasts to communicate with other routers. Each route entry includes a subnet number, the interface out to that subnet, and the IP address of the next router that should receive the packet. The commands to enable rip are:
router rip
network <major network number>