{"id":578,"date":"2017-07-01T17:24:00","date_gmt":"2017-07-01T17:24:00","guid":{"rendered":"https:\/\/jay-miah.co.uk\/?p=578"},"modified":"2024-11-17T17:27:55","modified_gmt":"2024-11-17T17:27:55","slug":"loop-guard-concept-and-implementation","status":"publish","type":"post","link":"https:\/\/jay-miah.co.uk\/index.php\/loop-guard-concept-and-implementation\/","title":{"rendered":"Loop Guard Concept and Implementation"},"content":{"rendered":"<p>Loop Guard and UDLD (Uni-directional Link Detection) are two ways to protect networks against loops. Loop guard is a spanning-tree optimisation protocol and can work with both Fibre and UTP cables while UDLD only works with fibre and is a layer 1\/2 protocol (unrelated to spanning-tree) that protects the upper layer protocols from causing loops.<\/p>\n<p>Loop Guard is generally used to protect against a mal-functioned switch. For example, in a normal STP state \u2013 the Root would send BPDU\u2019s into the network every two seconds to discover loops. If a loop is discovered the switch with the highest\u00a0\u201cBridge-ID\u201d\u00a0would block one if its links to prevent the loop, however it will continue to send and receive for BPDUs on that port.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"914\" height=\"521\" class=\"wp-image-579\" src=\"https:\/\/jay-miah.co.uk\/wp-content\/uploads\/2024\/11\/word-image-578-1.png\" \/> If for any reason BPDU\u2019s stop coming in on that blocked port from the neighbour device the switch will assume there is no longer a switch attached to that port and transitions the port into a forwarding (Designated) state. This has now caused a loop on the network.<\/p>\n<p>In reality the switch is still connected on the port and it is due to an issue with the switch itself that it has stopped sending BPDU\u2019s. If a switch malfunctions or the IOS crashes, the switch can continue to forward traffic but it can stop sending and receiving BPDU\u2019s.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"914\" height=\"521\" class=\"wp-image-580\" src=\"https:\/\/jay-miah.co.uk\/wp-content\/uploads\/2024\/11\/word-image-578-2.png\" \/><\/p>\n<p><strong>How can we protect against this?<\/strong><\/p>\n<p>We can use Loop Guard to protect the blocked port from transitioning into a forwarding state should the port stop receiving BPDU\u2019s from its neighbour switch.<\/p>\n<p>Loop Guard says, if I stop receiving BPDU\u2019s on my blocked port \u2013 this means something is wrong therefore I will keep it blocked by placing the port into an\u00a0\u201cLoop Inconsistent\u201d\u00a0mode. Once the issue is resolved I will transition the port back to blocking state automatically.<\/p>\n<p>Cisco recommends for the configuration to be applied on an interfaces by interfaces basis. Also a point to note would be that you cannot enable both loop guard and root guard at the same time.<\/p>\n<p><strong>Configuration Example<\/strong><\/p>\n<p>In the example below we will emulate a malfunction with a switch using\u00a0\u201cBPDU filter\u201d\u00a0and see how the blocked port behaves as it stops receiving BPDUs. We will then configure Loop Guard on an interface basis and again observe the behaviour to ensure it places the blocked into an\u00a0\u201cLoop Consistence\u201d\u00a0state.<\/p>\n<p>The topology has been setup using GNS 3<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"647\" height=\"377\" class=\"wp-image-581\" src=\"https:\/\/jay-miah.co.uk\/wp-content\/uploads\/2024\/11\/word-image-578-3.png\" \/><\/p>\n<p><strong>Step 1:<\/strong>\u00a0lets have a look at the spanning-tree topology and verify the state of each switch.<\/p>\n<p><strong>SW-1<\/strong><\/p>\n<p>#show spanning-tree<\/p>\n<p>We can see that\u00a0\u201cSW-1\u201d\u00a0is running RSTP and it is the\u00a0\u201cRoot-Bridge\u201d\u00a0with the lowest\u00a0\u201cBridge-ID\u201d. All ports on the\u00a0\u201cRoot\u201d\u00a0are in a forwarding state.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"711\" height=\"432\" class=\"wp-image-582\" src=\"https:\/\/jay-miah.co.uk\/wp-content\/uploads\/2024\/11\/word-image-578-4.png\" \/><\/p>\n<p><strong>SW-2<\/strong><\/p>\n<p>#show spanning-tree<\/p>\n<p>\u201cSW-2\u201d\u00a0is running\u00a0\u201cRSTP\u201d\u00a0and it has identified\u00a0\u201cSW-1\u201d\u00a0as the\u00a0\u201cRoot-Bridge\u201d\u00a0E1\/0 is its\u00a0\u201cRoot Port\u201d\u00a0with the best path to the\u00a0\u201cRoot-Bridge\u201d<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"708\" height=\"445\" class=\"wp-image-583\" src=\"https:\/\/jay-miah.co.uk\/wp-content\/uploads\/2024\/11\/word-image-578-5.png\" \/><\/p>\n<p><strong>SW-3<\/strong><\/p>\n<p>#show spanning-tree<\/p>\n<p>\u201cSW-3\u201d\u00a0is also running\u00a0\u201cRSTP\u201d, it has identified\u00a0\u201cSW-1\u201d\u00a0as the\u00a0\u201cRoot-Bridge\u201d, E1\/1 has been elected as the\u00a0\u201cRoot Port\u201d\u00a0and the redundant link on\u00a0\u201cE2\/2\u201d\u00a0is being blocked.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"710\" height=\"439\" class=\"wp-image-584\" src=\"https:\/\/jay-miah.co.uk\/wp-content\/uploads\/2024\/11\/word-image-578-6.png\" \/><\/p>\n<p><strong>Step 2:<\/strong>\u00a0on\u00a0\u201cSW-3\u201d\u00a0lets enable debugging to have a look at the BPDU\u2019s that are coming in on the blocked port.<\/p>\n<p>#debug spanning-tree bpdu receive<\/p>\n<p>We can see that BPDU\u2019s are being received from\u00a0\u201cSW-1\u201d\u00a0on\u00a0\u201cE1\/1\u201d\u00a0and\u00a0\u201cSW-2\u201d\u00a0on\u00a0\u201cE2\/2\u201d\u00a0every 2 seconds. These are being sent by the\u00a0\u201cRoot-Bridge\u201d<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1038\" height=\"433\" class=\"wp-image-585\" src=\"https:\/\/jay-miah.co.uk\/wp-content\/uploads\/2024\/11\/word-image-578-7.png\" \/><\/p>\n<p><strong>Step 3:<\/strong>\u00a0Configure\u00a0\u201cBPDU Filter\u201d\u00a0on\u00a0\u201cSW-2\u201d\u00a0to emulate a malfunction with the device, as BPDU filter is enabled on interface\u00a0\u201cE2\/0\u201d\u00a0the interface will not receive or send BPDU frames, essentially not participating in STP<\/p>\n<p>#conf t<\/p>\n<p>#Int e2\/0<\/p>\n<p>#spanning-tree bpdu filter enable<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"710\" height=\"68\" class=\"wp-image-586\" src=\"https:\/\/jay-miah.co.uk\/wp-content\/uploads\/2024\/11\/word-image-578-8.png\" \/><\/p>\n<p><strong>Step 4:<\/strong>\u00a0lets verify on\u00a0\u201cSW-3\u201d\u00a0that it can no longer see BPDU\u2019s on Interface\u00a0\u201cE2\/2\u201d\u00a0by looking at the debug messages.<\/p>\n<p>We can only see BPDU\u2019s coming in from\u00a0\u201cSW-1\u201d\u00a0on int\u00a0\u201cE1\/1\u201d\u00a0this is indicating that\u00a0\u201cSW-2\u201d\u00a0has a problem.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1039\" height=\"421\" class=\"wp-image-587\" src=\"https:\/\/jay-miah.co.uk\/wp-content\/uploads\/2024\/11\/word-image-578-9.png\" \/><\/p>\n<p><strong>Step 5:<\/strong>\u00a0On\u00a0\u201cSW-3\u201d\u00a0Lets take a look at the state of interface\u00a0\u201cE2\/2\u201d\u00a0which was previously blocking.<\/p>\n<p>#show spanning-tree<\/p>\n<p>As suspected interface\u00a0\u201cE2\/2\u201d\u00a0should now be forwarding, STP assumes that there is no longer a switch plugged into this port so it transitions it to a forwarding state. This has now caused a loop.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"709\" height=\"444\" class=\"wp-image-588\" src=\"https:\/\/jay-miah.co.uk\/wp-content\/uploads\/2024\/11\/word-image-578-10.png\" \/><\/p>\n<p><strong>Step 6:<\/strong>\u00a0Remove the BPDU filter configuration from interface\u00a0\u201cE2\/0\u201d\u00a0on\u00a0\u201cSW-2\u201d\u00a0so that the port is blocked by spanning-tree again<\/p>\n<p>#no spanning-tree bpdufilter enable<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"843\" height=\"31\" class=\"wp-image-589\" src=\"https:\/\/jay-miah.co.uk\/wp-content\/uploads\/2024\/11\/word-image-578-11.png\" \/><\/p>\n<p><strong>Step 7:<\/strong>\u00a0lets configure\u00a0\u201cLoop Guard\u201d\u00a0on\u00a0\u201cSW-3\u201d\u00a0and protect against the failure<\/p>\n<p>#conf t<\/p>\n<p>#int e2\/2<\/p>\n<p>#spanning-tree guard loop<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"711\" height=\"69\" class=\"wp-image-590\" src=\"https:\/\/jay-miah.co.uk\/wp-content\/uploads\/2024\/11\/word-image-578-12.png\" \/><\/p>\n<p><strong>Step 8:<\/strong>\u00a0re-enable BPDU Filter on interface\u00a0\u201cE2\/0\u201d\u00a0on\u00a0\u201cSW-2\u201d\u00a0to replicate a switch malfunction once again.<\/p>\n<p>#spanning-tree bpdufilter enable<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"710\" height=\"68\" class=\"wp-image-591\" src=\"https:\/\/jay-miah.co.uk\/wp-content\/uploads\/2024\/11\/word-image-578-13.png\" \/><\/p>\n<p>On\u00a0\u201cSW-3\u201d\u00a0we can see that interface\u00a0\u201cE2\/2\u201d\u00a0has realised its not receiving any BPDU\u2019s on a port that was previously blocked by STP therefore it has placed the port into a loop in-consistence state to prevent a loop.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"903\" height=\"33\" class=\"wp-image-592\" src=\"https:\/\/jay-miah.co.uk\/wp-content\/uploads\/2024\/11\/word-image-578-14.png\" \/><\/p>\n<p>If we take a look at the spanning-tree topology, we can see the port has been placed into a\u00a0\u201cLoop In-consistence\u201d\u00a0state<\/p>\n<p>#show spanning-tree<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"709\" height=\"446\" class=\"wp-image-593\" src=\"https:\/\/jay-miah.co.uk\/wp-content\/uploads\/2024\/11\/word-image-578-15.png\" \/><\/p>\n<p><strong>Step 9:<\/strong>\u00a0lets now remove BPDU filter on int\u00a0\u201c2\/0\u201d\u00a0on\u00a0\u201cSW-2\u201d\u00a0to emulate the issue has been resolved with the malfunctioned switch<\/p>\n<p>#no spanning-tree bpdufilter enable<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"843\" height=\"31\" class=\"wp-image-594\" src=\"https:\/\/jay-miah.co.uk\/wp-content\/uploads\/2024\/11\/word-image-578-16.png\" \/><\/p>\n<p>We can see on\u00a0\u201cSW-3\u201d\u00a0that Loop Guard has started receiving BPDU\u2019s on int\u00a0\u201cE2\/2\u201d\u00a0and has now restored the port back to a STP blocking state.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"876\" height=\"32\" class=\"wp-image-595\" src=\"https:\/\/jay-miah.co.uk\/wp-content\/uploads\/2024\/11\/word-image-578-17.png\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"709\" height=\"443\" class=\"wp-image-596\" src=\"https:\/\/jay-miah.co.uk\/wp-content\/uploads\/2024\/11\/word-image-578-18.png\" \/><\/p>\n<p><strong>Global configuration<\/strong><\/p>\n<p>To configure Loop Guard globally enter the following:<\/p>\n<p>#conf t<\/p>\n<p>#spanning-tree loopguard default<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"709\" height=\"56\" class=\"wp-image-597\" src=\"https:\/\/jay-miah.co.uk\/wp-content\/uploads\/2024\/11\/word-image-578-19.png\" \/><\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Loop Guard and UDLD (Uni-directional Link Detection) are two ways to protect networks against loops. Loop guard is a spanning-tree optimisation protocol and can work<\/p>\n","protected":false},"author":1,"featured_media":598,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6,9],"tags":[14,66,65,23],"class_list":["post-578","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-security","category-switching","tag-bpdu","tag-loop-guard","tag-spanning-tree-2","tag-stp"],"_links":{"self":[{"href":"https:\/\/jay-miah.co.uk\/index.php\/wp-json\/wp\/v2\/posts\/578","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jay-miah.co.uk\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jay-miah.co.uk\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jay-miah.co.uk\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jay-miah.co.uk\/index.php\/wp-json\/wp\/v2\/comments?post=578"}],"version-history":[{"count":1,"href":"https:\/\/jay-miah.co.uk\/index.php\/wp-json\/wp\/v2\/posts\/578\/revisions"}],"predecessor-version":[{"id":599,"href":"https:\/\/jay-miah.co.uk\/index.php\/wp-json\/wp\/v2\/posts\/578\/revisions\/599"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/jay-miah.co.uk\/index.php\/wp-json\/wp\/v2\/media\/598"}],"wp:attachment":[{"href":"https:\/\/jay-miah.co.uk\/index.php\/wp-json\/wp\/v2\/media?parent=578"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jay-miah.co.uk\/index.php\/wp-json\/wp\/v2\/categories?post=578"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jay-miah.co.uk\/index.php\/wp-json\/wp\/v2\/tags?post=578"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}