{"id":11866,"date":"2021-08-04T10:47:12","date_gmt":"2021-08-04T10:47:12","guid":{"rendered":"http:\/\/www.max-sperling.bplaced.net\/?p=11866"},"modified":"2024-02-20T11:43:41","modified_gmt":"2024-02-20T11:43:41","slug":"policy-based-routing-linux","status":"publish","type":"post","link":"http:\/\/www.max-sperling.bplaced.net\/?p=11866","title":{"rendered":"Policy-based routing (Linux)"},"content":{"rendered":"<p><strong>Classic routing<\/strong><br \/>\n&#8211; Happens based on the destination address of the ip packet<\/p>\n<p><u>Classic routing tables<\/u><\/p>\n<pre>\r\n$ ip rule list\r\n0:\tfrom all lookup local \r\n32766:\tfrom all lookup main \r\n32767:\tfrom all lookup default \r\n<\/pre>\n<p>The lookup order happens based on the priority (first column): local > main > default.<\/p>\n<hr>\n<p><strong>Policy-based routing<\/strong><br \/>\n&#8211; Allows decision making on other parameters (e.g. source address)<br \/>\n&#8211; It requires more routing tables then classic routing<\/p>\n<p><u>General workflow<\/u><\/p>\n<ol>\n<li>Add a new routing table<\/li>\n<li>Add rule(s) towards that table<\/li>\n<li>Add route(s) on that table<\/li>\n<\/ol>\n<p><u>Possible scenario<\/u><\/p>\n<pre>\r\n                       PC \/ Laptop\r\n|-----------------------------------------------------|\r\n|         Webbrowser 1               Webbrowser 2     |\r\n|       (Office content)          (Private content)   |\r\n|               |                          |          |\r\n|               |                        Proxy*       |\r\n|               |                          |          |\r\n|      Network interface 1        Network interface 2 |\r\n| (Network card, eth0, default)     (USB slot, usb0)  |\r\n|-----------------------------------------------------|\r\n                |                          |\r\n           Office LAN                  LTE modem\r\n                | \\-- Local server         |\r\n                |                          |\r\n            DSL modem                      |\r\n                |                          |\r\n                \\-----------\\ \/------------\/\r\n                             |\r\n                         Internet\r\n                             |\r\n                       Public server\r\n\r\n\r\n*) Config: Set source ip of outgoing packets to usb0 ip.\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Classic routing &#8211; Happens based on the destination address of the ip packet Classic routing tables $ ip rule list<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false},"categories":[23],"tags":[],"_links":{"self":[{"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=\/wp\/v2\/posts\/11866"}],"collection":[{"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=11866"}],"version-history":[{"count":1,"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=\/wp\/v2\/posts\/11866\/revisions"}],"predecessor-version":[{"id":16784,"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=\/wp\/v2\/posts\/11866\/revisions\/16784"}],"wp:attachment":[{"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=11866"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=11866"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=11866"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}