mirror of
https://github.com/linkedin/school-of-sre
synced 2026-01-19 15:08:03 +00:00
Deployed 52e7ed5 with MkDocs version: 1.1.2
This commit is contained in:
@@ -1269,14 +1269,14 @@
|
||||
|
||||
<h1 id="ip-routing-and-data-link-layer">IP Routing and Data Link Layer</h1>
|
||||
<p>We will dig how packets that leave the client reach the server and vice versa. When the packet reaches the IP layer, the transport layer populates source port, destination port. IP/Network layer populates destination IP(discovered from DNS) and then looks up the route to the destination IP on the routing table. </p>
|
||||
<div class="highlight"><pre><span></span><code><span class="c1">#Linux route -n command gives the default routing table</span>
|
||||
<pre><code class="language-bash">#Linux route -n command gives the default routing table
|
||||
route -n
|
||||
</code></pre></div>
|
||||
<div class="highlight"><pre><span></span><code>Kernel IP routing table
|
||||
</code></pre>
|
||||
<pre><code class="language-bash">Kernel IP routing table
|
||||
Destination Gateway Genmask Flags Metric Ref Use Iface
|
||||
<span class="m">0</span>.0.0.0 <span class="m">172</span>.17.0.1 <span class="m">0</span>.0.0.0 UG <span class="m">0</span> <span class="m">0</span> <span class="m">0</span> eth0
|
||||
<span class="m">172</span>.17.0.0 <span class="m">0</span>.0.0.0 <span class="m">255</span>.255.0.0 U <span class="m">0</span> <span class="m">0</span> <span class="m">0</span> eth0
|
||||
</code></pre></div>
|
||||
0.0.0.0 172.17.0.1 0.0.0.0 UG 0 0 0 eth0
|
||||
172.17.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth0
|
||||
</code></pre>
|
||||
<p>Here the destination IP is bitwise AND’d with the Genmask and if the answer is the destination part of the table then that gateway and interface is picked for routing. Here linkedin.com’s IP 108.174.10.10 is AND’d with 255.255.255.0 and the answer we get is 108.174.10.0 which doesn’t match with any destination in the routing table. Then Linux does an AND of destination IP with 0.0.0.0 and we get 0.0.0.0. This answer matches the default row</p>
|
||||
<p>Routing table is processed in the order of more octets of 1 set in genmask and genmask 0.0.0.0 is the default route if nothing matches.
|
||||
At the end of this operation Linux figured out that the packet has to be sent to next hop 172.17.0.1 via eth0. The source IP of the packet will be set as the IP of interface eth0.
|
||||
|
||||
Reference in New Issue
Block a user