ip route
17-14 IP Configuration
Usage
RoutesaremanagedbytheRTM(RouteTableManager),andarecontainedintheRIB(Route
InformationBase).Thisdatabasecontainsalltheactivestaticroutes,andalltheRIProutes.
TheRTMselectsuptothreeofthebestroutestoeachnetworkandinstallstheseroutesintheFIB
(ForwardingInformat ion Base).
Example
ThisexampleshowshowtodisplayallIProuteinformation.Inthiscase,thereareroutesdirectly
connectedtoVLANs1and2,twostaticroutesconnectedtoVLAN1(oneindirectly,andonevia
anothernetworkIP),andoneRIProute.Distance/costisdisplayedas[x/y]:
B3(su)->router#show ip route
Codes: C – connected, S – static, R – RIP, * - candidate default, U – per user
static route
C 192.168.27.0/24 [ 0/0001] directly connected, vlan 1
C 192.168.32.0/24 [ 0/0001] directly connected, vlan 2
S 2.0.0.0/8 [ 65/0001] via 192.168.72.1, vlan 1
S 3.0.0.0/8 [ 0/0001] directly connected vlan 1
R 1.0.0.0/8 [ 70/0002] via 192.168.72.22 vlan 1
ip route
UsethiscommandtoaddorremoveastaticIProute.Thenoformofthiscommandremovesthe
staticIProute.
ip route prefix mask dest-addr [distance]
no ip route prefix mask forward-addr
Parameters
Defaults
Ifdistanceisnotspecified,thedefaultvalueof1willbeapplied.
Mode
Globalconfiguration:B3(su)‐>router(Config)#
Example
ThisexampleshowshowtosetIPaddress10.1.2.3asthenexthopgatewaytodestinationaddress
10.0.0.0:
B3(su)->router(Config)#ip route 10.0.0.0 255.0.0.0 10.1.2.3
prefix SpecifiesadestinationIP addressprefix.
mask Specifiesadestinationprefixmask.
dest‐addr Specifiesaforwarding(gateway)IPaddress.
distance (Optional)Specifiesanadministrativedistancemetricforthisroute.Valid
valuesare1(default)to255.Routeswithlowervaluesreceivehigher
preferenceinrouteselection.