Using Static Routing

Problem

You want to configure a static route.

Solution

You can configure a static route with the ip route command, as follows:

Router#configure terminal
Enter configuration commands, one per line.  End with CNTL/Z.
Router(config)#ip route 10.35.15.5 255.255.255.255 Ethernet0
Router(config)#end 
Router#

You can also configure a static route to point to a particular next hop router:

Router#configure terminal
Enter configuration commands, one per line.  End with CNTL/Z.
Router(config)#interface Serial0
Router(config-if)#ip address 10.35.6.2 255.255.255.0  
Router(config-if)#exit
Router(config)#ip route 172.16.0.0 255.255.0.0 10.35.6.1 2
Router(config)#end
Router#

If you want to ensure a route remains in place even if the next-hop IP address becomes unreachable, or the interface goes down, you can use the permanent keyword:

Router#configure terminal
Enter configuration commands, one per line.  End with CNTL/Z.
Router(config)#ip route 10.35.15.5 255.255.255.255 Ethernet0 permanent
Router(config)#ip route 172.16.0.0 255.255.0.0 10.35.6.1 2 permanent
Router(config)#end
Router#

You can also manually configure routing tags that use static routes by using the tag keyword:

Router#configure terminal
Enter configuration commands, one per line.  End with CNTL/Z.
Router(config)#ip route 172.16.0.0 255.255.0.0 10.35.6.1 2 tag 36291
Router(config)#end
Router#

Discussion

The first version sends all packets destined to the single host 10.35.15.5 out through the Ethernet0 interface. In this case, ...

Get Cisco IOS Cookbook, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.