{"id":133,"date":"2025-03-19T23:34:44","date_gmt":"2025-03-19T23:34:44","guid":{"rendered":"https:\/\/www.bgptrace.com\/blog\/?p=133"},"modified":"2025-03-19T23:40:12","modified_gmt":"2025-03-19T23:40:12","slug":"test-with-ecmp-on-linux","status":"publish","type":"post","link":"https:\/\/www.bgptrace.com\/blog\/?p=133","title":{"rendered":"Test with ECMP on Linux"},"content":{"rendered":"\n<p>I was reading an article about ECMP (Equal Cost Multipath) for traffic load sharing, and it brought back memories of my previous traffic engineering tests. It seems simple at first glance, but it&#8217;s actually more complex\u2014especially when it comes to policy-based routing.<\/p>\n\n\n\n<p>The challenge lies in determining traffic redirection and sharing in a session-wise connection, whether with or without NAT, across multiple links or circuits with different latencies. There&#8217;s also the complication of firewall interception with asymmetric return traffic. These factors make achieving ideal traffic load sharing quite difficult.<\/p>\n\n\n\n<p>Of course, if tunneling is involved, things get simpler. It essentially blinds both endpoints and allows you to add two routes with the same metric in overlay routing. However, it doesn\u2019t clearly explain why load-sharing performance behaves the way it does.<\/p>\n\n\n\n<p>What about service enhancement? If the primary link becomes congested, should the secondary link pick up some of the traffic? That\u2019s not exactly round-robin behavior\u2014it would require active measurement and monitoring of the links. Maintaining session flow on the primary link while redirecting new flows to the secondary link sounds ideal, but it&#8217;s difficult to implement. For MPLS-TE, that&#8217;s straightforward\u2014but what if you have two internet links, like one DIA (Direct Internet Access) and one mobile network? How would you handle that?<\/p>\n\n\n\n<p>Well, just for fun, I haven\u2019t done any serious measurements yet. But after setting up load sharing on my node, it seems to be working\u2014though I haven\u2019t really thought through the next steps. Running a Speedtest shows that the flows (by ports) are transmitting separately. Hmm\u2026 not ideal, but not bad either. But what about other applications? If they&#8217;re using two different IP addresses for outgoing traffic\u2014ahhhh\u2026<\/p>\n\n\n\n<p>Let\u2019s discuss this, bro.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p><strong>Enable 2 Multipath load sharing<\/strong><br>sudo ip route add default scope global \\<br>nexthop via 192.168.X.X dev XXX weight 1 \\<br>nexthop via 192.168.X.X dev XXX weight 1<\/p>\n\n\n\n<p><strong>For multipath routing, disabling connection tracking for locally-generated traffic helps<\/strong><br>sudo sysctl -w net.netfilter.nf_conntrack_tcp_loose=0<\/p>\n\n\n\n<p><strong>Enable Layer 4 Hashing<\/strong><br>sudo sysctl -w net.ipv4.fib_multipath_hash_policy=1<\/p>\n\n\n\n<p><strong>Enable IP Forwarding<\/strong><br>sudo sysctl -w net.ipv4.ip_forward=1<\/p>\n\n\n\n<p><strong>Force More Aggressive Flow-Based Balancing:<br>Set rp_filter to 0 (disable reverse path filtering) so the kernel won\u2019t drop asymmetric traffic<\/strong><br>sudo sysctl -w net.ipv4.conf.all.rp_filter=0<\/p>\n\n\n\n<p><strong>Flush all route cache<\/strong><br>sudo ip route flush cache<\/p>\n\n\n\n<p>#ECMP #Linux #Internet #Routing #IP #Firewall #Tunneling #MPLS #trafficEngineering #ChatGPT<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I was reading an article about ECMP (Equal Cost Multipath) for traffic load sharing, and it brought back memories of my previous traffic engineering tests. It seems simple at first glance, but it&#8217;s actually more complex\u2014especially when it comes to policy-based routing. The challenge lies in determining traffic redirection and sharing in a session-wise connection, &hellip; <a href=\"https:\/\/www.bgptrace.com\/blog\/?p=133\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Test with ECMP on Linux&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[39,139,9,12,140,6,141,25,10,112,137],"class_list":["post-133","post","type-post","status-publish","format-standard","hentry","category-internet","tag-chatgpt","tag-ecmp","tag-internet","tag-ip","tag-loadsharing","tag-measurement","tag-pbr","tag-ping","tag-routing","tag-speedtest","tag-test"],"_links":{"self":[{"href":"https:\/\/www.bgptrace.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/133","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.bgptrace.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.bgptrace.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.bgptrace.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.bgptrace.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=133"}],"version-history":[{"count":3,"href":"https:\/\/www.bgptrace.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/133\/revisions"}],"predecessor-version":[{"id":137,"href":"https:\/\/www.bgptrace.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/133\/revisions\/137"}],"wp:attachment":[{"href":"https:\/\/www.bgptrace.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=133"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.bgptrace.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=133"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.bgptrace.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=133"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}