Sunday, September 11, 2011

IP Things

So the role of the IP layer is to figure out how to `route' packets to their final destination. To make this possible, every interface on the network needs an `IP address'. An IP address consists of four numbers separated by periods, like `167.216.245.249'. Each number is between zero and 255.
Interfaces in the same network tend to have neighboring IP addresses. For example, `167.216.245.250' sits right next to the machine with the IP address `167.216.245.249'. Remember also that a router is a node with interfaces on more than one network, so the router will have one IP address for each interface.

So the Linux Kernel's IP layer keeps a table of different `routes', describing how to get to various groups of IP addresses. The simplest of these is called a `default route': if the IP layer doesn't know better, this is where it will send a packet onwards to. You can see a list of routes using `/sbin/route'.
Routes can either point to a link, or a particular node which is connected to another network. For example, when you dial up to the ISP, your default route will point to the modem link, because that's where the entire world is.

  Rusty's              ISP's  ~~~~~~~~~~~~ 
   Modem               Modem {            }
       o------------------o { The Internet }
                             {            }
                              ~~~~~~~~~~~~  
But if you have a permanent machine on your network which connects to the outside world, it's a bit more complicated. In the diagram below, my machine can talk directly to Tridge and Paul's machines, and to the firewall, but it needs to know that packets heading the rest of the world need to go to the firewall, which will pass them on. This means that you have two routes: one which says `if it's on my network, just send it straight there' and then a default route which says `otherwise, send it to the firewall'.

                         o  Tridge's
                         |    Work Machine      ~~~~~~~~~~~~
  Rusty's                |                     {            } 
   Work Machine o--------+-----------------o--{ The Internet }
                         |            Firewall {            } 
                         |                      ~~~~~~~~~~~~
                         o  Paul's
                              Work Machine

No comments:

Post a Comment