Static Routing - IOS

SummaryStatic Routing uses static routing tables to route traffic.  Routing tables are manually configured.
Configuration Commands
ip routing  Enables IP forwarding.
no ip routing Disables IP forwarding. This command also deletes the content of the routing table.
   
show ip route Displays the contents of the routing table
clear ip route * Deletes all routing table entries.
show ip cache Displays the routing cache
   
ip route-cache Enables route caching. By default, route caching is enabled on a router.
no ip route-cache Disables route caching
ip route destination mask gw_address Adds a static routing table entry to destination with netmask mask
ip route destination mask Iface Adds a static routing table entry to destination with netmask mask. Here, the next-hop information is the name of a network interface (e.g., Fa0/0)

no ip route destination mask gw_address
no ip route destination mask Iface

Deletes the route table antry with destination, mask, and gw_address or Iface from the routing table.

IP Interface Configuration Example

Router1> enable
Password: <enable secret>
Router1# configure terminal 
Router1(config)# no ip routing
Router1(config)# ip routing
Router1(config)# interface Fa0/0
Router1(config-if)# no shutdown
Router1(config-if)# ip address 10.0.2.1 255.255.255.0
Router1(config-if)# end
Router1(config-if)# interface Fa0/1
Router1(config-if)# no shutdown
Router1(config-if)# ip address 10.0.3.1 255.255.255.0
Router1(config-if)# end

Adding & Deleting Routing Tables Example

Command for adding a route for the network prefix 10.21.0.0/16 with 10.11.1.4 as the next-hop address

Router1(config)# ip route 10.21.0.0 255.255.0.0 10.11.1.4

Command to add a host route to IP address 10.0.2.31 with next-hop set to 10.0.1.21

Router1(config)# ip route 10.0.2.31 255.255.255.255 10.0.1.21

Command to add the IP address 10.0.4.4 as the default gateway

Router1(config)# ip route 0.0.0.0 0.0.0.0 10.0.4.4

Commands to delete the previous entries use the no ip route command

Router1(config)# no ip route 10.21.0.0 255.255.0.0 10.11.1.4

Router1(config)# no ip route 10.0.2.31 255.255.255.255 10.0.1.21

Router1(config)# no ip route 0.0.0.0 0.0.0.0 10.0.4.4