{"id":88,"date":"2018-05-13T18:01:19","date_gmt":"2018-05-13T18:01:19","guid":{"rendered":"https:\/\/hegars83.wordpress.com\/?p=88"},"modified":"2018-06-20T20:31:17","modified_gmt":"2018-06-20T10:31:17","slug":"network-iproute2","status":"publish","type":"post","link":"https:\/\/blog.hegars.com\/?p=88","title":{"rendered":"Iproute2 &#8211; Route Tables"},"content":{"rendered":"<p>https:\/\/www.thomas-krenn.com\/en\/wiki\/Two_Default_Gateways_on_One_System<\/p>\n<h2>Add new route table<\/h2>\n<p>\/etc\/iproute2\/rt_tables<br \/>\n+ 1 rt2<\/p>\n<h2>Add the routes and rules to the route table<\/h2>\n<p>ip route add 1.2.3.0\/24 dev ens7 src 1.2.3.4 table rt2<br \/>\nip route add default via 1.2.3.254 dev ens7 table rt2<br \/>\nip rule add from 1.2.3.4\/32 table rt2<br \/>\nip rule add to 1.2.3.4\/32 table rt2<\/p>\n<h2>Check it out<\/h2>\n<p>ip route list table rt2<br \/>\nip rule show<\/p>\n<h2>Add startup script<\/h2>\n<p>\/etc\/network\/interface<br \/>\nto interface<br \/>\npost-up ip route add 1.2.3.0\/24 dev ens7 src 1.2.3.4 table rt2<br \/>\npost-up ip route add default via 1.2.3.254 dev ens7 table rt2<br \/>\npost-up ip rule add from 1.2.3.4\/32 table rt2<br \/>\npost-up ip rule add to 1.2.3.4\/32 table rt2<\/p>\n<p>https:\/\/wiki.linuxfoundation.org\/networking\/iproute2_examples<\/p>\n<h2>Traceroute with interface and source<\/h2>\n<p>root@debtest:~# traceroute -i ens7 -s 10.0.0.3 192.168.1.150<br \/>\ntraceroute to 192.168.1.150 (192.168.1.150), 30 hops max, 60 byte packets<br \/>\n1 10.0.0.10 (10.0.0.10) 1.348 ms 1.327 ms 1.300 ms<br \/>\n2 172.18.8.253 (172.18.8.253) 13.621 ms 13.641 ms 13.638 ms<br \/>\n3 172.18.1.2 (172.18.1.2) 25.842 ms 25.744 ms 25.798 ms<br \/>\n4 192.168.1.150 (192.168.1.150) 30.148 ms 30.147 ms 30.131 ms<\/p>\n<h2>Ping from source IP<\/h2>\n<p>root@debtest:~# ping -I 10.99.0.3 192.168.1.150<br \/>\nPING 192.168.1.150 (192.168.1.150) from 10.99.0.3 : 56(84) bytes of data.<br \/>\n64 bytes from 192.168.1.150: icmp_seq=1 ttl=125 time=34.7 ms<br \/>\n64 bytes from 192.168.1.150: icmp_seq=2 ttl=125 time=28.3 ms<br \/>\n64 bytes from 192.168.1.150: icmp_seq=3 ttl=125 time=24.0 ms<br \/>\n64 bytes from 192.168.1.150: icmp_seq=4 ttl=125 time=22.8 ms<br \/>\n^C<br \/>\n&#8212; 192.168.1.150 ping statistics &#8212;<br \/>\n4 packets transmitted, 4 received, 0% packet loss, time 3004ms<br \/>\nrtt min\/avg\/max\/mdev = 22.820\/27.502\/34.745\/4.663 ms<\/p>\n","protected":false},"excerpt":{"rendered":"<p>https:\/\/www.thomas-krenn.com\/en\/wiki\/Two_Default_Gateways_on_One_System Add new route table \/etc\/iproute2\/rt_tables + 1 rt2 Add the routes and rules to the route table ip route add 1.2.3.0\/24 dev ens7 src 1.2.3.4 table rt2 ip route add default via 1.2.3.254 dev ens7 table rt2 ip rule add from 1.2.3.4\/32 table rt2 ip rule add to 1.2.3.4\/32 table rt2 Check it out [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"site-container-style":"default","site-container-layout":"default","site-sidebar-layout":"default","disable-article-header":"default","disable-site-header":"default","disable-site-footer":"default","disable-content-area-spacing":"default","footnotes":""},"categories":[6,2],"tags":[],"_links":{"self":[{"href":"https:\/\/blog.hegars.com\/index.php?rest_route=\/wp\/v2\/posts\/88"}],"collection":[{"href":"https:\/\/blog.hegars.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.hegars.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.hegars.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.hegars.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=88"}],"version-history":[{"count":4,"href":"https:\/\/blog.hegars.com\/index.php?rest_route=\/wp\/v2\/posts\/88\/revisions"}],"predecessor-version":[{"id":233,"href":"https:\/\/blog.hegars.com\/index.php?rest_route=\/wp\/v2\/posts\/88\/revisions\/233"}],"wp:attachment":[{"href":"https:\/\/blog.hegars.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=88"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.hegars.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=88"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.hegars.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=88"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}