{"id":4813,"date":"2014-04-28T09:49:33","date_gmt":"2014-04-28T15:49:33","guid":{"rendered":"http:\/\/gregsowell.com\/?p=4813"},"modified":"2014-04-28T09:49:33","modified_gmt":"2014-04-28T15:49:33","slug":"cisco-bgp-prepend-all-routes-the-lazy-way","status":"publish","type":"post","link":"https:\/\/gregsowell.com\/?p=4813","title":{"rendered":"Cisco BGP Prepend All Routes &#8211; The Lazy Way"},"content":{"rendered":"<p>One man&#8217;s lazy is another man&#8217;s efficient.  I&#8217;m the most efficient guy you know \ud83d\ude1b<\/p>\n<p>Prepending is adding your AS number to BGP NLRI multiple times to make a set of routes look further away and thus less preferred.  <\/p>\n<p><strong>Without Prepending:<\/strong><\/p>\n<pre class=\"gs-code\"><code class=\"language-plaintext\">Router# show ip bgp 1.1.1.0\/24\r\nBGP routing table entry for 1.1.1.0\/24, version 555663701\r\n  65001 4323 15169, (received &amp; used)<\/code><\/pre>\n<p><strong>With Prepending:<\/strong><\/p>\n<pre class=\"gs-code\"><code class=\"language-plaintext\">Router# show ip bgp 1.1.1.0\/24\r\nBGP routing table entry for 1.1.1.0\/24, version 555663701\r\n  65001 65001 65001 4323 15169, (received &amp; used)<\/code><\/pre>\n<p>As you can see, in the second entry with prepending the AS distance to the route was 2 AS hops further away, and thus less preferred.<\/p>\n<p>Say for example a customer wants you to prepend every route to them.  The customer could just adjust local preference on their side, but if they aren&#8217;t comfortable with that, you can do the adjustment to prepending for them.<\/p>\n<p>First, we create a route map that will do the prepending:<\/p>\n<pre class=\"gs-code\"><code class=\"language-plaintext\">route-map bgp-&gt;prepend permit 10 !create the map\r\n description :: Prepend 2 times to routes !always add a description ALWAYS\r\n set as-path prepend 65001 65001 !add the prepending command<\/code><\/pre>\n<p>Normally on a route-map statement you are required to use a &#8220;match&#8221; command.  In the match command you will use something like an access-list or a prefix-list to specify which NLRI to act upon.  In our case we wanted to act on everything.  <strong>If you simply omit the match statement it uses an implicit &#8220;any&#8221;, and will capture everything.<\/strong><\/p>\n<p>We then add the route-map to the neighbor:<\/p>\n<pre class=\"gs-code\"><code class=\"language-plaintext\">router bgp 65001 !enter your BGP process\r\n address-family ipv4 !enter the v4 address family\r\n neighbor 10.0.0.1 route-map bgp-&gt;prepend out !assign our new route-map to the peer outgoing\r\nexit !get back to config mode\r\nexit !get back to enable mode\r\nclear ip bgp 10.0.0.1 soft out !do a soft clear on the peer to send the new prepending towards the<\/code><\/pre>\n<p>That&#8217;s just about as few lines as you can use to prepend everything.  I like using route-maps like this because if later on down the road I want to adjust them again, I just add an incremented statement \ud83d\ude42<\/p>\n","protected":false},"excerpt":{"rendered":"<p>One man&#8217;s lazy is another man&#8217;s efficient. I&#8217;m the most efficient guy you know \ud83d\ude1b Prepending is adding your AS number to BGP NLRI\u2026<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16,8],"tags":[],"class_list":["post-4813","post","type-post","status-publish","format-standard","hentry","category-cisco","category-networking"],"_links":{"self":[{"href":"https:\/\/gregsowell.com\/index.php?rest_route=\/wp\/v2\/posts\/4813","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gregsowell.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gregsowell.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gregsowell.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/gregsowell.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4813"}],"version-history":[{"count":1,"href":"https:\/\/gregsowell.com\/index.php?rest_route=\/wp\/v2\/posts\/4813\/revisions"}],"predecessor-version":[{"id":4814,"href":"https:\/\/gregsowell.com\/index.php?rest_route=\/wp\/v2\/posts\/4813\/revisions\/4814"}],"wp:attachment":[{"href":"https:\/\/gregsowell.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4813"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gregsowell.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4813"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gregsowell.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4813"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}