IP Routing Protocols For Dummies ================================ Sam Wilson, EUCS 27/9/02 [[[ BGP description still missing, not sure if redistribution is well enough described yet or if this is the right place to talk about default redistribution ]]] Here is some basic info about how IP routing protocols work, at least the three we use in Edinburgh - RIPv1, OSPF and BGP. How the EdLAN core uses OSPF and RIP is described in ; the EaStMAN-EdLAN BGP setup is described in . The major source of information for all these things is the Cisco IOS documentation. The main Cisco documentation page is at and at the time of writing the IOS documentation is accessed from a drop-down menu at the top right. Documentation for IOS 12.1 is at and the usual next link is for the Comfiguration Guides (explanation and simple how-tos) and Command References (exhaustive lists of commands). These are definitely worth getting familiar with - they're difficult to use to find things the first time, but once you know what's there they're very valuable. Classful vs Classless Routing ----------------------------- The original specification for IP addresses divided network addresses into three main classes. Networks within each class were treated as atomic wholes. Later the concept of subnetting allowed for breaking up of networks into smaller parts internally, but from outside the network it was still regarded as a single entity. Classless routing (CIDR, Classless Inter-domain Routing, RFC 1519) allows for two main extensions: the splitting of formerly classful networks into separate parts, and the aggregation of groups of smaller networks. There are two main effects on the behaviour of router which is acting classlessly. Firstly it is possible to configure interfaces with network numbers and masks which are not allowed under classful operation, e.g. a network number from the former class C range, say 192.41.102.0, being configured with a mask shorter than the classful 24 bits, say 192.41.102.0/23. This is known as "supernetting". Secondly a classful router assumes all parts of a classful network are contiguous. The following setup is therefore infeasible: +------+ +------+ network X ______|router|___________|router|______ network X subnet 1 | P | network Y | Q | subnet 2 +------+ +------+ Not only will neither router accept an explicit route via network Y to the other subnet of network X, neither will it forward traffic for unknown subnets of network X along a default path, should either router have a default pointing to the other. Classless routing allows both of these things to happen. Incidentally the convention "/n" to specify a network mask arose with CIDR - previously a subnet could be specified with any combination of bits, with CIDR only masks composed of contiguous, left-justified 1-bits are legitimate. Variable Length Subnet Masking ------------------------------ Linked to CIDR, and predating it somewhat, is the concept of variable length subnet masking (VLSM). One concept implied in some of the early work on subnetting was that a classful network should be divided into subnets by applying a single subnetmask, i.e. the netmask was the same for every subnet mask. Some protocols, e.g. RIPv1, implicitly enforce this by not passing netmasks around in routing advertisements, thus having to infer the mask either from the mask configured on a connected interface or from the class of an unconnected network. Later protocols like OSPF explicitly pass around masks with their announcements allowing for both different subnet masks within a classful network or fully classless operation. RIP --- RIP, the Routing Information Protocol (as if there weren't any others) is described, though not defined, in RFC 1058. Reading and understanding that RFC is highly recommended. Strictly that RFC defines RIPv1, an inherently classful routing protocol because it does not pass netmasks with routing updates and therefore has to infer them. RIPv2 is a classless successor which is not used in EdLAN. Future references to RIP in this document refer only to RIPv1. RIP is a distance vector protocol, that is, the only knowledge that a router keeps about how to reach networks is a vector of metrics ("distances") applying to those networks and the address of the next hop on the route. The vectors of network and distance are broadcast to other routers every 30 seconds. Each router simply listens to the broadcasts and if another router is advertising a better route to a destination than it already has the existing entry is replaced. If a routing entry is not heard about for 3x30 seconds the entry is removed. There are other refinements but this strategy results in the feature that "good news travels quickly, bad news travels slowly" - new routes get inserted in one wave of updates across the network; withdrawn routes take multiple update periods to be removed. Note also that neighbour keepalive information and network reachability information are combined in a single update - receipt of the update confirms both that the neighbour is present and the list of networks it is advertising. This approach can be regarded as wasteful of network bandwidth. The basic metric in RIP is the "hop count", the number of routers that traffic has to pass through to reach the destination network. A route is deemed to be better than another if the hop count is lower. The hop count can be manipulated to prefer some network links over others, but RIP is fundamentally ill-suited to networks where choices have to be made between dissimilar links. RIP is also susceptible to routing loops, particularly during changes in topology as routing updates propagate. The basic technique for removing these loops is "counting to infinity" - as routing information propagates around a loop the hop count is incremented until it reaches "infinity". Clearly counting to a genuine value of infinity is impossible so in RIP networks infinity is defined to be 16 hops. This means that the maximum distance between endpoints in a RIP network is constrained to be 15 hops. In practice this isn't much of a limitation. Because routing information is propagated on a hop-by-hop basis it is very easy to control how traffic is routed by filtering the broadcasts that each router sends or receives. When configuring a router with RIP the basic command is the "network ..." command which specifies a classful network number. Any interface with an address within the specified network both transmits and will receive RIP updates. For a particular interface transmission of RIP updates can be stopped completely using the "passive-interface" command and partial or complete transmission can be controlled using "distribute-list ... out". Reception of RIP can be controlled using the "distance ..." command or with "distribute-list ... in". OSPF ---- OSPF is a link-state protocol where each router keeps a map of the whole autonomous system, works out for itself which is the best route to every destination and installs the requisite next-hop in the routing table. Every router also knows about routes from outside the AS (external routes) and which router is advertising them into the AS. It also follows that once a link failure is detected a router can recalculate routes to the whole network immediately without waiting for other routers to pass the message on. What goes on in real life is more complex but you generally don't need to know much more. OSPF uses a bandwidth-related metric on each link so it can route traffic by the fastest route which may not necessarily be the shortest. By default this integer metric is set to 10^9/bps where bps is the speed of the interface in bits per second which is fine up to 1Gbps. From the fact that every router has a map of the network it follows that there can be no filtering of routes within an AS - every router by definition knows about every part of the network. There are small exceptions to this. Firstly the AS is divided into areas and between areas there can be summarisation of routes (a suitable group of /24s in one area could be summarised as a /22 in other areas, say). Secondly there are two specific types of areas called stub areas and not so stubby areas (NSSAs) where the only external route that is advertised into the area is the default. It is important to understand the use of areas in OSPF. Every OSPF setup has a central area, area 0. All other areas are linked to area 0 by area boundary routers (ABRs). Areas may be physically chained to non-zero areas but in that case the ABR linking has to be configured with a "virtual link" to an ABR in area 0 - we have no virtual links in EdLAN. A router which injects routes from outside the AS is an autonomous system boundary router or ASBR. We'll see under "Route Redistribution" below that in fact almost every router is an ASBR. When configuring a router those links which are included in the OSPF AS and in which area is decided by the use of "network" commands in the OSPF command stanza. These specify network address ranges on a base+mask basis and any interface with an address included in such a range is configured into the specified area and both sends and receives OSPF updates. There is really no other gross control over OSPF connectivity, though there are numerous parameters that can be tweaked. In OSPF the reachability (network) information is propagated separately from neighbour availability information - the routing database is propagated every 30 minutes but neighbours operate a keepalive "hello" protocol on a 10 second interval. A router can operate more than one OSPF AS with redistribution of routes between them, but metric information is lost at redistribution. Each OSPF process is identified by a separate AS number but this is for local identification only - there is no propagation of AS numbers in the OSPF protocol. It is sensible to try to keep OSPF AS numbers consistent between routers but it's only confusing if you don't, thing still work. BGP --- Route Redistribution -------------------- In general routing protocols only propagate network routes that are configured on interfaces assigned to that protocol or are learned using the protocol or, in the case of BGP, are explicitly configured to be propagated. Distributing routing information between protocols is tricky. The main reason is because they use different metrics for choosing the route and it is not easy to translate metrics learned in one protocol into those used by another. The usual thing to do is to set a default metric for any route learned from another protocol. The other oddity is that it's possible only to export a subset of routes from a CIDR/VLSM-aware protocol like OSPF into a classful protocol like RIPv1. I hope the reason is obvious. We try not to do it. Redistribution between protocols is done with the "redistribute ..." command. It is a huge and baroque command allowing vast control over what gets redistributed. The basic idea is illustrated by this configuration fragment: router ospf 64585 redistribute rip metric 1000 subnets : : This tells the OSPF process identified by AS number 64585 to redistribute routes learned from RIP, to offer them with a metric of 1000, and to propagate individual subnets not just the classful network numbers. Routes can also be redistributed under the control of a route-map which allows for very tight control. The groups of networks that can be redistributed are: other routing protocol instances (RIP, OSPF , BGP and so on), static routes and connected routes. Since RIP is turned on for a whole classful network at once every interface with an address in that that range is included in RIP and is advertised. If a router has interfaces in separate classful networks and RIP is turned on for all of them then redistribution happens automatically. If RIP is enabled for only one out of several classful networks, or if OSPF is used and only some interfaces configured then each routing protocol may need to be configured to redistribute connected routes. For instance a router with two backbone connections configured for OSPF and other departmental connections not configured for OSPF will not, by default, announce the departmental connections in OSPF. A router with RIP enabled only for one classful network will not bny default announce another classful network in RIP. For example consider a router with the following interface configurations: int vlan 301 ip address 129.215.0.5 255.255.255.252 int vlan 302 ip address 129.215.0.9 255.255.255.252 int vlan 601 ip address 192.168.1.254 255.255.255.0 int vlan 602 ip address 192.168.2.254 255.255.255.0 If OSPF is configured only on vlans 301 and 302 then for the 192.168 networks to be propagated into OSPF the 'redistribute connected' command will have to be given: router ospf 64585 ! put both vlans 301 and 302 into area 0 network 129.215.0.4 0.0.0.3 area 0 network 129.215.0.8 0.0.0.3 area 0 ! redistribute the other connected networks redistribute connected default-metric 1000 In this example, rather than specify the metric in the "redistribute" command a default metric is set. Similarly with RIP configured as below then the 'redistribute connected' command makes sure that 129.215.0.0/16 and 192.168.1.0/16 are advertised by RIP to systems in 192.168.2.0/16. router rip ! only speak and listen to rip on vlan 602 network 192.168.2.0 ! propagate other connected networks in rip redistribute connected default-metric 5 NOTE: unless a metric is set, either explicitly on the redistribute command on in a default-metric command no redistribution takes place - a cause of much head scratching in the past.