O'Reilly logo

Cisco IOS Cookbook, 2nd Edition by Ian Brown, Kevin Dooley

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required