To illustrate different aspects of routing, we will use
the following example which is the output of the command
netstat -r
:
Destination Gateway Flags Refs Use Netif Expire
default outside-gw UGSc 37 418 ppp0
localhost localhost UH 0 181 lo0
test0 0:e0:b5:36:cf:4f UHLW 5 63288 ed0 77
10.20.30.255 link#1 UHLW 1 2421
foobar.com link#1 UC 0 0
host1 0:e0:a8:37:8:1e UHLW 3 4601 lo0
host2 0:e0:a8:37:8:1e UHLW 0 5 lo0 =>
host2.foobar.com link#1 UC 0 0
224 link#1 UC 0 0
The first two lines specify the default route (which we
will cover in the next section) and the localhost
route.
The interface (Netif
column) that it specifies to use
for localhost
is lo0
, also known as the
loopback device. This says to keep all traffic for this
destination internal, rather than sending it out over the
LAN, since it will only end up back where it started
anyway.
The next thing that stands out are the
``0:e0:...
'' addresses. These are ethernet
hardware addresses. FreeBSD will automatically identify any
hosts (test0
in the example) on the local ethernet and
add a route for that host, directly to it over the ethernet
interface, ed0
. There is also a timeout
(Expire
column) associated with this type of route,
which is used if we fail to hear from the host in a
specific amount of time. In this case the route will be
automatically deleted. These hosts are identified using a
mechanism known as RIP (Routing Information Protocol),
which figures out routes to local hosts based upon a
shortest path determination.
FreeBSD will also add subnet routes for the local subnet
(10.20.30.255
is the broadcast address for the subnet
10.20.30
, and foobar.com
is the domain name
associated with that subnet). The designation link#1
refers to the first ethernet card in the machine. You'll
notice no additional interface is specified for those.
Both of these groups (local network hosts and local
subnets) have their routes automatically configured by a
daemon called routed
. If this is not run, then only
routes which are statically defined (ie. entered
explicitly) will exist.
The host1
line refers to our host, which it knows by
ethernet address. Since we are the sending host, FreeBSD
knows to use the loopback interface (lo0
) rather than
sending it out over the ethernet interface.
The two host2
lines are an example of what happens
when we use an ifconfig alias (see the section of ethernet
for reasons why we would do this). The =>
symbol after the lo0
interface says that not only are
we using the loopback (since this is address also refers to
the local host), but specifically it is an alias. Such
routes only show up on the host that supports the alias;
all other hosts on the local network will simply have a
link#1
line for such.
The final line (destination subnet 224
) deals with
MultiCasting, which will be covered in a another section.
The other column that we should talk about are the
Flags
. Each route has different attributes that are
described in the column. Below is a short table of some of
these flags and their meanings:
Up: The route is active.
Host: The route destination is a single host.
Gateway: Send anything for this destination on to this remote system, which will figure out from there where to send it.
Static: This route was configured manually, not automatically generated by the system.
Clone: Generates a new route based upon this route for machines we connect to. This type of route is normally used for local networks.
WasCloned Indicated a route that was auto-configured based upon a local area network (Clone) route.
Link: Route involves references to ethernet hardware.