A few different types of static routing can be configured for both IPv4 and IPv6. The concepts are the same and the commands are somewhat similar too. These are the four types of static routing.
Here is the topology used for IPv4:
Here is the topology used for IPv6:
Default route
- A default route is used to route traffic to any network that is not in your routing table. without a default route defined, any traffic destined to a network that is not in the routing table will be dropped by the router.
- A default route is configured to route packets to networks that are not in your routing table.
- Without a default route, the destination address must match an address in your routing table, otherwise the packets will be dropped by the router
- Typically, the default route points to the internet
- A default route puts the onus of routing on the next hop router.
- Most often the default route is an upstream router.
- It’s like a router saying I don’t know how to get to that destination, but my default route says to send it to this next hop so I’ll make it that router’s job to figure it out.
- A default route identifies the gateway IP address to which the router sends all IP packets for which it does not have a learned or static route.
- A default static route is simply a static route with 0.0.0.0/0 as the destination IP address.
- Routes that identify a specific destination take precedence over the default route.
Configure an IPv4 default route by typing:
config t
ip route 0.0.0.0 0.0.0.0 (exit-interface-on-this-router)
--OR--
ip route 0.0.0.0 0.0.0.0 (next-hops-ipv4-address)
R1# config t
R1(config)#ip route 0.0.0.0 0.0.0.0 172.16.0.2
R1(config)#^Z
R1#
Configure an IPv6 default route by typing:
config t
ipv6 route ::/0 (exit-interface-on-this-router)
--OR--
ipv6 route ::/0 (next-hop-ipv6-address)
Router1(config)#ipv6 route ::/0 2001:DB8::C802:17FF:FE35:8
Network route
- A network route is configured to route packets to a specific network
- You may add many different network routes to the routing table
- Without a network route, packets will get routed via the default route if one exists
- Network routes are used for networks that are not locally or directly connected to the router
- A network route identifies the network, network mask and next hop IP address to send packets to
- The network mask in a network route can be /1 through /31
- The network mask in a network route cannot be /0 (default route) or /32 (host route)
- More specific network routes take precedence over less specific network routes (based on the network mask)
Configure an IPv4 Network route by typing:
config t
ip route (network-to-route-to) (subnet-mask) (exit-interface-on-this-router)
--OR--
ip route (network-to-route-to) (subnet-mask) (next-hops-ipv4-address)
We could configure router R1 and R2 to access each other with a static network route:R1(config)#ip route 10.0.1.0 255.255.255.0 172.16.0.2
R2(config)#ip route 10.0.0.0 255.255.255.0 172.16.0.1
Configure an IPv6 Network route by typing:
config t
ipv6 route (network-to-route-to)/(subnet-mask) (exit-interface-on-this-router)
--OR--
ipv6 route (network-to-route-to)/(subnet-mask) (next-hop-ipv6-address)
Router(config)#ipv6 route 2001:DB8:0:1::/64 2001:DB8::C802:17FF:FE35:
Host route
A host route is used to route traffic to a specific host. The subnet mask in the route will always be all 1’s. That means the subnet mask for a host route will be /32 for IPv4 and /128 for IPv6.
- A host route is configured to route packets to a specific host
- The subnet mask will be all 1’s
- The IPv4 subnet mask of a host route will always be /32
- The IPv6 subnet mask of a host route will always be /128
- Host routes are automatically added to the routing table for all IPv4 and IPv6 addresses that are configured on the router
- The purpose of a host route is to create a corresponding CEF entry as a receive entry so that the packets destined to this IP address can be processed by the router itself
- Loopback interfaces are commonly created with /32 subnet masks and will therefore appear as a host route in the routing table
- Host routes are the most specific route possible and therefore take precedence over all other routes (based on the network mask)
Configure an IPv4 Host route by typing:
config t
ip route (host-to-route-to) 255.255.255.255 (exit-interface-on-this-router)
–OR–
ip route (network-to-route-to) (subnet-mask) (next-hops-ipv4-address)
R1(config)#ip route 10.0.1.1 255.255.255.255 172.16.0.2
Configure an IPv6 Host route by typing:
config t
ipv6 route (network-to-route-to)/(subnet-mask) (exit-interface-on-this-router)
–OR–ipv6 route (network-to-route-to)/(subnet-mask) (next-hop-ipv6-address)
Router(config)#ipv6 route 2001:DB8:0:3:C803:17FF:FE44:1C/128 2001:DB8::C802:17FF:FE35:8
Floating static route
A floating static route is a static route with an administrative distance higher than that of the routing protocol in use. In this way, the floating static route will only appear in the routing table if the existing static or dynamic route is lost
- Floating static routes are static routes with the administrative distance specified
- Floating static routes administrative distance is purposefully set higher than the preferred dynamic routing protocol
- Floating static routes act as a backup route should the preferred dynamic routing protocol lose its neighbor relationships and therefore have its routes removed from the routing table
- When the dynamic routes are removed from the routing table, the floating static route is inserted into the routing table since it has the next best administrative distance
- Floating static routes will also work to prefer one circuit over another
- For example, if you have one circuit that is 100Mbps and another that is 45Mbps you might want to set a static route over the 100Mbps circuit. It’s admin distance is 1. Then you’d set a floating static route to go across the 45Mbps circuit with an admin distance of 2 or higher. If the 100Mbps circuit goes down, the static route will be removed from the routing table and the floating static route will be used.
Configure an IPv4 Floating static route by typing:
ip route (network-to-route-to) (subnet-mask) (next-hops-ipv4-address) (chosen-admin-distance)
R1(config)#ip route 10.0.1.0 255.255.255.0 172.16.0.2 254
Configure an IPv6 Floating static route by typing:
Router(config)#ipv6 route 2001:DB8:0:1::/64 2001:DB8::C802:17FF:FE35:8 254