<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Aman Singh on Medium]]></title>
        <description><![CDATA[Stories by Aman Singh on Medium]]></description>
        <link>https://medium.com/@aks001235?source=rss-1707423c5a20------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Qv5LVVXHtpNqC_Ldfn-_9w.jpeg</url>
            <title>Stories by Aman Singh on Medium</title>
            <link>https://medium.com/@aks001235?source=rss-1707423c5a20------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 22:58:15 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@aks001235/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[BGP Communities in Action: Controlling Route Propagation Without Prefix Filters]]></title>
            <link>https://medium.com/@aks001235/bgp-communities-in-action-controlling-route-propagation-without-prefix-filters-67ecd56c6295?source=rss-1707423c5a20------2</link>
            <guid isPermaLink="false">https://medium.com/p/67ecd56c6295</guid>
            <category><![CDATA[juniper]]></category>
            <category><![CDATA[bgp]]></category>
            <category><![CDATA[routing]]></category>
            <category><![CDATA[labs]]></category>
            <category><![CDATA[troubleshooting]]></category>
            <dc:creator><![CDATA[Aman Singh]]></dc:creator>
            <pubDate>Sat, 18 Jul 2026 11:54:04 GMT</pubDate>
            <atom:updated>2026-07-18T12:04:18.461Z</atom:updated>
            <content:encoded><![CDATA[<p>Communities are routing metadata that let customers communicate intent to providers without requiring new prefix filters every time a routing policy changes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/919/1*UN9d2BZLmF-JM8cN8ZW-Zg.png" /></figure><p>In this lab, using the Juniper vLabs multi-AS topology, AS64522 tags a single critical prefix with community 64522:100. AS64533 interprets that community and selectively advertises only that route to AS64544.</p><h3>Business Requirement</h3><p>AS64533 provides transit services for multiple customers. To simplify customer-specific routing policies, it offers a community-based service. Customers may attach community 64522:100 to any prefix that should be propagated toward AS64544. Prefixes without this community must remain within AS64533 and should not be advertised further. This allows customers to control route propagation without requesting configuration changes from the provider for every individual prefix.</p><h3>Customer Configuration (vMX2/vMX3)</h3><pre>set policy-options community PRIMARY members 64522:100<br> <br> set policy-options policy-statement EXPORT-EBGP term TAGGED from protocol ospf<br> set policy-options policy-statement EXPORT-EBGP term TAGGED from route-filter 10.100.100.1/32 exact<br> set policy-options policy-statement EXPORT-EBGP term TAGGED then community add PRIMARY<br> set policy-options policy-statement EXPORT-EBGP term TAGGED then accept<br> <br> set policy-options policy-statement EXPORT-EBGP term OTHER from protocol ospf<br> set policy-options policy-statement EXPORT-EBGP term OTHER from route-filter 10.100.100.0/24 orlonger<br> set policy-options policy-statement EXPORT-EBGP term OTHER then accept<br> <br> set protocols bgp group to-AS64533 export EXPORT-EBGP<br></pre><p>Verification on vMX4</p><pre>show route protocol bgp 10.100.100.1/32 detail<br> <br> …<br> Communities: 64522:100<br> Accepted<br> Localpref: 100</pre><h3>Provider Policy (vMX4)</h3><pre>set policy-options community PRIMARY members 64522:100<br> <br> set policy-options policy-statement EXPORT-TO-64544 term PRIMARY from protocol bgp<br> set policy-options policy-statement EXPORT-TO-64544 term PRIMARY from community PRIMARY<br> set policy-options policy-statement EXPORT-TO-64544 term PRIMARY then accept<br> <br> set policy-options policy-statement EXPORT-TO-64544 term REJECT then reject<br> <br> set protocols bgp group to-AS64544 export EXPORT-TO-64544</pre><h3>Conclusion</h3><p>Rather than hardcoding customer prefixes into export filters, the provider implements a single reusable policy. The customer simply tags routes that should be propagated. This pattern scales significantly better, reduces operational overhead, and mirrors how many providers offer community-based routing services.</p><p>📺 Prefer a video walkthrough? Watch the complete troubleshooting and solution on my YouTube channel — <a href="https://youtu.be/lojKAwhCVt4">https://youtu.be/lojKAwhCVt4</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=67ecd56c6295" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Network Troubleshooting series -Lab 3]]></title>
            <link>https://medium.com/@aks001235/network-troubleshooting-series-lab-3-a70aa96a7250?source=rss-1707423c5a20------2</link>
            <guid isPermaLink="false">https://medium.com/p/a70aa96a7250</guid>
            <category><![CDATA[labs]]></category>
            <category><![CDATA[bgp]]></category>
            <category><![CDATA[networking]]></category>
            <category><![CDATA[troubleshooting]]></category>
            <dc:creator><![CDATA[Aman Singh]]></dc:creator>
            <pubDate>Sat, 11 Jul 2026 16:12:43 GMT</pubDate>
            <atom:updated>2026-07-11T16:27:54.989Z</atom:updated>
            <content:encoded><![CDATA[<p>When you’re learning BGP, reading about attributes like <strong>Local Preference</strong>, <strong>MED</strong>, and <strong>AS Path</strong> is one thing. Troubleshooting a broken network where multiple issues exist simultaneously is a completely different experience.</p><p>In this lab, I intentionally built a misconfigured dual-homed customer topology and fixed it step by step until the network behaved exactly as intended.</p><p>Rather than solving a single problem, this exercise demonstrates how multiple BGP attributes interact and how one incorrect policy can hide another.</p><h3>Topology</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*T1rzD8csRSv06SNf0l1kuw.png" /></figure><p>The customer (AS65001) is connected to two upstream providers.</p><p>The desired behavior is straightforward:</p><ul><li><strong>ISP-A (R2)</strong> should carry all normal traffic.</li><li><strong>ISP-B (R3)</strong> should remain as backup.</li></ul><h3>Initial Symptoms</h3><p>Every BGP session was established.</p><p>Every prefix was reachable.</p><p>No packets were dropped.</p><p>Yet every traceroute preferred <strong>ISP-B</strong>.</p><p>From R1:</p><pre>traceroute -s 10.1.1.1 10.4.0.1<br>1 10.13.0.2<br>2 10.4.0.1</pre><pre>traceroute -s 10.1.2.1 10.4.0.1<br>1 10.13.0.2<br>2 10.4.0.1</pre><p>From R4:</p><pre>traceroute -s 10.4.0.1 10.1.1.1<br>1 10.34.0.1<br>2 10.1.1.1</pre><p>Traffic in <strong>both directions</strong> was using ISP-B.</p><p>Clearly, something was wrong with the routing policy.</p><h3>Problem 1: Wrong Local Preference</h3><p>The first thing to verify is which route R1 selected for the destination network.</p><pre>r1# show ip route 10.4.0.0<br>Routing entry for 10.4.0.0/24<br>Known via &quot;bgp&quot;<br>* 10.13.0.2 via eth2</pre><p>The route pointed towards ISP-B.</p><p>Looking at the BGP configuration revealed why.</p><pre>neighbor 10.12.0.2 route-map TO-ISP-A-OUT out<br>neighbor 10.13.0.2 route-map SET-LP-HIGH in<br>neighbor 10.13.0.2 route-map TO-ISP-B-OUT out</pre><p>The Local Preference policy was applied inbound on ISP-B instead of ISP-A.</p><pre>route-map SET-LP-HIGH permit 10<br> set local-preference 200</pre><p>Since Local Preference is evaluated inside the local AS, R1 naturally preferred the ISP-B route.</p><p>After moving the policy to neighbor 10.12.0.2, the route changed immediately.</p><pre>r1# show ip route 10.4.0.0<br>* 10.12.0.2 via eth1</pre><p>The BGP table also confirmed why the path won.</p><pre>r1# show ip bgp 10.4.0.0/24<br>65002 65004<br>  localpref 200<br>  best (Local Pref)</pre><p>Traceroute now followed ISP-A.</p><pre>traceroute -s 10.1.1.1 10.4.0.1<br>1 10.12.0.2<br>2 10.4.0.1</pre><p>Outbound traffic was fixed.</p><p>Inbound traffic was not.</p><h3>Problem 2: MED Didn’t Work</h3><p>Traffic from R4 still preferred ISP-B.</p><p>Looking at the route maps:</p><pre>route-map TO-ISP-A-OUT permit 20<br> match ip address prefix-list PFX-NET1<br> set metric 10<br>route-map TO-ISP-B-OUT permit 10<br> match ip address prefix-list PFX-NET1<br> set metric 100</pre><p>This looked perfectly correct.</p><p>Lower MED was advertised through ISP-A.</p><p>Higher MED through ISP-B.</p><p>So why was R4 ignoring it?</p><p>Because of one important BGP rule.</p><blockquote>By default, MED is compared only between routes learned from the same neighboring AS.</blockquote><p>R4 was receiving:</p><ul><li>AS65002</li><li>AS65003</li></ul><p>Since the neighboring AS numbers were different, MED wasn’t even considered.</p><p>Instead, the decision process continued to later tie-breakers.</p><p>I enabled:</p><pre>router bgp 65004<br> bgp always-compare-med</pre><p>However, another issue became obvious.</p><p>The MED attribute wasn’t even visible on R4.</p><pre>r4# show ip bgp 10.1.1.0/24<br>65002 65001<br>best (Older Path)</pre><p>Why?</p><p>Because MED is a non-transitive BGP attribute.</p><p>It is exchanged only between directly connected neighbors and is not propagated beyond the receiving AS.</p><p>Although bgp always-compare-med changes the comparison behavior, relying on MED across multiple independent provider ASes is often fragile and depends on how each provider handles the attribute.</p><p>For this lab, AS Path Prepending is a much better choice.</p><pre>r1(config)# route-map TO-ISP-B-OUT permit 10<br>r1(config-route-map)# set as-path prepend 65001 65001 65001<br>r1(config-route-map)# exit</pre><h3>Problem 3: AS Path Prepending Applied to the Wrong ISP</h3><p>The next issue appeared in the outbound policy.</p><pre>route-map TO-ISP-A-OUT permit 10<br>match ip address prefix-list PFX-NET2<br>set as-path prepend 65001 65001 65001</pre><p>This was backwards.</p><p>The longer AS path was being advertised through the <strong>primary ISP</strong>.</p><p>Instead, the prepending should occur on the <strong>backup ISP</strong>.</p><p>The fix was:</p><pre>r1# conf t<br>r1(config)# route-map TO-ISP-A-OUT permit 10<br>r1(config-route-map)# no set as-path prepend<br>r1(config-route-map)# exit<br>r1(config)# route-map TO-ISP-B-OUT permit 20<br>r1(config-route-map)# match ip address prefix-list PFX-NET2<br>r1(config-route-map)# set as-path prepend 65001 65001 65001<br>r1(config-route-map)# exit<br>r1(config)#</pre><p>Now ISP-B advertised a longer AS path, making ISP-A more attractive.</p><p>Everything should have worked.</p><p>Except it still didn’t.</p><h3>Problem 4 : R4 Became a Transit AS</h3><p>Checking R3 revealed something unexpected.</p><pre>r3# show ip bgp 10.1.2.0/24<br>65004 65002 65001</pre><p>Instead of learning the prefix directly from R1, R3 had learned it back from R4.</p><p>R4 had unintentionally become a transit AS.</p><p>That meant R3 preferred the shorter path through R4 instead of the prepended path received directly from R1.</p><p>To prevent this, R4 should never advertise customer prefixes back toward either ISP.</p><p>A simple prefix-list based filter solved the issue.</p><pre>ip prefix-list R1-PREFIXES seq 5 permit 10.1.1.0/24<br>ip prefix-list R1-PREFIXES seq 10 permit 10.1.2.0/24<br><br>route-map TO-R2 deny 10<br> match ip address prefix-list R1-PREFIXES<br>route-map TO-R2 permit 20<br>route-map TO-R3 deny 10<br> match ip address prefix-list R1-PREFIXES<br>route-map TO-R3 permit 20<br>router bgp 65004<br> address-family ipv4 unicast<br>  neighbor 10.24.0.1 route-map TO-R2 out<br>  neighbor 10.34.0.1 route-map TO-R3 out</pre><p>In production, an AS Path-based policy would scale much better than maintaining growing prefix-lists, but for this lab, the prefix-list keeps the behaviour easy to understand.</p><p>After applying the filters, R4 learned both paths correctly without advertising them back.</p><pre>r4# show ip bgp 10.1.2.0/24<br>65003 65001 65001 65001 65001<br>65002 65001<br>best (AS Path)</pre><p>Exactly what we wanted.</p><h3>Final Verification</h3><p>Traceroute from R4:</p><pre>traceroute -s 10.4.0.1 10.1.1.1<br>1 10.24.0.1<br>2 10.1.1.1</pre><p>Traceroute from R1:</p><pre>traceroute -s 10.1.2.1 10.4.0.1<br>1 10.12.0.2<br>2 10.4.0.1</pre><pre>traceroute -s 10.1.1.1 10.4.0.1<br>1 10.12.0.2<br>2 10.4.0.1</pre><p>Everything now follows ISP-A exactly as intended.</p><h3>Key Takeaways</h3><p>This lab reinforced several important BGP concepts:</p><ul><li>Higher Local Preference wins for outbound traffic inside your own AS.</li><li>Lower MED is preferred, but only when the receiving router actually compares it.</li><li>Shorter AS Path is generally preferred, making AS Path Prepending a practical inbound traffic engineering tool.</li><li>Preventing an AS from becoming an unintended transit is just as important as manipulating path attributes</li></ul><p>📺 Prefer a video walkthrough? Watch the complete troubleshooting and solution on my YouTube channel — <a href="https://youtu.be/gveF4IrWsco">https://youtu.be/gveF4IrWsco</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a70aa96a7250" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Network Troubleshooting series — Lab 2]]></title>
            <link>https://medium.com/@aks001235/network-troubleshooting-series-lab-2-8517999ba3a6?source=rss-1707423c5a20------2</link>
            <guid isPermaLink="false">https://medium.com/p/8517999ba3a6</guid>
            <category><![CDATA[troubleshooting]]></category>
            <category><![CDATA[bgp]]></category>
            <category><![CDATA[labs]]></category>
            <category><![CDATA[computer-networking]]></category>
            <dc:creator><![CDATA[Aman Singh]]></dc:creator>
            <pubDate>Sat, 04 Jul 2026 16:01:14 GMT</pubDate>
            <atom:updated>2026-07-04T16:15:27.568Z</atom:updated>
            <content:encoded><![CDATA[<h3>Problem Statement</h3><p>A customer in AS65001 (R1) has two advertised networks:</p><ul><li>10.1.1.0/24 — Primary site</li><li>10.1.3.0/24 — Secondary/Disaster Recovery site</li></ul><p>These networks must communicate with a partner network in AS65003 (R5), which advertises 10.5.5.0/24. All traffic between the two autonomous systems transits AS65002 through the path:</p><p>R1 → R2 → R3 → R4 → R5</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*98RqahJuQMWO_6ZfREiZdw.png" /></figure><p>The first indication that something was wrong was that R1 couldn’t reach R5.</p><pre>bash-5.1# ping -I 10.1.1.1 10.5.5.5<br>PING 10.5.5.5 (10.5.5.5) from 10.1.1.1: 56 data bytes<br>^C<br>--- 10.5.5.5 ping statistics ---<br>12 packets transmitted, 0 packets received, 100% packet loss</pre><p>The obvious place to start was verifying the BGP sessions.</p><p>On R1:</p><pre>r1# show bgp summary<br>IPv4 Unicast Summary (VRF default):<br>BGP router identifier 1.1.1.1, local AS number 65001 vrf-id 0<br>...<br>Neighbor        V         AS   MsgRcvd   MsgSent ... State/PfxRcd<br>10.12.0.2       4      65002        15        17 ...            0</pre><p>R1 is definitely advertising routes.</p><pre>r1# show bgp ipv4 unicast neighbors 10.12.0.2 advertised-routes<br>BGP table version is 2, local router ID is 1.1.1.1, vrf id 0<br>Default local pref 100, local AS 65001<br>Status codes:  s suppressed, d damped, h history, * valid, &gt; best, = multipath,<br>               i internal, r RIB-failure, S Stale, R Removed<br>Nexthop codes: @NNN nexthop&#39;s vrf id, &lt; announce-nh-self<br>Origin codes:  i - IGP, e - EGP, ? - incomplete<br>RPKI validation codes: V valid, I invalid, N Not found<br><br>   Network          Next Hop            Metric LocPrf Weight Path<br>*&gt; 10.1.1.0/24      0.0.0.0                  0         32768 i<br>*&gt; 10.1.3.0/24      0.0.0.0                  0         32768 i<br><br>Total number of prefixes 2</pre><p>So the problem wasn’t on R1.</p><h3>Step 1 : Investigating R2</h3><p>Checking the BGP summary on R2 showed something unexpected.</p><pre>r2# show ip bgp summary<br><br>IPv4 Unicast Summary (VRF default):<br>BGP router identifier 2.2.2.2, local AS number 65002 vrf-id 0<br>BGP table version 1<br>RIB entries 1, using 192 bytes of memory<br>Peers 2, using 1434 KiB of memory<br><br>Neighbor        V         AS   MsgRcvd   MsgSent   TblVer  InQ OutQ  Up/Down State/PfxRcd   PfxSnt Desc<br>10.12.0.1       4      65001        19        19        0    0    0 00:15:04            1        1 N/A<br>10.23.0.2       4      65002        18        19        0    0    0 00:15:03            0        1 N/A<br><br>Total number of neighbors 2</pre><p>R2 had received <strong>only one route</strong> from R1.</p><p>Looking at the configuration quickly explained why.</p><pre>router bgp 65002<br> address-family ipv4 unicast<br>  neighbor 10.12.0.1 prefix-list R1-IN in</pre><p>The prefix-list was:</p><pre>ip prefix-list R1-IN seq 5 permit 10.1.1.0/24</pre><p>Only <strong>10.1.1.0/24</strong> was allowed.</p><p>R1 was advertising another network:</p><pre>10.1.3.0/24</pre><p>which the prefix-list silently dropped.</p><p>The BGP table confirmed this.</p><pre>r2# show bgp ipv4 unicast<br>BGP table version is 3, local router ID is 2.2.2.2, vrf id 0<br>Default local pref 100, local AS 65002<br>Status codes:  s suppressed, d damped, h history, * valid, &gt; best, = multipath,<br>               i internal, r RIB-failure, S Stale, R Removed<br>Nexthop codes: @NNN nexthop&#39;s vrf id, &lt; announce-nh-self<br>Origin codes:  i - IGP, e - EGP, ? - incomplete<br>RPKI validation codes: V valid, I invalid, N Not found<br><br>   Network          Next Hop            Metric LocPrf Weight Path<br>*&gt; 10.1.1.0/24      10.12.0.1                0             0 65001 i<br><br>Displayed  1 routes and 1 total pathsOnly one prefix existed.</pre><h3>Fixing the Prefix List</h3><p>Instead of permitting individual subnets, I expanded the prefix list.</p><pre>r2(config)# ip prefix-list R1-IN seq 5 permit 10.1.0.0/16 le 32</pre><p>The important part here is:</p><pre>le 32</pre><p>It allows every subnet within 10.1.0.0/16.</p><p>After the change:</p><pre>r2# show ip bgp summary<br><br>IPv4 Unicast Summary (VRF default):<br>BGP router identifier 2.2.2.2, local AS number 65002 vrf-id 0<br>BGP table version 6<br>RIB entries 3, using 576 bytes of memory<br>Peers 2, using 1434 KiB of memory<br><br>Neighbor        V         AS   MsgRcvd   MsgSent   TblVer  InQ OutQ  Up/Down State/PfxRcd   PfxSnt Desc<br>10.12.0.1       4      65001        50        51        0    0    0 00:03:32            2        2 N/A<br>10.23.0.2       4      65002        41        48        0    0    0 00:03:33            0        2 N/A</pre><p>and</p><pre>r2# show bgp ipv4 unicast<br>BGP table version is 6, local router ID is 2.2.2.2, vrf id 0<br>Default local pref 100, local AS 65002<br>Status codes:  s suppressed, d damped, h history, * valid, &gt; best, = multipath,<br>               i internal, r RIB-failure, S Stale, R Removed<br>Nexthop codes: @NNN nexthop&#39;s vrf id, &lt; announce-nh-self<br>Origin codes:  i - IGP, e - EGP, ? - incomplete<br>RPKI validation codes: V valid, I invalid, N Not found<br><br>   Network          Next Hop            Metric LocPrf Weight Path<br>*&gt; 10.1.1.0/24      10.12.0.1                0             0 65001 i<br>*&gt; 10.1.3.0/24      10.12.0.1                0             0 65001 i<br><br>Displayed  2 routes and 2 total paths</pre><p>The problem is resolved.</p><h3>Step 2: Why Isn’t R3 Advertising to R4?</h3><p>Moving further into the topology, I checked R3.</p><pre>r3# show ip bgp summary<br><br>IPv4 Unicast Summary (VRF default):<br>BGP router identifier 3.3.3.3, local AS number 65002 vrf-id 0<br>BGP table version 7<br>RIB entries 5, using 960 bytes of memory<br>Peers 2, using 1434 KiB of memory<br><br>Neighbor        V         AS   MsgRcvd   MsgSent   TblVer  InQ OutQ  Up/Down State/PfxRcd   PfxSnt Desc<br>10.23.0.1       4      65002        50        43        0    0    0 00:04:36            2        0 N/A<br>10.34.0.2       4      65002        30        29        0    0    0 00:26:10            1        0 N/A<br><br>Total number of neighbors 2</pre><p>R3 was receiving routes from R2.</p><p>However, it wasn’t advertising them onward.</p><p>This is expected BGP behaviour.</p><p>Routes learned from one iBGP peer are not advertised to another iBGP peer due to the iBGP split-horizon rule.</p><p>The traditional solution is a Route Reflector.</p><h3>Step 3: Configuring a Route Reflector</h3><p>I configured R3 as a Route Reflector.</p><pre>r3(config-router-af)# neighbor 10.23.0.1 route-reflector-client<br>r3(config-router-af)# neighbor 10.34.0.2 route-reflector-client</pre><p>Immediately afterwards:</p><pre>r3# show ip bgp summary<br><br>IPv4 Unicast Summary (VRF default):<br>BGP router identifier 3.3.3.3, local AS number 65002 vrf-id 0<br>BGP table version 13<br>RIB entries 5, using 960 bytes of memory<br>Peers 2, using 1434 KiB of memory<br><br>Neighbor        V         AS   MsgRcvd   MsgSent   TblVer  InQ OutQ  Up/Down State/PfxRcd   PfxSnt Desc<br>10.23.0.1       4      65002        60        57        0    0    0 00:00:20            2        3 N/A<br>10.34.0.2       4      65002        40        42        0    0    0 00:00:13            1        3 N/A</pre><p>But when checking on R4 I can see that the routes are not getting advertised further to R5</p><pre>r4# show ip bgp summary<br><br>IPv4 Unicast Summary (VRF default):<br>BGP router identifier 4.4.4.4, local AS number 65002 vrf-id 0<br>BGP table version 1<br>RIB entries 5, using 960 bytes of memory<br>Peers 2, using 1434 KiB of memory<br><br>Neighbor        V         AS   MsgRcvd   MsgSent   TblVer  InQ OutQ  Up/Down State/PfxRcd   PfxSnt Desc<br>10.34.0.1       4      65002        49        47        0    0    0 00:06:26            2        1 N/A<br>10.45.0.2       4      65003        42        43        0    0    0 00:38:54            1        1 N/A<br><br>Total number of neighbors 2</pre><p>On checking the exact route:</p><pre>r4# show bgp ipv4 unicast 10.1.1.0/24<br>BGP routing table entry for 10.1.1.0/24, version 0<br>Paths: (1 available, no best path)<br>  Not advertised to any peer<br>  65001<br>    10.23.0.1 (inaccessible) from 10.34.0.1 (2.2.2.2)<br>      Origin IGP, metric 0, localpref 100, invalid, internal<br>      Originator: 2.2.2.2, Cluster list: 3.3.3.3<br>      Last update: Fri Jul  3 16:08:14 2026</pre><p>This route is invalid because the next hop is set to 10.23.0.1, which is not accessible. Ideally the next hop should be to R3.</p><h3>Step 4: Next-Hop Processing on FRR</h3><p>After reading through the FRRouting documentation, I found that Route Reflectors require an additional configuration when reflecting routes learned from iBGP peers.</p><p>ref — <a href="https://docs.frrouting.org/en/latest/bgp.html#clicmd-neighbor-PEER-next-hop-self-force">https://docs.frrouting.org/en/latest/bgp.html#clicmd-neighbor-PEER-next-hop-self-force</a></p><p>Specifically:</p><pre>neighbor X next-hop-self force</pre><p>Unlike standard next-hop-self, the force Keyword also rewrites the next hop for routes learned via iBGP.</p><p>I configured:</p><pre>r3(config-router-af)# neighbor 10.23.0.1 next-hop-self force<br>r3(config-router-af)# neighbor 10.34.0.2 next-hop-self force</pre><p>Once this was applied, R4 finally advertised the correct routes.</p><pre>r4# show bgp ipv4 unicast neighbors 10.45.0.2 advertised-routes<br>BGP table version is 3, local router ID is 4.4.4.4, vrf id 0<br>Default local pref 100, local AS 65002<br>Status codes:  s suppressed, d damped, h history, * valid, &gt; best, = multipath,<br>               i internal, r RIB-failure, S Stale, R Removed<br>Nexthop codes: @NNN nexthop&#39;s vrf id, &lt; announce-nh-self<br>Origin codes:  i - IGP, e - EGP, ? - incomplete<br>RPKI validation codes: V valid, I invalid, N Not found<br><br>   Network          Next Hop            Metric LocPrf Weight Path<br>*&gt; 10.1.1.0/24      0.0.0.0                       100      0 65001 i<br>*&gt; 10.1.3.0/24      0.0.0.0                       100      0 65001 i<br>*&gt; 10.5.5.0/24      0.0.0.0                                0 65003 i</pre><p>Exactly what I expected.</p><h3>Final Verification</h3><p>Time for the ultimate test.</p><pre>bash-5.1# ping -I 10.5.5.5 10.1.1.1<br>PING 10.1.1.1 (10.1.1.1) from 10.5.5.5: 56 data bytes<br>64 bytes from 10.1.1.1: seq=0 ttl=61 time=2.818 ms<br>64 bytes from 10.1.1.1: seq=1 ttl=61 time=0.153 ms<br>^C<br>--- 10.1.1.1 ping statistics ---<br>2 packets transmitted, 2 packets received, 0% packet loss<br>round-trip min/avg/max = 0.153/1.485/2.818 ms</pre><p>Success.</p><h3>Key Takeaways</h3><p>This lab reinforced several important BGP concepts:</p><ul><li>A BGP session being <strong>established</strong> doesn’t mean routes are being accepted.</li><li>Prefix-lists can silently filter valid routes.</li><li>iBGP follows the split-horizon rule, so routers won’t advertise routes learned from one iBGP peer to another.</li><li>Route Reflectors eliminate the need for a full iBGP mesh.</li><li>When using Route Reflectors in FRRouting, next-hop-self force may be required to produce a valid next hop for reflected iBGP routes.</li></ul><p>📺 Prefer a video walkthrough? Watch the complete troubleshooting and solution on my YouTube channel — <a href="https://youtu.be/IbmSzawbNt0">https://youtu.be/IbmSzawbNt0</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8517999ba3a6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Network Troubleshooting series — Lab 1]]></title>
            <link>https://medium.com/@aks001235/network-troubleshooting-series-lab-1-26fec0bc762c?source=rss-1707423c5a20------2</link>
            <guid isPermaLink="false">https://medium.com/p/26fec0bc762c</guid>
            <category><![CDATA[bgp]]></category>
            <category><![CDATA[networking]]></category>
            <category><![CDATA[labs]]></category>
            <dc:creator><![CDATA[Aman Singh]]></dc:creator>
            <pubDate>Sun, 28 Jun 2026 09:29:13 GMT</pubDate>
            <atom:updated>2026-06-28T09:31:19.410Z</atom:updated>
            <content:encoded><![CDATA[<p>Here is the problem statement:</p><p><strong>## Topology</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Zc_yJb-CHFwPha78QMaGjA.png" /></figure><p><strong>## Problem Statement</strong></p><p>A customer connected to <strong>**AS65001 (R1)**</strong> has opened a ticket against the transit provider <strong>**AS65002 (R2/R3)**</strong> stating that they cannot reach a partner network hosted in <strong>**AS65003 (R4)**</strong>, and vice versa.<br> <br>Let’s start working on it:</p><p>From R1, I tried reaching the loopback on R4.</p><p>Cannot ping 1 end to other :</p><pre><br> aman@Amankumar-Singh:~/lab_1$ docker exec -it clab-bgp-ttshoot-r1 ping -I 10.1.1.1 10.4.4.4<br> PING 10.4.4.4 (10.4.4.4) from 10.1.1.1: 56 data bytes<br> ^C<br> — — 10.4.4.4 ping statistics — -<br> 3 packets transmitted, 0 packets received, 100% packet loss<br> aman@Amankumar-Singh:~/lab_1$ docker exec -it clab-bgp-ttshoot-r4 ping -I 10.4.4.4 10.1.1.1<br> PING 10.1.1.1 (10.1.1.1) from 10.4.4.4: 56 data bytes<br> ^C<br> — — 10.1.1.1 ping statistics — -<br> 3 packets transmitted, 0 packets received, 100% packet loss<br> aman@Amankumar-Singh:~/lab_1$</pre><p>My first instinct: <br>Did BGP even come up?</p><p>config on R2, simple config:</p><pre><br> r2# show running-config<br> Building configuration…<br> <br> Current configuration:<br> !<br> frr version 8.4_git<br> frr defaults traditional<br> hostname r2<br> domainname localdomain<br> log file /var/log/frr/frr.log informational<br> no ipv6 forwarding<br> !<br> interface eth1<br> ip address 10.12.0.2/30<br> exit<br> !<br> interface eth2<br> ip address 10.23.0.1/30<br> exit<br> !<br> interface lo<br> ip address 2.2.2.2/32<br> exit<br> !<br> router bgp 65002<br> bgp router-id 2.2.2.2<br> no bgp ebgp-requires-policy<br> neighbor 10.12.0.1 remote-as 65001<br> neighbor 10.23.0.2 remote-as 65002<br> exit<br> !<br> end<br> r2#</pre><pre> <br> r2# show ip bgp summary<br> <br> IPv4 Unicast Summary (VRF default):<br> BGP router identifier 2.2.2.2, local AS number 65002 vrf-id 0<br> BGP table version 3<br> RIB entries 3, using 576 bytes of memory<br> Peers 2, using 1434 KiB of memory<br> <br> Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd PfxSnt Desc<br> 10.12.0.1 4 65001 27 27 0 0 0 00:21:35 1 1 N/A<br> 10.23.0.2 4 65002 26 26 0 0 0 00:21:35 1 1 N/A<br> <br> Total number of neighbors 2<br> <br> r3# show ip bgp summary<br> <br> IPv4 Unicast Summary (VRF default):<br> BGP router identifier 3.3.3.3, local AS number 65002 vrf-id 0<br> BGP table version 3<br> RIB entries 3, using 576 bytes of memory<br> Peers 2, using 1434 KiB of memory<br> <br> Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd PfxSnt Desc<br> 10.23.0.1 4 65002 27 27 0 0 0 00:22:00 1 1 N/A<br> 10.34.0.2 4 65003 28 28 0 0 0 00:22:00 1 1 N/A<br> <br> Total number of neighbors 2</pre><p>The configuration looked fine and every BGP session was Established. That ruled out neighbor establishment issues, authentication problems, interface mismatches, and AS-number mistakes.</p><p>So if the control plane was healthy, why wasn’t the data plane working?<br> <br>I stopped looking at the neighbors and started looking at the routes themselves.</p><pre> <br> r3# show bgp ipv4 unicast<br> BGP table version is 3, local router ID is 3.3.3.3, vrf id 0<br> Default local pref 100, local AS 65002<br> Status codes: s suppressed, d damped, h history, * valid, &gt; best, = multipath,<br> i internal, r RIB-failure, S Stale, R Removed<br> Nexthop codes: @NNN nexthop’s vrf id, &lt; announce-nh-self<br> Origin codes: i — IGP, e — EGP, ? — incomplete<br> RPKI validation codes: V valid, I invalid, N Not found<br> <br> Network Next Hop Metric LocPrf Weight Path<br> i10.1.1.0/24 10.12.0.1 0 100 0 65001 i<br> *&gt; 10.4.4.0/24 10.34.0.2 0 0 65003 i<br> <br> Displayed 2 routes and 2 total paths<br> r3#<br> <br> r2# show bgp ipv4 unicast<br> BGP table version is 3, local router ID is 2.2.2.2, vrf id 0<br> Default local pref 100, local AS 65002<br> Status codes: s suppressed, d damped, h history, * valid, &gt; best, = multipath,<br> i internal, r RIB-failure, S Stale, R Removed<br> Nexthop codes: @NNN nexthop’s vrf id, &lt; announce-nh-self<br> Origin codes: i — IGP, e — EGP, ? — incomplete<br> RPKI validation codes: V valid, I invalid, N Not found<br> <br> Network Next Hop Metric LocPrf Weight Path<br> *&gt; 10.1.1.0/24 10.12.0.1 0 0 65001 i<br> i10.4.4.0/24 10.34.0.2 0 100 0 65003 i<br> <br> Displayed 2 routes and 2 total paths</pre><p>That was the clue.<br> <br>Nothing was wrong with BGP.<br>Nothing was wrong with the prefixes.<br> <br>The problem was the NEXT_HOP attribute.<br> <br>By default, when a router advertises an eBGP-learned route to an iBGP peer, it preserves the original next hop. R2 forwarded 10.1.1.0/24 to R3 with a next hop of 10.12.0.1, while R3 forwarded 10.4.4.0/24 to R2 with a next hop of 10.34.0.2. Neither receiving router could reach those external links.<br> <br>This is exactly what next-hop-self is designed to solve.</p><pre> <br> r2(config)# router bgp 65002<br> exitr2(config-router)# address-family ipv4 unicast<br> r2(config-router-af)# neighbor 10.23.0.2 next-hop-self<br> r2(config-router-af)# exit-address-family<br> r2(config-router)# exit<br> <br> r3# conf t<br> r3(config)# router bgp 65002<br> exitr3(config-router)# address-family ipv4 unicast<br> r3(config-router-af)# neighbor 10.23.0.1 next-hop-self<br> r3(config-router-af)# exit-address-family<br> r3(config-router)# exit<br> r3(config)#<br> <br> r3# show bgp ipv4 unicast<br> BGP table version is 4, local router ID is 3.3.3.3, vrf id 0<br> Default local pref 100, local AS 65002<br> Status codes: s suppressed, d damped, h history, * valid, &gt; best, = multipath,<br> i internal, r RIB-failure, S Stale, R Removed<br> Nexthop codes: @NNN nexthop’s vrf id, &lt; announce-nh-self<br> Origin codes: i — IGP, e — EGP, ? — incomplete<br> RPKI validation codes: V valid, I invalid, N Not found<br> <br> Network Next Hop Metric LocPrf Weight Path<br> *&gt;i10.1.1.0/24 10.23.0.1 0 100 0 65001 i<br> *&gt; 10.4.4.0/24 10.34.0.2 0 0 65003 i<br> <br> Displayed 2 routes and 2 total paths<br> <br> r2# show bgp ipv4 unicast<br> BGP table version is 4, local router ID is 2.2.2.2, vrf id 0<br> Default local pref 100, local AS 65002<br> Status codes: s suppressed, d damped, h history, * valid, &gt; best, = multipath,<br> i internal, r RIB-failure, S Stale, R Removed<br> Nexthop codes: @NNN nexthop’s vrf id, &lt; announce-nh-self<br> Origin codes: i — IGP, e — EGP, ? — incomplete<br> RPKI validation codes: V valid, I invalid, N Not found<br> <br> Network Next Hop Metric LocPrf Weight Path<br> *&gt; 10.1.1.0/24 10.12.0.1 0 0 65001 i<br> *&gt;i10.4.4.0/24 10.23.0.2 0 100 0 65003 i<br> <br> Displayed 2 routes and 2 total paths</pre><p>After configuring next-hop-self, the NEXT_HOP changed from the external interface addresses to the directly reachable iBGP peer addresses. The routes immediately became valid.<br> <br>You might wonder why we configure next-hop-self only on iBGP peers. The reason is that eBGP already changes the next hop automatically when advertising routes to another AS. iBGP intentionally preserves the original next hop because larger networks usually rely on an IGP to provide reachability. In this lab, there is no IGP, so preserving the original next hop breaks forwarding.<br> <br>Another important question is why the route wasn’t advertised further. Before a BGP route can be installed into the routing table, its next hop must be reachable. If the next hop cannot be resolved, the route is considered unusable because forwarding packets would result in a black hole. Once next-hop-self makes the next hop reachable, the route is installed into the RIB and can be advertised to downstream peers.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=26fec0bc762c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Scaling an AI Network Assistant with Inventory and SQLite]]></title>
            <link>https://medium.com/@aks001235/scaling-an-ai-network-assistant-with-inventory-and-sqlite-8c555d9fc10a?source=rss-1707423c5a20------2</link>
            <guid isPermaLink="false">https://medium.com/p/8c555d9fc10a</guid>
            <category><![CDATA[networking]]></category>
            <category><![CDATA[cisco]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[mcp-server]]></category>
            <dc:creator><![CDATA[Aman Singh]]></dc:creator>
            <pubDate>Sun, 24 May 2026 06:40:52 GMT</pubDate>
            <atom:updated>2026-05-24T06:46:46.013Z</atom:updated>
            <content:encoded><![CDATA[<p>In my previous story — <a href="https://medium.com/@aks001235/building-an-mcp-based-ai-network-engineer-with-python-b93fdbcce810">https://medium.com/@aks001235/building-an-mcp-based-ai-network-engineer-with-python-b93fdbcce810</a> , I built a small MCP-based AI network assistant that could:</p><ul><li>understand networking questions in natural language</li><li>select the correct network tool</li><li>connect to a Cisco router</li><li>retrieve operational data</li><li>let an LLM analyze the results</li></ul><p>But the original implementation had a few limitations:</p><p>The first limitation is that it only worked against a single hardcoded router.</p><p>That approach worked for learning LLM orchestration, but it was not realistic for actual network environments where automation systems need to operate across multiple devices dynamically.</p><p>So I extended the project to support:</p><ul><li>inventory-driven device selection</li><li>dynamic router connectivity</li><li>AI-driven device-aware tool execution</li></ul><p>The result was a much more scalable architecture.</p><h3>The Problem with Hardcoded Devices</h3><p>Initially, my tools looked like this:</p><pre>router = {<br>    &quot;device_type&quot;: &quot;cisco_ios_telnet&quot;,<br>    &quot;host&quot;: &quot;192.168.223.131&quot;,<br>    &quot;port&quot;: 32770,<br>    &quot;username&quot;: &quot;admin&quot;,<br>    &quot;password&quot;: &quot;eve&quot;,<br>}</pre><p>Every tool execution always connected to the same device.</p><p>That meant:</p><ul><li>no network-wide flexibility</li><li>no multi-device support</li><li>no inventory abstraction</li><li>no dynamic execution logic</li></ul><p>The LLM could understand intent, but the infrastructure layer was still static.</p><h3>The Architectural Shift</h3><p>The major change was introducing an inventory layer.</p><p>Instead of embedding device details directly inside Python functions, device information was externalised into a datasource.</p><p>Example inventory:</p><pre>{<br>  &quot;R1&quot;: {<br>    &quot;host&quot;: &quot;192.168.223.131&quot;,<br>    &quot;port&quot;: 32769<br>  },<br>  &quot;R2&quot;: {<br>    &quot;host&quot;: &quot;192.168.223.131&quot;,<br>    &quot;port&quot;: 32774<br>  },<br>  &quot;R3&quot;: {<br>    &quot;host&quot;: &quot;192.168.223.131&quot;,<br>    &quot;port&quot;: 32774<br>  }<br>}</pre><p>This changed the architecture significantly.</p><p>Instead of:</p><p>User<br>↓<br>LLM<br>↓<br>Single Hardcoded Router</p><p>The workflow became:</p><p>User<br>↓<br>Groq LLM<br>↓<br>Tool Selection<br>↓<br>Device Selection<br>↓<br>Inventory Lookup<br>↓<br>FastMCP Tool<br>↓<br>Netmiko<br>↓<br>Target Router</p><p>The assistant could now dynamically choose which device to interact with.</p><h3>Building the Inventory Layer</h3><p>The inventory is loaded once during startup:</p><pre>with open(&quot;devices.json&quot;) as f:<br>    DEVICES = json.load(f)</pre><p>I then added a helper function to dynamically construct device connection parameters.</p><pre>def get_device(device_name):<br>  if device_name not in DEVICES:<br>        raise ValueError(<br>            f&quot;Device {device_name} not found&quot;<br>        )<br>    device = DEVICES[device_name]<br>    return {<br>        &quot;device_type&quot;: &quot;cisco_ios_telnet&quot;,<br>        &quot;host&quot;: device[&quot;host&quot;],<br>        &quot;port&quot;: device[&quot;port&quot;],<br>        &quot;username&quot;: &quot;admin&quot;,<br>        &quot;password&quot;: &quot;eve&quot;,<br>    }</pre><p>This removed all hardcoded device dependencies from the tool layer.</p><p>Now the same MCP tool could operate against any router present in the inventory.</p><h3>Extending FastMCP Tools</h3><p>Previously, tools had no awareness of device context.</p><p>Old version:</p><pre>@mcp.tool()<br>def show_bgp():</pre><p>New version:</p><pre>@mcp.tool()<br>def show_bgp(device_name: str):</pre><p>The tool now becomes parameterised and inventory-aware.</p><p>Example:</p><pre>@mcp.tool()<br>def show_bgp(device_name: str):<br>    router = get_device(device_name)<br>    conn = ConnectHandler(**router)<br>    output = conn.send_command(<br>        &quot;show ip bgp summary&quot;<br>    )<br>    conn.disconnect()<br>    return output</pre><p>This small architectural change dramatically improves scalability.</p><p>Instead of creating separate tools for every router, a single reusable tool can now operate across the entire inventory.</p><h3>Making the LLM Device-Aware</h3><p>The next challenge was allowing the LLM to determine not only:</p><ul><li>which tool to use</li></ul><p>but also:</p><ul><li>which device should be queried</li></ul><p>The system prompt was updated to force structured responses.</p><p>Example:</p><pre>SYSTEM_PROMPT = &quot;&quot;&quot;<br>Return EXACTLY in this format:<br>TOOL:&lt;tool_name&gt;:&lt;device_name&gt;<br>Examples:<br>TOOL:show_bgp:R1<br>TOOL:show_interfaces:R2<br>&quot;&quot;&quot;<br></pre><p>Now the LLM performs two reasoning tasks simultaneously:</p><ol><li>Intent selection</li><li>Device extraction</li></ol><p>Example interaction:</p><p>User:</p><pre>show bgp summary on R1</pre><p>LLM response:</p><pre>TOOL:show_bgp:R1</pre><p>The response is then parsed programmatically:</p><pre>parts = llm_decision.strip().split(&quot;:&quot;)<br>tool_name = parts[1]<br>device_name = parts[2]</pre><p>This effectively converts natural language into executable infrastructure actions.</p><h3>End-to-End Execution Flow</h3><p>The complete flow now looks like this:</p><p>User Question<br>↓<br>Groq LLM<br>↓<br>Tool + Device Decision<br>↓<br>Inventory Lookup<br>↓<br>FastMCP Tool Execution<br>↓<br>Netmiko Session<br>↓<br>Router CLI Output<br>↓<br>Second LLM Analysis Pass<br>↓<br>Human-Friendly Response</p><p>The second LLM stage still performs operational analysis.</p><p>For example:</p><p>User:</p><pre>How many BGP neighbors are established on R1?</pre><p>The assistant:</p><ul><li>selects the BGP tool</li><li>extracts device R1</li><li>retrieves live router state</li><li>feeds raw output back into the LLM</li><li>generates a summarized operational answer</li></ul><p>This creates a much more natural interaction model compared to traditional CLI automation.</p><p>Also, the data can stay anywhere; here it is stored in a JSON file, but it can also be stored in Excel or a database.</p><h3>Storing Network State in SQLite</h3><p>Initially, the setup was directly querying devices every time the AI needed information. That works for a few routers, but it becomes slow and inefficient once the environment grows.</p><p>To improve this, I added a lightweight SQLite-based inventory cache where interface data is periodically collected and stored.</p><h3>Database Schema</h3><p>I created a simple interfaces table:</p><pre>import sqlite3<br>conn = sqlite3.connect(&quot;network.db&quot;)<br>cursor = conn.cursor()<br>cursor.execute(&quot;&quot;&quot;<br>CREATE TABLE IF NOT EXISTS interfaces (<br>    id INTEGER PRIMARY KEY AUTOINCREMENT,<br>    device_name TEXT,<br>    interface_name TEXT,<br>    ip_address TEXT,<br>    status TEXT,<br>    protocol TEXT,<br>    collected_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP<br>)<br>&quot;&quot;&quot;)<br>conn.commit()<br>conn.close()</pre><p>This stores:</p><ul><li>Device name</li><li>Interface name</li><li>IP address</li><li>Interface status</li><li>Protocol state</li><li>Collection timestamp</li></ul><h3>Polling Devices Periodically</h3><p>Instead of querying routers live for every request, I built a small collector loop.</p><p>The collector:</p><ol><li>Connects to each router</li><li>Runs show ip interface brief</li><li>Parses the output</li><li>Stores it into SQLite</li></ol><pre>while True:<br>    for device in DEVICES:<br>        output = show_interfaces(device)<br>        parsed = parse_interfaces(output)<br>        save_interfaces(device, parsed)<br>     print(&quot;Pass&quot;)<br>     time.sleep(300)</pre><p>This gives me a continuously updated local dataset of interface states across the lab.</p><h3>Parsing Router Output</h3><p>The raw CLI output is converted into structured data before insertion.</p><pre>def parse_interfaces(output):<br>    interfaces = []<br>    lines = output.splitlines()[1:]<br>    for line in lines:<br>        parts = line.split()<br>        if len(parts) &gt;= 6:<br>            interfaces.append({<br>                &quot;interface_name&quot;: parts[0],<br>                &quot;ip_address&quot;: parts[1],<br>                &quot;status&quot;: parts[-2],<br>                &quot;protocol&quot;: parts[-1]<br>            })<br>    return interfaces</pre><p>This makes the router output easier to search, analyze, and expose to the AI assistant.</p><h3>Accessing Network Data Through MCP Tools</h3><p>Once the data is stored locally, the AI assistant can query SQLite instead of logging into routers every time.</p><p>Example MCP tool:</p><pre>@mcp.tool()<br>def get_interfaces(device_name: str):<br>    conn = sqlite3.connect(&quot;network.db&quot;)<br>    cursor = conn.cursor()<br>    cursor.execute(&quot;&quot;&quot;<br>    SELECT interface_name,<br>           ip_address,<br>           status,<br>           protocol<br>    FROM interfaces<br>    WHERE device_name = ?<br>    &quot;&quot;&quot;, (device_name,))<br>    rows = cursor.fetchall()<br>    conn.close()<br>    return rows</pre><p>I also added a network-wide query:</p><pre>@mcp.tool()<br>def get_interfaces_all():<br>    conn = sqlite3.connect(&quot;network.db&quot;)<br>    cursor = conn.cursor()<br>    cursor.execute(&quot;&quot;&quot;<br>    SELECT device_name,<br>           interface_name,<br>           ip_address,<br>           status,<br>           protocol<br>    FROM interfaces<br>    &quot;&quot;&quot;)<br>    rows = cursor.fetchall()<br>    conn.close()<br>    return rows</pre><h3>Why This Helps</h3><p>This changed the setup significantly.</p><p>Instead of:</p><ul><li>AI → Router login → CLI command → Parse output</li></ul><p>The workflow became:</p><ul><li>AI → SQLite query → Immediate response</li></ul><p>Benefits:</p><ul><li>Faster responses</li><li>Reduced device load</li><li>Easier scaling to larger environments</li><li>Historical data capability</li><li>Simpler multi-device analysis</li></ul><p>This also opens the door for:</p><ul><li>Trend analysis</li><li>Interface flap detection</li><li>Alerting pipelines</li><li>AI-based anomaly detection</li><li>Natural language queries across the entire network</li></ul><p>This gives a much better and faster result:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lbcl2SRxP64FF8syNudjKA.png" /></figure><p>A better approach would be to push data from devices through various available mechanisms, but it is a little difficult to setup that in lab so I am doing pull model.</p><p>If you enjoyed reading this or found the project useful, you can support my work here:</p><p>☕ <a href="http://buymeacoffee.com/Amansingh1202">buymeacoffee.com/Amansingh1202</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8c555d9fc10a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building an MCP-Based AI Network Engineer with Python]]></title>
            <link>https://medium.com/@aks001235/building-an-mcp-based-ai-network-engineer-with-python-b93fdbcce810?source=rss-1707423c5a20------2</link>
            <guid isPermaLink="false">https://medium.com/p/b93fdbcce810</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[networking]]></category>
            <dc:creator><![CDATA[Aman Singh]]></dc:creator>
            <pubDate>Sat, 09 May 2026 07:42:20 GMT</pubDate>
            <atom:updated>2026-05-09T07:42:20.824Z</atom:updated>
            <content:encoded><![CDATA[<p>I recently built a small AI-powered network assistant using Python, Groq LLMs, FastMCP, and Netmiko to understand how modern LLM workflows can interact with real network devices.</p><p>The idea was simple:</p><blockquote><em>Ask networking questions in plain English → have an LLM decide what network data is needed → connect to a router → retrieve live operational state → let the LLM analyze the output and respond naturally.</em></blockquote><p>The interesting part was not just the LLM itself, but understanding how all the components communicate internally.</p><h3>High-Level Architecture</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/785/0*dSOIg4bnmknoD0De" /></figure><p>The workflow looks like this:</p><pre>User<br> ↓<br>Groq LLM<br> ↓<br>Tool Selection Logic<br> ↓<br>FastMCP Tool<br> ↓<br>Netmiko<br> ↓<br>Cisco Router<br> ↓<br>CLI Output<br> ↓<br>Groq LLM Analysis<br> ↓<br>Final Human Response</pre><p>The project is split into two logical parts:</p><ol><li>LLM orchestration (main.py)</li><li>Network tools exposed through FastMCP (tools.py)</li></ol><h3>Step 1: Building the Router Connectivity Layer</h3><p>For device communication, I used Netmiko.</p><p>The actual communication path here is:</p><pre>Python<br> ↓<br>Netmiko<br> ↓<br>Telnet/SSH Session<br> ↓<br>Cisco CLI</pre><p>Netmiko internally handles:</p><ul><li>session establishment</li><li>prompt detection</li><li>command execution</li><li>output collection</li></ul><p>Example tool:</p><pre>@mcp.tool()<br>def show_interfaces():<br>    conn = ConnectHandler(**router)<br>    output = conn.send_command(<br>        &quot;show ip interface brief&quot;<br>    )<br>    conn.disconnect()<br>    return output</pre><p>This tool simply:</p><ol><li>Opens a session</li><li>Executes a CLI command</li><li>Collects output</li><li>Returns the result as text</li></ol><h3>Step 2 : Why FastMCP Was Added</h3><p>I could have directly called Python functions. But I wanted to structure the project around MCP (Model Context Protocol). FastMCP exposes Python functions as discoverable tools for AI systems.</p><p>Instead of manually wiring every function:</p><pre>if &quot;bgp&quot; in prompt:<br>    show_bgp()</pre><p>FastMCP allows tools to become standardized callable capabilities.</p><p>Example:</p><pre>@mcp.tool()<br>def show_bgp():</pre><p>Now the function becomes:</p><ul><li>discoverable</li><li>reusable</li><li>AI-friendly</li></ul><p>Conceptually:</p><pre>Without MCP:<br>LLM → custom Python logic<br>With MCP:<br>LLM → standardized tools layer</pre><p>This becomes important as systems scale:</p><ul><li>multiple devices</li><li>telemetry sources</li><li>ticketing systems</li><li>observability platforms</li></ul><h3>Step 3: LLM Integration with Groq</h3><p>For inference, I used Groq with the openai/gpt-oss-120b model.</p><p>The helper function is intentionally simple:</p><pre>def ask_llm(messages):<br>    completion = client.chat.completions.create(<br>        model=&quot;openai/gpt-oss-120b&quot;,<br>        messages=messages,<br>        temperature=0<br>    )<br>   return completion.choices[0].message.content</pre><p>At this stage, the LLM performs two different jobs:</p><ol><li>Tool selection</li><li>Output analysis</li></ol><p>These are actually separate reasoning stages.</p><h3>Step 4: Tool Selection Stage</h3><p>The first prompt determines:</p><blockquote><em>Which network tool should be executed?</em></blockquote><p>The system prompt constrains the model:</p><pre>SYSTEM_PROMPT = &quot;&quot;&quot;<br>You are a network automation assistant.<br>If the user asks about interfaces:<br>return ONLY:<br>TOOL:show_interfaces<br>&quot;&quot;&quot;</pre><p>Example flow:</p><p>User:</p><pre>give me status of all interfaces</pre><p>LLM response:</p><pre>TOOL:show_interfaces</pre><p>At this point:</p><ul><li>No network data has been analysed yet</li><li>The model is only deciding intent</li></ul><p>This is essentially an AI-driven command dispatcher.</p><h3>Step 5: Network Device Execution</h3><p>Once the tool is selected:</p><pre>tool_output = show_interfaces()<br>Netmiko connects to the router and executes:<br>show ip interface brief</pre><p>The raw CLI output is returned to Python.</p><p>Example:</p><pre>Ethernet1/0 up up<br>Ethernet1/1 up up<br>Ethernet2/0 administratively down down</pre><p>At this stage, the system now has a live operational network state.</p><h3>Step 6: Second LLM Pass</h3><p>Initially, my implementation stopped after returning raw CLI output.</p><p>That worked for:</p><ul><li>“show interfaces”</li><li>“show bgp”</li></ul><p>But failed for analytical questions like:</p><ul><li>“How many interfaces are up?”</li><li>“Which neighbors are down?”</li></ul><p>The reason was:</p><ul><li>the LLM selected tools</li><li>but never interpreted the returned data</li></ul><p>The fix was introducing a second LLM reasoning stage.</p><p>The raw router output is fed back into the model:</p><pre>analysis_messages = [<br>    {<br>        &quot;role&quot;: &quot;user&quot;,<br>        &quot;content&quot;: f&quot;&quot;&quot;<br>User Question:<br>{user_input}<br>Router Output:<br>{tool_output}<br>&quot;&quot;&quot;<br>    }<br>]</pre><p>Now the LLM performs actual analysis.</p><p>Example:</p><p>User:</p><pre>How many interfaces are up?</pre><p>Router Output:</p><pre>Ethernet1/0 up up<br>Ethernet1/1 up up<br>Ethernet2/0 administratively down down</pre><p>Final AI Response:</p><pre>2 interfaces are operationally up.<br>1 interface is administratively down.</pre><p>This is where the assistant becomes genuinely useful.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b93fdbcce810" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[IPv6 SLAAC Deep Dive]]></title>
            <link>https://medium.com/@aks001235/ipv6-slaac-deep-dive-f81d419e2fff?source=rss-1707423c5a20------2</link>
            <guid isPermaLink="false">https://medium.com/p/f81d419e2fff</guid>
            <category><![CDATA[slaac]]></category>
            <category><![CDATA[labs]]></category>
            <category><![CDATA[networking]]></category>
            <category><![CDATA[computer-networking]]></category>
            <dc:creator><![CDATA[Aman Singh]]></dc:creator>
            <pubDate>Sun, 19 Apr 2026 14:50:59 GMT</pubDate>
            <atom:updated>2026-04-19T14:50:59.712Z</atom:updated>
            <content:encoded><![CDATA[<h3>What is SLAAC</h3><p>SLAAC allows a host to:</p><ul><li>Automatically generate its IPv6 address</li><li>Learn the default gateway</li><li>Operate without DHCP</li></ul><p>This is how it works step by step:</p><h3>1. Interface comes up</h3><p>When the device connects to a network, its network interface initialises and enables IPv6.</p><h3>2. Link-local address creation</h3><p>The device first generates a link-local address (always starts with fe80::). It generally builds this using its MAC address (via modified EUI-64).</p><h3>3. Duplicate Address Detection (DAD)</h3><p>Before using the address, the device checks if it’s already in use:</p><ul><li>It sends a Neighbour Solicitation (NS) message.</li><li>If no one responds, the address is considered unique and usable.</li></ul><h3>4. Router Solicitation (RS)</h3><p>The device asks: <em>“Any routers out there?”</em></p><ul><li>It sends a Router Solicitation message to the network.</li></ul><h3>5. Router Advertisement (RA)</h3><p>A router responds with a Router Advertisement, which contains:</p><ul><li>Network prefix (e.g., 2001:db8:abcd::/64)</li><li>Default gateway info</li><li>Flags indicating whether SLAAC and/or DHCPv6 should be used</li></ul><h3>6. Global address generation</h3><p>Using the prefix from the RA:</p><ul><li>The device combines:</li><li>The network prefix (from router)</li><li>Its interface ID (from earlier)</li><li>This forms a global unicast IPv6 address</li></ul><h3>7. Duplicate Address Detection (again)</h3><p>The device repeats DAD for this new global address to ensure no conflict.</p><h3>8. Address becomes usable</h3><p>Once verified:</p><ul><li>The device can now communicate on the network and the internet using IPv6.</li><li>It also installs the router as its default gateway.</li></ul><h3>📊 Packet-by-Packet Breakdown</h3><p>Let’s walk through the actual flow from your capture.</p><h3>Let’s try it in our Lab,</h3><p>I am configuring this on my router:</p><pre>conf t<br>ipv6 unicast-routing<br><br>interface fa0/0<br>ipv6 address 2001:db8:1::1/64<br>no shutdown</pre><p>Let us analyse what happens packet by packet:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7rThHtu1kLo1iGHWIbjbuQ.png" /></figure><h3>🔹 Packet 22 — Neighbor Solicitation (DAD)</h3><ul><li>Src :: → Dst ff02::1:ffc1:0</li><li>Checking if fe80::c803:11ff:fec1:0 is already in use.</li><li>No reply → address is considered unique.</li></ul><h3>🔹 Packet 23 , 24, 25 — MLD Report v2</h3><ul><li>Host joins multicast groups (ff02::1, solicited-node group).</li><li>Ensures it can receive ND / RA messages.</li></ul><h3>🔹 Packet 26 — Neighbor Advertisement</h3><ul><li>Router replies: fe80::c803:11ff:fec1:0 is at ca:03:11:c1:00:00</li><li>Confirms ownership of link-local address.</li></ul><h3>🔹 Packet 27 — Neighbor Solicitation (for global)</h3><ul><li>Src :: → Dst ff02::1:ff00:1</li><li>DAD for global IPv6 2001:db8:1::1.</li></ul><h3>🔹 Packet 28 — Router Advertisement (KEY SLAAC PACKET)</h3><ul><li>Router → ff02::1 (all nodes)</li><li>Contains:</li><li>Prefix 2001:db8:1::/64</li><li>Flags (A=1 for SLAAC)</li><li>Host uses this to generate global IPv6 address.</li></ul><h3>🔹 Packet 33 — Neighbor Advertisement (global)</h3><ul><li>Router advertises: 2001:db8:1::1 is at MAC</li><li>Confirms global IPv6 ownership.</li></ul><p>In Nutshell:</p><ul><li><strong>DAD (link-local) → Packet 22</strong></li><li><strong>Multicast join → 23–25</strong></li><li><strong>Router presence → 26</strong></li><li><strong>DAD (global) → 27</strong></li><li><strong>RA → SLAAC happens → 28 (critical)</strong></li><li><strong>Address confirmed → 33</strong></li></ul><h3>Router Advertisement Fields</h3><p>From this packet, which is packet no 28:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ur_L4Y3muAqQneGlmRpT-Q.png" /></figure><h3>🔹 Global RA Flags</h3><pre>Managed (M): 0<br>Other (O): 0</pre><h3>Meaning:</h3><p>This is a pure SLAAC environment.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/781/1*F7xaUhdBERpRYvqqfWpIug.png" /></figure><h3>🔹 Router Lifetime</h3><pre>1800 seconds</pre><p>Host installs:</p><pre>Default route valid for 30 minutes</pre><h3>🔹 Prefix Information</h3><pre>Prefix: 2001:db8:1::/64</pre><h3>Critical Flags inside Prefix</h3><pre>On-link (L): 1<br>Autonomous (A): 1</pre><h3>Interpretation</h3><h4>L flag = 1</h4><ul><li>Network is directly reachable (same subnet)</li></ul><h4>A flag = 1</h4><ul><li>SLAAC is enabled</li></ul><p>This is the actual trigger for address creation</p><h3>🔹 Lifetime Values</h3><pre>Valid Lifetime: 30 days<br>Preferred Lifetime: 7 days</pre><p>Behavior:</p><ul><li>Preferred → actively used</li><li>Valid → still usable but deprecated</li></ul><h3>🔹 MTU Option</h3><pre>MTU: 1500</pre><p>Host adopts MTU from RA</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f81d419e2fff" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[GRE vs IP-in-IP]]></title>
            <link>https://medium.com/@aks001235/gre-vs-ip-in-ip-5feed6fec0a3?source=rss-1707423c5a20------2</link>
            <guid isPermaLink="false">https://medium.com/p/5feed6fec0a3</guid>
            <category><![CDATA[gre]]></category>
            <category><![CDATA[routing]]></category>
            <category><![CDATA[ipip]]></category>
            <category><![CDATA[networking]]></category>
            <category><![CDATA[ospf]]></category>
            <dc:creator><![CDATA[Aman Singh]]></dc:creator>
            <pubDate>Sat, 11 Apr 2026 09:24:16 GMT</pubDate>
            <atom:updated>2026-04-11T09:24:16.545Z</atom:updated>
            <content:encoded><![CDATA[<p>I recently built a small lab to understand how GRE and IP-in-IP tunnels actually behave, not just from configuration but also from control plane + packet level.</p><h3>🧩 Initial State: Interfaces</h3><p>Here’s how the topology looked before bringing up the tunnel:</p><pre>R3(config)#do sh ip int br<br>Interface              IP-Address      OK? Method Status                Protocol<br>FastEthernet0/0        10.0.23.3       YES manual up                    up<br>FastEthernet1/0        unassigned      YES unset  administratively down down<br>FastEthernet2/0        unassigned      YES unset  administratively down down<br>Loopback0              3.3.3.3         YES manual up                    up<br>Tunnel0                172.16.13.2     YES manual up                    down<br><br>R2(config)#do sh ip int br<br>Interface              IP-Address      OK? Method Status                Protocol<br>FastEthernet0/0        10.0.12.2       YES manual up                    up<br>FastEthernet1/0        10.0.23.2       YES manual up                    up<br>FastEthernet2/0        unassigned      YES unset  administratively down down<br><br>R1(config)#do sh ip int br<br>Interface              IP-Address      OK? Method Status                Protocol<br>FastEthernet0/0        10.0.12.1       YES manual up                    up<br>FastEthernet1/0        unassigned      YES unset  administratively down down<br>FastEthernet2/0        unassigned      YES unset  administratively down down<br>Loopback0              1.1.1.1         YES manual up                    up<br>Tunnel0                172.16.13.1     YES manual up                    down</pre><h3>🔧 GRE Tunnel Configuration</h3><p>On R1:</p><pre>do sh running-config | section Tunnel<br>interface Tunnel0<br> ip address 172.16.13.1 255.255.255.252<br> tunnel source 10.0.12.1<br> tunnel destination 10.0.23.3<br>R1(config)#ip route 10.0.23.3 255.255.255.255 10.0.12.2<br>R1(config)#do wr<br>Building configuration...<br>[OK]<br>R1(config)#<br>*Apr 11 11:30:30.511: %LINEPROTO-5-UPDOWN: Line protocol on Interface Tunnel0, changed state to up</pre><p><em>Tunnel comes UP even if remote side is not configured</em></p><p>This is because:</p><ul><li>GRE only checks <strong>underlay reachability</strong></li><li>It does NOT validate remote tunnel state</li></ul><h3>🔧 R3 Tunnel Config</h3><pre>R3(config)#do sh running-config | section Tunnel<br>interface Tunnel0<br> ip address 172.16.13.2 255.255.255.252<br> tunnel source 10.0.23.3<br> tunnel destination 10.0.12.1<br>R3(config)#ip route 10.0.12.1 255.255.255.255 10.0.23.2</pre><h3>Running OSPF over GRE</h3><pre>R1(config-router)# network 172.16.13.0 0.0.0.3 area 0<br>R1(config-router)# network 1.1.1.0 0.0.0.255 area 0<br>R1(config-router)#do wr<br>Building configuration...<br>[OK]<br>R1(config-router)#<br>*Apr 11 11:43:34.343: %OSPF-5-ADJCHG: Process 1, Nbr 3.3.3.3 on Tunnel0 from LOADING to FULL, Loading Done</pre><p>On R3:</p><pre>R3(config)#router ospf 1<br>R3(config-router)# router-id 3.3.3.3<br>R3(config-router)# network 172.16.13.0 0.0.0.3 area 0<br>R3(config-router)# network 3.3.3.0 0.0.0.255 area 0<br>R3(config-router)#do wr<br>Building configuration...<br><br>*Apr 11 11:43:34.315: %OSPF-5-ADJCHG: Process 1, Nbr 1.1.1.1 on Tunnel0 from LOADI</pre><p>Verification:</p><pre>R1(config)#do ping 3.3.3.3<br>Type escape sequence to abort.<br>Sending 5, 100-byte ICMP Echos to 3.3.3.3, timeout is 2 seconds:<br>!!!!!<br>Success rate is 100 percent (5/5), round-trip min/avg/max = 20/34/52 ms</pre><h3>Failure Scenario</h3><p>Shutting tunnel on R1:</p><pre>R1(config)#int tunnel0<br>R1(config-if)#shut<br>R1(config-if)#<br>*Apr 11 11:53:53.187: %OSPF-5-ADJCHG: Process 1, Nbr 3.3.3.3 on Tunnel0 from FULL to DOWN, Neighbor Down: Interface down or detached<br>*Apr 11 11:53:55.171: %LINEPROTO-5-UPDOWN: Line protocol on Interface Tunnel0, changed state to down<br>*Apr 11 11:53:55.175: %LINK-5-CHANGED: Interface Tunnel0, changed state to administratively down</pre><p>But on R3:</p><pre>R3(config)#do sh ip int br<br>Interface              IP-Address      OK? Method Status                Protocol<br>FastEthernet0/0        10.0.23.3       YES manual up                    up<br>FastEthernet1/0        unassigned      YES unset  administratively down down<br>FastEthernet2/0        unassigned      YES unset  administratively down down<br>Loopback0              3.3.3.3         YES manual up                    up<br>Tunnel0                172.16.13.2     YES manual up                    up</pre><p>👉 <strong>Key Learning:</strong></p><blockquote><em>GRE tunnel is </em><strong><em>unidirectional state-aware</em></strong></blockquote><ul><li>One side down ❌</li><li>Other side still shows up ✅</li></ul><blockquote><em>Use BFD for fast + symmetric failure detection</em></blockquote><h3>🔁 IP-in-IP Configuration Difference</h3><p>Only change:</p><pre>R1(config)# do show running-config | section int<br>interface Loopback0<br> ip address 1.1.1.1 255.255.255.0<br>interface Tunnel0<br> ip address 192.168.13.1 255.255.255.252<br> tunnel source 10.0.12.1<br> tunnel mode ipip<br> tunnel destination 10.0.23.3</pre><p>👉 Just one line:</p><pre>tunnel mode ipip</pre><h3>🔬 Packet-Level Understanding</h3><h3>🔹 IP-in-IP Packet</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*B3yAntUDedLpauNuvvvNVw.png" /></figure><pre>Src: 10.0.12.1<br>Dst: 10.0.23.3<br>Protocol: IPIP (4)<br>TTL: 255</pre><p>👉 Meaning:</p><ul><li>Outer = underlay</li><li>Inner = tunnel packet</li><li>No extra header</li></ul><h3>🔹 GRE Packet (Key Differences)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*c6IpOa8Ap4QtRSLGqMEo_A.png" /></figure><ul><li>Protocol = <strong>47</strong></li><li>GRE header present</li><li>Payload type defined (IPv4)</li></ul><h3>GRE vs IP-in-IP</h3><ul><li><strong>Protocol Number</strong></li></ul><p>GRE → <strong>47</strong></p><p>IPIP → <strong>4</strong></p><ul><li><strong>Encapsulation</strong></li></ul><p>GRE → Outer IP + GRE header + Inner IP</p><p>IPIP → Outer IP + Inner IP (no extra header)</p><ul><li><strong>Header Presence</strong></li></ul><p>GRE → Has <strong>GRE header</strong> (defines payload type)</p><p>IPIP → No additional header</p><ul><li><strong>Overhead</strong></li></ul><p>GRE → ~24 bytes</p><p>IPIP → ~20 bytes</p><ul><li><strong>Multicast Support</strong></li></ul><p>GRE → Supported</p><p>IPIP → Not supported</p><ul><li><strong>Flexibility</strong></li></ul><p>GRE → Can carry multiple protocols</p><p>IPIP → Only IP (unicast)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5feed6fec0a3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Juniper OSPF Multi Area Lab challenges]]></title>
            <link>https://medium.com/@aks001235/juniper-ospf-multi-area-lab-challenges-d22054172d7d?source=rss-1707423c5a20------2</link>
            <guid isPermaLink="false">https://medium.com/p/d22054172d7d</guid>
            <category><![CDATA[learning]]></category>
            <category><![CDATA[ospf]]></category>
            <category><![CDATA[networking]]></category>
            <category><![CDATA[labs]]></category>
            <dc:creator><![CDATA[Aman Singh]]></dc:creator>
            <pubDate>Thu, 26 Mar 2026 16:26:29 GMT</pubDate>
            <atom:updated>2026-03-26T16:26:29.602Z</atom:updated>
            <content:encoded><![CDATA[<p>I am using this Juniper vLab for the challenges</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/895/0*1v9dwAeSuMRnjS0x.jpg" /><figcaption><a href="https://jlabs.juniper.net/vlabs/portal/ospf-multi-area/">https://jlabs.juniper.net/vlabs/portal/ospf-multi-area/</a></figcaption></figure><h3>Challenge 2: Stub Area and Default Route Injection</h3><p>In a multi-area OSPF design, controlling route propagation is not just about <em>what</em> you filter; it’s about <em>where</em> you filter it.</p><p>In this scenario, the goal was simple:</p><blockquote><em>Prevent the loopback 10.100.100.5 (R5 in Area 1) from reaching R6 (Area 2)</em></blockquote><p>However, the initial implementation did not work, even though the policy looked correct. The reason lies in how OSPF generates and propagates LSAs across areas.</p><h3>Initial Observation</h3><p>On R6, we can see that all loopbacks, including 10.100.100.5, are present:</p><pre>jcluser@vMX6&gt; show route protocol ospf<br><br>inet.0: 22 destinations, 22 routes (22 active, 0 holddown, 0 hidden)<br>+ = Active Route, - = Last Active, * = Both<br><br>10.100.12.0/24     *[OSPF/10] 00:03:31, metric 2<br>                    &gt;  to 10.100.26.1 via ge-0/0/3.0<br>10.100.13.0/24     *[OSPF/10] 00:03:14, metric 3<br>                    &gt;  to 10.100.26.1 via ge-0/0/3.0<br>                       to 10.100.46.1 via ge-0/0/4.0<br>10.100.14.0/24     *[OSPF/10] 00:03:26, metric 2<br>                    &gt;  to 10.100.46.1 via ge-0/0/4.0<br>10.100.15.0/24     *[OSPF/10] 00:03:14, metric 3<br>                    &gt;  to 10.100.26.1 via ge-0/0/3.0<br>                       to 10.100.46.1 via ge-0/0/4.0<br>10.100.23.0/24     *[OSPF/10] 00:02:59, metric 2<br>                    &gt;  to 10.100.26.1 via ge-0/0/3.0<br>10.100.24.0/24     *[OSPF/10] 00:03:09, metric 2<br>                    &gt;  to 10.100.26.1 via ge-0/0/3.0<br>                       to 10.100.46.1 via ge-0/0/4.0<br>10.100.34.0/24     *[OSPF/10] 00:03:26, metric 2<br>                    &gt;  to 10.100.46.1 via ge-0/0/4.0<br>10.100.35.0/24     *[OSPF/10] 00:02:59, metric 3<br>                       to 10.100.26.1 via ge-0/0/3.0<br>                    &gt;  to 10.100.46.1 via ge-0/0/4.0<br>10.100.100.1/32    *[OSPF/10] 00:03:14, metric 2<br>                       to 10.100.26.1 via ge-0/0/3.0<br>                    &gt;  to 10.100.46<br>10.100.100.2/32    *[OSPF/10] 00:03:31, metric 1<br>                    &gt;  to 10.100.26.1 via ge-0/0/3.0<br>10.100.100.3/32    *[OSPF/10] 00:02:59, metric 2<br>                       to 10.100.26.1 via ge-0/0/3.0<br>                    &gt;  to 10.100.46.1 via ge-0/0/4.0<br>10.100.100.4/32    *[OSPF/10] 00:03:26, metric 1<br>                    &gt;  to 10.100.46.1 via ge-0/0/4.0<br>10.100.100.5/32    *[OSPF/10] 00:03:14, metric 3<br>                       to 10.100.26.1 via ge-0/0/3.0<br>                    &gt;  to 10.100.46.1 via ge-0/0/4.0<br>224.0.0.5/32       *[OSPF/10] 00:04:22, metric 1<br>                       MultiRecv</pre><p>Also confirming on R5:</p><pre>jcluser@vMX5&gt; show interfaces terse | match lo    <br>Interface               Admin Link Proto    Local                 Remote<br>lo0                     up    up<br>lo0.0                   up    up   inet     10.100.100.5        --&gt; 0/0<br>lo0.16384               up    up   inet     127.0.0.1           --&gt; 0/0<br>lo0.16385               up    up   inet</pre><h3>First Attempt: Filtering on R1 and R3 (Area 1 ABRs)</h3><p>Applied export policy:</p><pre>jcluser@vMX1# show | compare                                <br>[edit]<br>+  policy-options {<br>+      policy-statement DISCARD_LOOPBACK {<br>+          term remove_loopback {<br>+              from {<br>+                  route-filter 10.100.100.0/24 orlonger;<br>+              }<br>+              then reject;<br>+          }<br>+          term allow_others {<br>+              then accept;<br>+          }<br>+      }<br>+  }<br>[edit protocols ospf]<br>+   export DISCARD_LOOPBACK;</pre><p>But R6 still sees all loopbacks:</p><pre>jcluser@vMX6&gt; show route protocol ospf | match /32 <br>10.100.100.1/32<br>10.100.100.2/32<br>10.100.100.3/32<br>10.100.100.4/32<br>10.100.100.5/32</pre><h3>Correct Approach: Filtering at the Right ABR</h3><p>Applied policy on R2 and R4:</p><pre>jcluser@vMX2&gt; show configuration protocols ospf | display set <br>set protocols ospf area 0.0.0.0 interface ge-0/0/0.0<br>set protocols ospf area 0.0.0.0 interface ge-0/0/1.0<br>set protocols ospf area 0.0.0.0 interface lo0.0<br>set protocols ospf area 0.0.0.2 network-summary-export DISCARD_LOOPBACK<br>set protocols ospf area 0.0.0.2 interface ge-0/0/2.0<br>set protocols ospf area 0.0.0.2 interface ge-0/0/3.0</pre><p>Policy:</p><pre>set policy-options policy-statement DISCARD_LOOPBACK term remove_loopback from route-filter 10.100.100.0/24 orlonger<br>set policy-options policy-statement DISCARD_LOOPBACK term remove_loopback then reject<br>set policy-options policy-statement DISCARD_LOOPBACK term allow_others then accept</pre><h3>Result</h3><p>Now on R6:</p><pre>jcluser@vMX6&gt; show route protocol ospf | match /32    <br>224.0.0.5/32       *[OSPF/10] 02:18:00, metric 1</pre><p>All loopbacks are filtered.</p><h3>Refinement: Filtering Only R5 Loopback</h3><p>Updated policy:</p><pre>jcluser@vMX2# show | compare <br>[edit policy-options policy-statement DISCARD_LOOPBACK term remove_loopback from]<br>+      route-filter 10.100.100.5/32 exact;<br>-      route-filter 10.100.100.0/24 orlonger;</pre><h3>Final Result</h3><pre>jcluser@vMX6&gt; show route protocol ospf | match /32    <br>10.100.100.1/32    *[OSPF/10] 00:00:15, metric 2<br>10.100.100.2/32    *[OSPF/10] 00:00:15, metric 1<br>10.100.100.3/32    *[OSPF/10] 00:00:15, metric 2<br>10.100.100.4/32    *[OSPF/10] 00:01:35, metric 1<br>224.0.0.5/32       *[OSPF/10] 02:24:00, metric 1</pre><p>We can see that now only the 10.100.100.5 route is discarded, while all other loopbacks remain.</p><h3>Key Learning: Where to Filter in OSPF</h3><p>The route flow looks like this logically:</p><ul><li>The router in Area 1 advertises the network as a Type-1 LSA</li><li>The ABR between Area 1 and Area 0 converts it into a Type-3 summary LSA and advertises it into Area 0</li><li>The ABR between Area 0 and Area 2 then generates another Type-3 LSA toward Area 2</li></ul><p>If you try to filter the route on the first ABR (Area1 ↔ Area0), Area 0 may still learn the summary.</p><p>To prevent the route from entering Area 2, the correct control point is the ABR that advertises into Area 2, because that is where the Type-3 LSA toward Area 2 is generated.</p><h3>Final Insight</h3><p>That’s why when we applied our policies on R1 and R3, it didn’t work, but it worked when we applied it on R2 and R4.</p><p>This is a subtle but critical concept in OSPF:</p><blockquote><strong><em>You don’t filter where the route originates, you filter where the LSA is generated for the target area.</em></strong></blockquote><h3>Challenge 2: Stub Area and Default Route Injection</h3><h3>Initial State</h3><p>Before any stub configuration, R5 does not have a default route:</p><pre>jcluser@vMX5&gt; show route protocol ospf <br>inet.0: 22 destinations, 22 routes (22 active, 0 holddown, 0 hidden)<br>+ = Active Route, - = Last Active, * = Both<br><br>10.100.12.0/24     *[OSPF/10] 00:02:33, metric 2<br>                    &gt;  to 10.100.15.1 via ge-0/0/3.0<br>10.100.13.0/24     *[OSPF/10] 00:02:28, metric 2<br>                    &gt;  to 10.100.15.1 via ge-0/0/3.0<br>                       to 10.100.35.1 via ge-0/0/4.0<br>10.100.14.0/24     *[OSPF/10] 00:02:33, metric 2<br>                    &gt;  to 10.100.15.1 via ge-0/0/3.0<br>10.100.23.0/24     *[OSPF/10] 00:02:28, metric 2<br>                    &gt;  to 10.100.35.1 via ge-0/0/4.0<br>10.100.24.0/24     *[OSPF/10] 00:02:28, metric 3<br>                    &gt;  to 10.100.15.1 via ge-0/0/3.0<br>                       to 10.100.35.1 via ge-0/0/4.0<br>10.100.26.0/24     *[OSPF/10] 00:02:28, metric 3<br>                    &gt;  to 10.100.15.1 via ge-0/0/3.0<br>                       to 10.100.35.1 via ge-0/0/4.0<br>10.100.34.0/24     *[OSPF/10] 00:02:28, metric 2<br>                    &gt;  to 10.100.35.1 via ge-0/0/4.0<br>10.100.46.0/24     *[OSPF/10] 00:02:28, metric 3<br>                    &gt;  to 10.100.15.1 via ge-0/0/3.0<br>                       to 10.100.35.1 via ge-0/0/4.0<br>10.100.100.1/32    *[OSPF/10] 00:02:33, metric 1<br>                    &gt;  to 10.100.15.1 via ge-0/0/3.0<br>10.100.100.2/32    *[OSPF/10] 00:02:28, metric 2<br>                       to 10.100.15.1 via ge-0/0/3.0<br>                    &gt;  to 10.100.35.1 via ge-0/0/4.0<br>10.100.100.3/32    *[OSPF/10] 00:02:28, metric 1<br>                    &gt;  to 10.100.35.1 via ge-0/0/4.0<br>10.100.100.4/32    *[OSPF/10] 00:02:28, metric 2<br>                       to 10.100.15.1 via ge-0/0/3.0<br>                    &gt;  to 10.100.35.1 via ge-0/0/4.0<br>10.100.100.6/32    *[OSPF/10] 00:02:28, metric 3<br>                       to 10.100.15.1 via ge-0/0/3.0<br>                    &gt;  to 10.100.35.1 via ge-0/0/4.0<br>224.0.0.5/32       *[OSPF/10] 01:05:45, metric 1<br>                       MultiRecv</pre><h3>Stub Configuration</h3><p>Configured stub area on all routers in Area 1:</p><pre>jcluser@vMX1&gt; configure exclusive <br>warning: uncommitted changes will be discarded on exit<br>Entering configuration mode<br>[edit]<br>jcluser@vMX1# set protocols ospf area 0.0.0.1 stub <br>[edit]<br>jcluser@vMX1# commit check <br>configuration check succeeds<br>[edit]<br>jcluser@vMX1# commit <br>commit complete</pre><p>Even after this, no default route appeared on R5.</p><h3>Key Insight</h3><p><strong>Stub ≠ automatic default</strong></p><p>Instead:</p><ul><li>Stub → allows default</li><li>ABR → decides to inject it</li></ul><h3>Fix: Explicit Default Injection</h3><p>Configured on both ABRs (R1 and R3):</p><pre>set protocols ospf area 0.0.0.1 stub default-metric 10</pre><h3>Result</h3><p>Now R5 receives the default route:</p><pre>jcluser@vMX5&gt; show route protocol ospf    <br>inet.0: 22 destinations, 23 routes (22 active, 0 holddown, 0 hidden)<br>+ = Active Route, - = Last Active, * = Both<br>0.0.0.0/0           [OSPF/10] 00:00:04, metric 11<br>                    &gt;  to 10.100.15.1 via ge-0/0/3.0<br>                       to 10.100.35.1 via ge-0/0/4.0<br>...</pre><h3>Why Metric is 11 (Not 10)</h3><p>Final route metric =</p><p>Intra-area cost (to reach ABR) + Inter-area metric (advertised by ABR)<br>= 10 + 1 = 11</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d22054172d7d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a Cisco ACL + Juniper Firewall Filter Lab]]></title>
            <link>https://medium.com/@aks001235/building-a-cisco-acl-juniper-firewall-filter-lab-0d79677d40c0?source=rss-1707423c5a20------2</link>
            <guid isPermaLink="false">https://medium.com/p/0d79677d40c0</guid>
            <category><![CDATA[firewall]]></category>
            <category><![CDATA[juniper]]></category>
            <category><![CDATA[cisco]]></category>
            <category><![CDATA[networking]]></category>
            <category><![CDATA[acl]]></category>
            <dc:creator><![CDATA[Aman Singh]]></dc:creator>
            <pubDate>Mon, 09 Feb 2026 17:11:50 GMT</pubDate>
            <atom:updated>2026-02-09T17:11:50.655Z</atom:updated>
            <content:encoded><![CDATA[<p>In this story, I’ll walk through a clean ACL + firewall-filter challenge I created using a <strong>Cisco C7200</strong> and a <strong>Juniper OLIVE</strong>, based on realistic enterprise requirements: <em>allow only specific management traffic, deny everything else, and verify the behaviour properly</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/742/1*0vUhjs5EmCY5Ve821fq5Sg.png" /></figure><p>This lab is especially useful because it forces you to think in terms of:</p><ul><li>Stateless filtering behaviour (ACLs and firewall filters)</li><li>Direction of traffic (inbound vs outbound)</li><li>Source vs destination matching</li><li>Service-based filtering (ICMP, SSH, SNMP)</li><li>Verification using real traffic tests and counters</li></ul><h3>Cisco Side: ACL Design Requirements</h3><p>On the Cisco side, the goal was to build a strict inbound ACL that only allows:</p><ul><li>ICMP echo-request to Cisco loopback 1.1.1.1 <strong>from Juniper loopback </strong><strong>2.2.2.2</strong></li><li>SSH to Cisco loopback 1.1.1.1 <strong>from Juniper loopback </strong><strong>2.2.2.2</strong></li><li>Explicitly deny ICMP and SSH attempts to the Cisco interface 192.168.1.1</li></ul><p>This is a typical pattern used in networks where:</p><ul><li>The loopback IP is treated as the router’s <em>management identity</em></li><li>Physical interface IPs are not meant to be reachable for management access</li><li>ACL is applied inbound on the WAN or transit-facing interface</li></ul><h3>Cisco Configuration</h3><p>Below is the Cisco ACL and interface configuration used:</p><pre>R2(config)#do show access-lists<br>Extended IP access list in_from_R1<br>    10 permit icmp host 2.2.2.2 host 1.1.1.1 (4 matches)<br>    20 deny icmp host 2.2.2.2 host 192.168.1.1<br>    30 deny icmp host 192.168.1.2 host 192.168.1.1 (3 matches)<br>    40 permit tcp host 192.168.1.2 host 1.1.1.1 eq 22<br>    50 permit tcp host 2.2.2.2 host 1.1.1.1 eq 22 (2 matches)<br>    60 deny tcp host 192.168.1.2 host 192.168.1.1 eq 22<br>    70 deny tcp host 2.2.2.2 host 192.168.1.1 eq 22<br>R2(config)#do sh running-config | section int<br>interface Loopback0<br> ip address 1.1.1.1 255.255.255.255<br>interface FastEthernet0/0<br> ip address 192.168.1.1 255.255.255.0<br> ip access-group in_from_R1 in<br> duplex half</pre><h3>Key Observations About the Cisco ACL</h3><p>A few important design points stand out here:</p><h3>1. ACL must be applied inbound on the physical interface</h3><p>The key requirement was <em>inbound filtering</em>, which is why the ACL is applied using:</p><pre>ip access-group in_from_R1 in</pre><p>This ensures traffic entering Cisco from Juniper is evaluated immediately.</p><h3>2. ICMP filtering is explicitly tied to loopback</h3><p>The first term is very strict:</p><pre>10 permit icmp host 2.2.2.2 host 1.1.1.1</pre><p>This ensures that ICMP is not permitted to random interface IPs, and it enforces loopback-only management reachability.</p><h3>3. SSH is explicitly restricted to TCP port 22</h3><p>Here, SSH is tied to port 22:</p><pre>50 permit tcp host 2.2.2.2 host 1.1.1.1 eq 22</pre><p>This prevents unintended access to other TCP services.</p><h3>4. Deny statements enforce “no management on physical interface”</h3><p>These lines ensure that SSH attempts to 192.168.1.1 are denied:</p><pre>70 deny tcp host 2.2.2.2 host 192.168.1.1 eq 22</pre><p>This is aligned with the requirement that loopback is the only allowed management endpoint.</p><h3>Juniper Side: Firewall Filter Design Requirements</h3><p>On the Juniper side, the policy requirements are different:</p><ul><li>Only allow SNMP from Cisco loopback 1.1.1.1 to Juniper loopback 2.2.2.2</li><li>Deny SNMP attempts to Juniper physical interface 192.168.1.2</li><li>Still allow Cisco to ping Juniper loopback 2.2.2.2</li><li>Drop everything else</li></ul><p>This is also realistic because SNMP is commonly restricted to loopback-based management, while physical interface SNMP is blocked.</p><h3>Juniper Configuration</h3><p>Here is the Juniper firewall filter configuration:</p><pre>filter in_from_R1 {<br>    term only_snmp {<br>        from {<br>            source-address {<br>                1.1.1.1/32;<br>            }<br>            destination-address {<br>                2.2.2.2/32;<br>            }<br>            protocol udp;<br>            port snmp;<br>        }<br>        then accept;<br>    }<br>    term reject_snmp_specific {<br>        from {<br>            destination-address {<br>                192.168.1.2/32;<br>            }<br>            protocol udp;<br>            port snmp;<br>        }<br>        then {<br>            reject;<br>        }<br>    }<br>    term ping_loopback {<br>        from {<br>            destination-address {<br>                2.2.2.2/32;<br>            }<br>            protocol icmp;<br>        }<br>        then accept;<br>    }<br>    term reject_else {<br>        then {<br>            reject;<br>        }<br>    }<br>}</pre><h3>Key Observations About the Juniper Firewall Filter</h3><p>Juniper firewall filters work differently from Cisco ACLs in syntax, but the core concept is the same:</p><ul><li>Match criteria in the from section</li><li>Action in the then section</li><li>Evaluation happens top-down (first match wins)</li></ul><h3>1. SNMP is matched using protocol + port</h3><p>This is the correct way to match SNMP:</p><pre>protocol udp;<br>port snmp;</pre><p>On Junos, port snmp maps to UDP/161.</p><h3>2. Source and destination are explicitly controlled</h3><p>This term ensures SNMP is only allowed from Cisco loopback to Juniper loopback:</p><pre>source-address {<br>    1.1.1.1/32;<br>}<br>destination-address {<br>    2.2.2.2/32;<br>}</pre><p>This is very clean and avoids accidental SNMP exposure.</p><h3>3. Explicit SNMP rejection to physical interface</h3><p>The second term denies SNMP to 192.168.1.2/32:</p><pre>term reject_snmp_specific {<br>    from {<br>        destination-address {<br>            192.168.1.2/32;<br>        }<br>        protocol udp;<br>        port snmp;<br>    }<br>    then {<br>        reject;<br>    }<br>}</pre><p>This satisfies the requirement of denying SNMP queries to the physical interface.</p><h3>4. ICMP is allowed for loopback reachability</h3><p>The ping_loopback term ensures that Cisco can still ping Juniper loopback:</p><pre>term ping_loopback {<br>    from {<br>        destination-address {<br>            2.2.2.2/32;<br>        }<br>        protocol icmp;<br>    }<br>    then accept;<br>}</pre><p>This is critical because in many real environments you want monitoring reachability but not full access.</p><h3>5. Default deny at the end is mandatory</h3><p>The final term:</p><pre>term reject_else {<br>    then {<br>        reject;<br>    }<br>}</pre><p>ensures that the policy is a strict allow-list filter.</p><p>This ping validates that our config on the Juniper side is correct:</p><pre>R2(config)#do ping 2.2.2.2 source 1.1.1.1<br>Type escape sequence to abort.<br>Sending 5, 100-byte ICMP Echos to 2.2.2.2, timeout is 2 seconds:<br>Packet sent with a source address of 1.1.1.1<br>!!!!!<br>Success rate is 100 percent (5/5), round-trip min/avg/max = 4/14/24 ms<br>R2(config)#do ping 2.2.2.2<br>Type escape sequence to abort.<br>Sending 5, 100-byte ICMP Echos to 2.2.2.2, timeout is 2 seconds:<br>.....<br>Success rate is 0 percent (0/5)</pre><ul><li>When we specifysource 1.1.1.1, traffic originates from the loopback.</li><li>When we don’t specify the source, Cisco uses the outgoing interface address (192.168.1.1).</li></ul><p>The ping failing from our outgoing interface is the by-product of my config on Cisco, where even though I didn’t configure any specific source-address check for ICMP on the Juniper device, the “20 deny icmp host 2.2.2.2 host 192.168.1.1” config, which I originally applied to prevent 192.168.1.1 from pinging 2.2.2.2, is now also blocking the return ICMP traffic.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0d79677d40c0" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>