Next: Multicast RIB Commands, Previous: Interface Commands, Up: Zebra [Contents][Index]
Static routing is a very fundamental feature of routing technology. It defines static prefix and gateway.
network is destination prefix with format of A.B.C.D/M. gateway is gateway for the prefix. When gateway is A.B.C.D format. It is taken as a IPv4 address gateway. Otherwise it is treated as an interface name. If the interface name is null0 then zebra installs a blackhole route.
ip route 10.0.0.0/8 10.0.0.2 ip route 10.0.0.0/8 ppp0 ip route 10.0.0.0/8 null0
First example defines 10.0.0.0/8 static route with gateway 10.0.0.2. Second one defines the same prefix but with gateway to interface ppp0. The third install a blackhole route.
This is alternate version of above command. When network is A.B.C.D format, user must define netmask value with A.B.C.D format. gateway is same option as above command
ip route 10.0.0.0 255.0.0.0 10.0.0.2 ip route 10.0.0.0 255.0.0.0 ppp0 ip route 10.0.0.0 255.0.0.0 null0
These statements are equivalent to those in the previous example.
Installs the route with the specified distance.
Multiple nexthop static route
ip route 10.0.0.1/32 10.0.0.2 ip route 10.0.0.1/32 10.0.0.3 ip route 10.0.0.1/32 eth0
If there is no route to 10.0.0.2 and 10.0.0.3, and interface eth0 is reachable, then the last route is installed into the kernel.
If zebra has been compiled with multipath support, and both 10.0.0.2 and 10.0.0.3 are reachable, zebra will install a multipath route via both nexthops, if the platform supports this.
zebra> show ip route S> 10.0.0.1/32 [1/0] via 10.0.0.2 inactive via 10.0.0.3 inactive * is directly connected, eth0
ip route 10.0.0.0/8 10.0.0.2 ip route 10.0.0.0/8 10.0.0.3 ip route 10.0.0.0/8 null0 255
This will install a multihop route via the specified next-hops if they are reachable, as well as a high-metric blackhole route, which can be useful to prevent traffic destined for a prefix to match less-specific routes (eg default) should the specified gateways not be reachable. Eg:
zebra> show ip route 10.0.0.0/8 Routing entry for 10.0.0.0/8 Known via "static", distance 1, metric 0 10.0.0.2 inactive 10.0.0.3 inactive Routing entry for 10.0.0.0/8 Known via "static", distance 255, metric 0 directly connected, Null0
These behave similarly to their ipv4 counterparts.
Select the primary kernel routing table to be used. This only works for kernels supporting multiple routing tables (like GNU/Linux 2.2.x and later). After setting tableno with this command, static routes defined after this are added to the specified table.
Next: Multicast RIB Commands, Previous: Interface Commands, Up: Zebra [Contents][Index]