Internal Routing protocols

By internal we mean routing protocols to exchange routing information used within a single administrative domain. Often referred to as an IGP (Internal Gateway Protocol)

There are a number of protocols. RIP was one of the first, but it only understands Class-full IP addresses (/8's /16's /24's). RIPv2 (sometimes called RIPng) understands modern classless networks. RIP (v1 or v2) is a distance vector protocol. A distance vector protocols share their entire routing table with neighboring routers at specified intervals and include a distance (sometimes called a hop count) for each route. Routers use the route with the shortest hop count seen for delivery.

OSPF is a "link state" protocol. It is defined in RFC 2328. Link state protocols only tell other participating routers about their neighbors (links) and costs to reach their neighbors. Then each router uses this information to build a graph and applies "Dijkstra's Algorithm" to find the shortest path to each network.

We are going to be using OSPF in our lab as an internal routing protocol.

Ospf within an autonomous system can further subdivided the network into areas. There is one backbone area (area 0) and all other areas must border on the backbone area (there are exceptions, using "virtual links", but these area only used rarely). Each router interface belongs to one and only one area. A router with interfaces on more than one area is known as a Area Border Router (ABR) and can summarize the routing information it advertises to the backbone.

A router with an interface that is not within the Autonomous System is a Autonomous System Border Router (ASBR) and can inject routes learned from other AS's and via other routing protocols into the OSPF AS.

So you have 4 different types of routers in ospf. An internal router which has all interfaces in one area. An Area Border Router (ABR) which has one or more interfaces in the backbone area and one or more in other areas. A Backbone router which has one or more interface in the backbone area (ABR's are also backbone routers, but so are routers with all interfaces in the backbone.) And last, a Autonomous System Border Router (ASBR) which has at least one interface in the OSPF AS and at least one interface in another AS.

You also have 4 different types of routes in ospf.


	intra-area routes  	- detailed information within the area
	inter-area routes 	- often summary of area addresses to backbone area.
	external routes type 1	- uses same metric as intra or inter area routes
	external routes type 2	- metrics for these are higher cost then any of the external
			          type 1 and inter/intra area metrics. So are only 
				  compared to other ASE type 2 routes. Often they 
				  are based on some other routing protocol costs.

Each interface has a cost associated with it. OSPF protocol uses these costs to compute the shortest path. These costs are a 16 bit number between 1 and 65535. Most routers have default costs for interfaces based on the speed on the link. You can override these default costs to engineer the traffic flow through your network.

OSPF on zebra/quagga and cisco routers

OSPF supports a number of different types of networks. We will be using Broadcast Multiaccess networks (IE ethernet). It can also support point to point links (with no broadcast or multicast capabilities) or non-broadcast multiaccess networks (like frame relay)

OSPF consists of a a number of different message types. The HELLO packets are used on broadcast network segments to discover other routers on that network segment (that layer 2 broadcast domain) and to elect a designated router (DR) and backup designated router (BDR) for that network segment. All routers on a network segment will form an adjacency with the DR and BDR. This means they share all link state information with the DR and BDR. The DR will share adjacency information with other network segments and also propagate this to all routers on its segment. The BDR also maintains full information in case the DR goes down, to allow a quick recovery. The DR also generates a network advertisement for the segment. The DR/BDR are chosen (elected) via information exchanged in the HELLO protocol. There is a settable priority for each router, and the highest priority will be chosen as DR. Once chosen they do not change unless the DR or BDR go down. If the priority is the same then the router with the highest router ID becomes DR.

Every router running ospf will choose one of its interfaces as a router-id. This 32 bit number (IP address) will uniquely identify the router. You can set this manually in some ospf implementations, or it can be chosen for you from the interfaces on the router. The RFC suggests if chosen automatically it can be the lowest numeric IP address.

OSPF uses multicast addresses to communicate on broadcast networks. 224.0.0.5 is for all ospf routers. It is used in the hello protocol and also used by the DR to send LSA updates to all routers on a network. 224.0.0.6 is for all Designated Routers (DE and BDR). It is used by routers to send LSA updates to the DR's.

During the process of routers becoming adjacent they exchange database description packets to insure that they all have consistent ideas of the state of the network. Then as links go up and down routers exchange LSA packets (by sending them to the DR, which then sends to all adjacent routers).

Area Border Routers can summarize route information and will then only send this summary network advertisements to the core (and hence the core to other routers).

OSPF can also uses a shared secret authentication system to ensure that only authorized routers can participate in the protocol.

Configuring OSPF on linux/quagga routers in vtysh

Linux/Quagga routers have a separate process to perform the OSPF protocol. It is called ospfd and it communicates with the zebrad process to install routes in the system. It has a separate configuration file, usually called ospfd.conf (though you can choose any name). The config file MUST initially have a line
	hostname rX
where the rX matches the rX in the zebrad.conf file.

You can configure this process with the vtysh program. It will accept commands for both the zebrad and ospfd processes and send them to the appropriate process. When you save (via copy running startup) it will write the appropriate commands to the appropriate config files also.

To configure a quagga router to use ospf you need to do two things. First give commands on the interface level to set the interface parameters, IE the cost of the link and the authentication parameters. Also you need to tell the ospf process which networks you are connected to are going to participate and which areas they are in.

For example: If you had a router with 2 interfaces, eth0 and eth1. eth0 has IP 10.50.1.1/24 and connects to 10.50.1.0/24 network. eth1 has IP 10.60.1.130/27 and connects to network 10.60.1.128/27. eth0 is in area 0 and eth1 is in area 1. eth0 has a cost of 1000 and eth1 has a cost of 100. Both eth0 and eth1 networks use md5 authentication for OSPF and the passwords are "ospfpass" for eth0 and "ospfpass" for eth1.

Here is the configuration commands you you issue to vtysh. Assume the ip address information has already been configured on the interfaces.

!
! This configures the authentication and costs on eth0
!
	interface eth0
	 ip ospf authentication message-digest
	 ip ospf message-digest-key 1 md5 ospfpass
	 ip ospf cost 1000
	 quit

!
! This configures the authentication and costs on eth1
!
	interface eth1
	 ip ospf authentication message-digest
	 ip ospf message-digest-key 1 md5 ospfpass
	 ip ospf cost 100
	 quit
!
! Here we set the router ID 
! Then we specify which networks are in which areas
!
	router ospf
	 router-id 10.50.1.130
	 network 10.50.1.0/24 area 0.0.0.0
	 network 10.60.1.128/27 area 0.0.0.1
	 quit

Under the router ospf section you can also specify aggregation on the Area Border Routers. If area 1 could be aggregated to 10.60.1.128/25 you could specify this in the router ospf clause as such:

        router ospf
         router-id 10.50.1.130
         network 10.50.1.0/24 area 0.0.0.0
         network 10.60.1.128/27 area 0.0.0.1
	 area 0.0.0.1 range 10.60.1.128/25
         quit

Cisco routers configuration is quite similar. In fact the Interface level commands are the same, other than the interface names themselves. Example:

 	interface eth1/1
	 ip ospf authentication message-digest
	 ip ospf message-digest-key 1 md5 net1pass
	 ip ospf cost 100
	 quit
But in the router ospf stanza there are two differences. One is that you must specify the process number on the router ospf command. You can pick some randomish number that doesn't interfere with other process numbers you are using. The other major difference is that instead of using normal CIDR /XX notation to specify ranges on the network command you have to use wildcard bitmasks (which are the inverse of the corresponding dotted quad netmask). IE, a /24 would be 0.0.0.255. A /26 would be 0.0.0.63. Etc. On a cisco the router ospf stanza would look like this:
        router ospf 1
         router-id 10.50.1.130
         network 10.50.1.0 0.0.0.255 area 0.0.0.0
         network 10.60.1.128 0.0.0.31 area 0.0.0.1
         area 0.0.0.1 range 10.60.1.128 255.255.255.128
We have a number of tools to help us debug the ospf state on quagga and IOS routers. Here are a few:
! 
! Show ospf interface parameters
!
	show ip ospf interface
!
! Show ospf neighbor information
! 
	show ip ospf neighbor
!
! Show ospf database information
! 
	show ip ospf database
!
! Show ospf route information
! 
	show ip ospf route

OSPF on JunOS routers

For JunOS routers you will configure ospd in the protocols section. Here you will define your areas and in each area place the interfaces and the metrics and authentication information. Here is the JunOS config for a interface fxp1.0 that is in area 0.

juniper@br# edit protocols ospf   

[edit protocols ospf]
juniper@br# set area 0.0.0.0 interface fxp1.0 metric 1000

[edit protocols ospf]
juniper@br# set area 0.0.0.0 interface fxp1.0 authentication md5 1 key ospfpass

[edit protocols ospf]
juniper@br# show 
area 0.0.0.0 {
    interface fxp1.0 {
        metric 100;
        authentication {
            md5 1 key "$9$2/gGiPfz6CuQF"; ## SECRET-DATA
        }
    }
}

[edit protocols ospf]
juniper@br# 

To set the router-id used by OSPF (and later BGP) for BR, you set it under the routing-options level. Example:


[edit routing-options]
juniper@br# router-id 10.50.0.1

For the border router we might also want to inject a default route into the ospf routing. To do this in JunOS you will need to create a policy-statement under the policy-options hierarchy. Then we will want to tell the ospf protocol to use this defined policy to effect the injection of the default route into the ospf protocol. We area going to inject as a type 2 Autonomous System External route so its metric will only be compared to other ASE type 2 metrics, the internal metrics are not considered.

First we define the policy

[edit protocols ospf]			NOTE, we are starting from the edit protocols ospf level
juniper@br# up 				We go back to the top level 

[edit protocols]
juniper@br# up 

[edit]
juniper@br# edit policy-options policy-statement POLICYNAME 

[edit policy-options policy-statement POLICYNAME]
juniper@br# set term TERMNAME from route-filter 0.0.0.0/0 exact 	use an exact route-filter
									for the default route
[edit policy-options policy-statement POLICYNAME]
juniper@br# set term TERMNAME then metric 5000 

[edit policy-options policy-statement POLICYNAME]			set the metric and type to use
juniper@br# set term TERMNAME then external type 2

[edit policy-options policy-statement POLICYNAME]			and accept the route
juniper@br# set term TERMNAME then accept             			

[edit policy-options policy-statement POLICYNAME]			second term simply rejects any other
juniper@br# set term ANOTHERTERMNAME then reject 

[edit policy-options policy-statement POLICYNAME]
juniper@br# show 
term TERMNAME {
    from {
        route-filter 0.0.0.0/0 exact;
    }
    then {
        metric 5000;
        external {
            type 2;
        }
        accept;
    }
}
term ANOTHERTERMNAME {
    then reject;
}

[edit policy-options policy-statement POLICYNAME]
juniper@br# 

Note that POLICYNAME and TERMNAME and ANOTHERTERMNAME can be any string you choose. It is a good idea to use meaningful names..

Now what we have defined the policy we apply it to the ospf protocol.

[edit policy-options policy-statement POLICYNAME]
juniper@br# top      					shortcut to top level

[edit]
juniper@br# set protocols ospf export POLICYNAME 	apply our policy as what to export
							to ospf protocol
[edit]
juniper@br# show protocols ospf 
export POLICYNAME;
area 0.0.0.1 {
    interface fxp1.0 {
        metric 100;
        authentication {
            md5 1 key "$9$vLfM7Vg4ZjkPJG"; ## SECRET-DATA
        }
    }
}

[edit]
juniper@br# 

NOTE: for the JunOS router to insert any route into OSPF it must have that route in it's routing table. In this case we want to insert the 0.0.0.0/0 (default route) So we want to make sure we have that route in our table. It should be there currently as a static route.