The Route Table#
Operating systems store information about the network around them inside a "route table". Network routers also have this table too and it'll look slightly different for them.
This route table contains everything your host computers needs to know to send information from itself to other hosts. Here's an example route table:
Network Destination | Netmask | Gateway | Interface |
---|---|---|---|
0.0.0.0 | 0.0.0.0 | 192.168.1.1 | 192.168.1.10 |
127.0.0.1 | 255.0.0.0 | 127.0.0.1 | 127.0.0.1 |
192.168.2.0 | 255.255.255.0 | 192.168.1.1 | 192.168.1.10 |
In this table we're defining the rules for moving traffic between networks.
The most interesting of these rules, and one you'll see often, is the 0.0.0.0
rule. It's commonly seen written as 0.0.0.0/0
. This rule catches all traffic that doesn't match the other rules. This is how you're able to talk to the Internet, because 8.8.8.8/32
doesn't match any other rule, so the data is sent to the default gateway which then decides how-to get your traffic to 8.8.8.8/32
.
We have our localhost
in there too: 127.0.0.1
. This is called the "loopback device" and it refers to your own host. This cannot be routed outside of your own system.
Finally, we have a rule for the other network 192.168.2.0/24
(255.255.255.0
is another way of saying /24
, remember). Technically not required as 0.0.0.0/0
would catch this, but for our purposes it demonstrates a point.