{"id":211,"date":"2020-09-26T13:29:31","date_gmt":"2020-09-26T13:29:31","guid":{"rendered":"https:\/\/dft.wiki\/?p=211"},"modified":"2026-06-09T14:49:42","modified_gmt":"2026-06-09T18:49:42","slug":"ospf-on-cisco-routers","status":"publish","type":"post","link":"https:\/\/dft.wiki\/?p=211","title":{"rendered":"OSPF on Cisco Routers"},"content":{"rendered":"<p>OSPF is an open standard (non-proprietary) routing protocol. It is a link-state protocol that allows all routers on the network to map the entire topology and make their own forwarding decisions based on that complete picture.<\/p>\n<p>Given the scenario below, PC1 needs to reach PC2:<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2020\/09\/image-72.png\" alt=\"This image has an empty alt attribute; its file name is image-72.png\" \/><\/figure>\n<\/div>\n<div class=\"wp-block-columns\">\n<div class=\"wp-block-column\">\n<p>Router1<\/p>\n<pre>enable \r\nconfigure terminal \r\nno ip domain lookup\r\nline con 0\r\nlogging synchronous\r\nhostname Router1<\/pre>\n<pre>interface g0\/0\r\nip address 192.168.3.1 255.255.255.252\r\nno shutdown\r\ninterface g0\/1\r\nip address 192.168.1.1 255.255.255.0\r\nno shutdown<\/pre>\n<\/div>\n<div class=\"wp-block-column\">\n<p>Router2<\/p>\n<pre>enable \r\nconfigure terminal \r\nno ip domain lookup\r\nline con 0\r\nlogging synchronous\r\nhostname Router2<\/pre>\n<pre>interface g0\/0\r\nip address 192.168.3.2 255.255.255.252\r\nno shutdown\r\ninterface g0\/1\r\nip address 192.168.2.1 255.255.255.0\r\nno shutdown<\/pre>\n<\/div>\n<\/div>\n<p><strong>Example of a Single Area configuration:<\/strong><\/p>\n<div class=\"wp-block-columns\">\n<div class=\"wp-block-column\">\n<p>Router1<\/p>\n<pre>router ospf 1\r\nnetwork 192.168.1.0 0.0.0.255 area 0\r\nnetwork 192.168.3.0 0.0.0.3 area 0\r\npassive-interface GigabitEthernet0\/1<\/pre>\n<\/div>\n<div class=\"wp-block-column\">\n<p>Router2<\/p>\n<pre>router ospf 1\r\nnetwork 192.168.2.0 0.0.0.255 area 0\r\nnetwork 192.168.3.0 0.0.0.3 area 0\r\npassive-interface GigabitEthernet0\/1<\/pre>\n<\/div>\n<\/div>\n<p>For simple networks with few routers this works perfectly. The problem starts when there are many routers, say 50. When one link goes down, all routers begin exchanging link-state messages. This overhead can be reduced by segmenting the network into areas:<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img decoding=\"async\" class=\"wp-image-435\" src=\"https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2020\/09\/image-79.png\" alt=\"\" \/><\/figure>\n<\/div>\n<p><strong>Configuring the interfaces according to the diagram above:<\/strong><\/p>\n<div class=\"wp-block-columns\">\n<div class=\"wp-block-column\">\n<p>RouterA1<\/p>\n<pre>enable \r\nconfigure terminal \r\nhostname RA1\r\nno ip domain lookup\r\nline con 0\r\nlogging synchronous\r\ninterface g0\/0\r\nip address 10.0.0.2 255.255.255.0\r\nno shutdown\r\ninterface s0\/0\/0\r\nip address 10.0.1.1 255.255.255.0\r\nno shutdown<\/pre>\n<p>RouterA3<\/p>\n<pre>enable \r\nconfigure terminal \r\nhostname RA3\r\nno ip domain lookup\r\nline con 0\r\nlogging synchronous\r\ninterface s0\/0\/1\r\nip address 10.0.3.1 255.255.255.0\r\nno shutdown\r\ninterface g0\/1\r\nip address 10.0.2.2 255.255.255.0\r\nno shutdown<\/pre>\n<p>RouterB2<\/p>\n<pre>enable \r\nconfigure terminal \r\nhostname RB2\r\nno ip domain lookup\r\nline con 0\r\nlogging synchronous\r\ninterface g0\/0\r\nip address 10.0.6.1 255.255.255.0\r\nno shutdown\r\ninterface g0\/1\r\nip address 10.0.5.2 255.255.255.0\r\nno shutdown<\/pre>\n<p>Router Gateway<\/p>\n<pre>enable \r\nconfigure terminal \r\nhostname Gateway\r\nno ip domain lookup\r\nline con 0\r\nlogging synchronous\r\ninterface s0\/0\/0\r\nip address 10.0.4.2 255.255.255.0\r\nno shutdown\r\ninterface s0\/0\/1\r\nip address 10.0.7.2 255.255.255.0\r\nno shutdown\r\ninterface s0\/1\/0\r\nip address 10.0.1.2 255.255.255.0\r\nno shutdown\r\ninterface s0\/1\/1\r\nip address 10.0.3.2 255.255.255.0\r\nno shutdown<\/pre>\n<\/div>\n<div class=\"wp-block-column\">\n<p>RouterA2<\/p>\n<pre>enable \r\nconfigure terminal \r\nhostname RA2\r\nno ip domain lookup\r\nline con 0\r\nlogging synchronous\r\ninterface g0\/0\r\nip address 10.0.0.1 255.255.255.0\r\nno shutdown\r\ninterface g0\/1\r\nip address 10.0.2.1 255.255.255.0\r\nno shutdown<\/pre>\n<p>RouterB1<\/p>\n<pre>enable \r\nconfigure terminal \r\nhostname RB1\r\nno ip domain lookup\r\nline con 0\r\nlogging synchronous\r\ninterface g0\/0\r\nip address 10.0.6.2 255.255.255.0\r\nno shutdown\r\ninterface s0\/0\/1\r\nip address 10.0.7.1 255.255.255.0\r\nno shutdown<\/pre>\n<p>RouterB3<\/p>\n<pre>enable \r\nconfigure terminal \r\nhostname RB3\r\nno ip domain lookup\r\nline con 0\r\nlogging synchronous\r\ninterface s0\/0\/0\r\nip address 10.0.4.1 255.255.255.0\r\nno shutdown\r\ninterface g0\/1\r\nip address 10.0.5.1 255.255.255.0\r\nno shutdown<\/pre>\n<\/div>\n<\/div>\n<p><strong>Configuring OSPF according to the areas in the diagram:<\/strong><\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img decoding=\"async\" class=\"wp-image-439\" src=\"https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2020\/09\/image-83.png\" alt=\"\" \/><\/figure>\n<\/div>\n<div class=\"wp-block-columns\">\n<div class=\"wp-block-column\">\n<p>RouterA1<\/p>\n<pre>router ospf 1\r\nnetwork 10.0.0.0 0.0.0.255 area 1\r\nnetwork 10.0.1.0 0.0.0.255 area 1<\/pre>\n<p>RouterA2<\/p>\n<pre>router ospf 1\r\nnetwork 10.0.0.0 0.0.0.255 area 1\r\nnetwork 10.0.2.0 0.0.0.255 area 1<\/pre>\n<p>RouterA3<\/p>\n<pre>router ospf 1\r\nnetwork 10.0.2.0 0.0.0.255 area 1\r\nnetwork 10.0.3.0 0.0.0.255 area 1<\/pre>\n<p>Router Gateway<\/p>\n<pre>router ospf 1\r\nnetwork 10.0.1.0 0.0.0.255 area 1\r\nnetwork 10.0.3.0 0.0.0.255 area 1\r\nnetwork 10.0.7.0 0.0.0.255 area 2\r\nnetwork 10.0.4.0 0.0.0.255 area 2<\/pre>\n<\/div>\n<div class=\"wp-block-column\">\n<p>RouterB1<\/p>\n<pre>router ospf 1\r\nnetwork 10.0.7.0 0.0.0.255 area 2\r\nnetwork 10.0.6.0 0.0.0.255 area 2<\/pre>\n<p>RouterB2<\/p>\n<pre>router ospf 1\r\nnetwork 10.0.6.0 0.0.0.255 area 2\r\nnetwork 10.0.5.0 0.0.0.255 area 2<\/pre>\n<p>RouterB3<\/p>\n<pre>router ospf 1\r\nnetwork 10.0.5.0 0.0.0.255 area 2\r\nnetwork 10.0.4.0 0.0.0.255 area 2<\/pre>\n<p><strong>Note:<\/strong><\/p>\n<ul>\n<li>Routers A* belong to area 1, so they are called Internal routers;<\/li>\n<li>Routers B* belong to area 2, so they are called Internal routers;<\/li>\n<li>Router Gateway has interfaces in both area 1 and area 2, so it is called an Area Border Router;<\/li>\n<\/ul>\n<\/div>\n<\/div>\n<p>The router that connects to outside the network requires this configuration:<\/p>\n<pre>router ospf 1\r\ndefault-information originate\r\nip route 0.0.0.0 0.0.0.0 g0\/0<\/pre>\n<p>This tells all other routers which one is the &#8216;<strong>gateway of last resort<\/strong>&#8216; when a destination network is unknown.<\/p>\n<p>To verify the configuration on each router, use the following commands:<\/p>\n<pre>show ip route\r\nshow ip route ospf\r\nshow ip protocols\r\nshow ip interface brief\r\nshow ip ospf\r\nshow ip ospf interface brief\r\nshow ip ospf interface\r\nshow ip ospf neighbor\r\nshow ip ospf database<\/pre>\n<p>Reference Bandwidth (for optimized route calculation):<\/p>\n<pre>router ospf 1\r\nauto-cost reference-bandwidth 10000\r\nip ospf cost 22222<\/pre>\n<p>Set all interfaces as passive by default:<\/p>\n<pre>passive-interface default\r\nno passive-interface Serial0\/0\/0\r\nno passive-interface Serial0\/0\/1<\/pre>\n<p>To enable <strong>authentication<\/strong> for OSPF, apply the following commands <strong>on all interfaces on all routers<\/strong>:<\/p>\n<pre>ip ospf message-digest-key 1 md5 PASSWORD\r\nip ospf authentication message-digest<\/pre>\n<p>Remember to replace &#8216;PASSWORD&#8217; with a secret of your choice.<\/p>\n<p>Learn more about [<a href=\"https:\/\/www.youtube.com\/watch?v=kfvJ8QVJscc\">OSPF Single<\/a> &#8211; CertBros]<\/p>\n<p>Learn more about [<a href=\"https:\/\/www.youtube.com\/watch?v=PIMnj2oqYIo\">OSPF Multi<\/a> &#8211; CertBros]<\/p>\n<p>The previous post was about RIPv2 [<a href=\"https:\/\/dft.wiki\/?p=205\">Read It<\/a>].<\/p>\n<p>The following post is about EIGRP [<a href=\"https:\/\/dft.wiki\/?p=209\">Read It<\/a>].<\/p>\n","protected":false},"excerpt":{"rendered":"<p>OSPF is an open standard (non-proprietary) routing protocol. It is a link-state protocol that allows [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-211","post","type-post","status-publish","format-standard","hentry","category-ccna"],"_links":{"self":[{"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/posts\/211","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dft.wiki\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=211"}],"version-history":[{"count":11,"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/posts\/211\/revisions"}],"predecessor-version":[{"id":5837,"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/posts\/211\/revisions\/5837"}],"wp:attachment":[{"href":"https:\/\/dft.wiki\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=211"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dft.wiki\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=211"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dft.wiki\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=211"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}