Routing

We have managed to communicate between two machines connected on our network, but how did helium know where to send and receive information about hydrogen? The answer lies in a mechanism named “routing.”

The kernel maintains a structure known as a “routing table.” This contains information about where packets need to be sent, or routed, to get to their destination. We can view the routing table with netstat:

hydrogen# netstat -rn
Routing Table:
  Destination        Gateway       Flags  Ref   Use   Interface
----------------- ---------------- ----- ----- ------ ---------
192.168.22.0      192.168.22.1     U        3      5  hme0
127.0.0.1         127.0.0.1        UH       0      2  lo0
hydrogen#

This shows us that any packets destined for the 192.168.22.0 network will be routed through a gateway with an IP address of 192.168.22.1 (i.e., the network interface that we defined earlier). It also shows that the loopback interface is routed, again through itself.

This is a fairly simple implementation of a routing table, but we will see how it can be expanded later.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset