Editorial pass through Routing Basics.
Add name to table. Sponsored by: iXsystems
This commit is contained in:
parent
7ada9725e0
commit
61eb3b5669
Notes:
svn2git
2020-12-08 03:00:23 +00:00
svn path=/head/; revision=44142
1 changed files with 53 additions and 146 deletions
|
@ -132,7 +132,7 @@ Routing tables
|
|||
|
||||
Internet:
|
||||
Destination Gateway Flags Refs Use Netif Expire
|
||||
default outside-gw UGSc 37 418 em0
|
||||
default outside-gw UGS 37 418 em0
|
||||
localhost localhost UH 0 181 lo0
|
||||
test0 0:e0:b5:36:cf:4f UHLW 5 63288 re0 77
|
||||
10.20.30.255 link#1 UHLW 1 2421
|
||||
|
@ -148,33 +148,37 @@ host2.example.com link#1 UC 0 0
|
|||
<varlistentry>
|
||||
<term>default</term>
|
||||
<listitem>
|
||||
<para>The first line specifies the <literal></literal>
|
||||
<para>The first route in this table specifies the <literal>default</literal>
|
||||
route. When the local system needs to make a connection to a
|
||||
remote host, it checks the routing table to determine if a
|
||||
known path exists. If the remote host falls into a subnet
|
||||
that it knows how to reach, the system checks to see if it
|
||||
can connect using that interface.</para>
|
||||
known path exists. If the remote host matches an entry in the
|
||||
table, the system checks to see if it
|
||||
can connect using the interface specified in that entry.</para>
|
||||
|
||||
<para>If all known paths fail, the system has one last option:
|
||||
the <quote>default</quote> route. This route is a special
|
||||
type of gateway route (usually the only one present in the
|
||||
system), and is always marked with a <literal>c</literal> in
|
||||
the flags field. For hosts on a local area network, this
|
||||
gateway is set to the system which has a direct connection to
|
||||
the Internet.</para>
|
||||
<para>If the destination does not match an entry, or if all known
|
||||
paths fail, the system uses the entry for the
|
||||
default route. For hosts on a local area network, the
|
||||
<literal>Gateway</literal> field in the default route is set
|
||||
to the system which has a direct connection to
|
||||
the Internet. When reading this entry, verify that the
|
||||
<literal>Flags</literal> column indicates that the gateway is
|
||||
usable (<literal>UG</literal>).</para>
|
||||
|
||||
<para>The default route for a machine which itself is
|
||||
functioning as the gateway to the outside world will be the
|
||||
gateway machine at the Internet Service Provider
|
||||
(<acronym>ISP</acronym>).</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>localhost</term>
|
||||
<listitem>
|
||||
<para>The second line is the <literal>localhost</literal> route.
|
||||
The interface (<literal>Netif</literal> column) that this
|
||||
routing table specifies to use for
|
||||
<literal>localhost</literal> is <filename>lo0</filename>,
|
||||
also known as the loopback device. This says to keep all
|
||||
traffic for this destination internal, rather than sending it
|
||||
<para>The second route is the <literal>localhost</literal> route.
|
||||
The interface specified in the <literal>Netif</literal> column
|
||||
for <literal>localhost</literal> is <filename>lo0</filename>,
|
||||
also known as the loopback device. This indicates that all
|
||||
traffic for this destination should be internal, rather than sending it
|
||||
out over the network.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
@ -201,8 +205,8 @@ host2.example.com link#1 UC 0 0
|
|||
<varlistentry>
|
||||
<term>subnet</term>
|
||||
<listitem>
|
||||
<para>&os; will add subnet routes for the local subnet.
|
||||
<systemitem class="ipaddress">10.20.30.255</systemitem> is the
|
||||
<para>&os; will automatically add subnet routes for the local subnet.
|
||||
In this example, <systemitem class="ipaddress">10.20.30.255</systemitem> is the
|
||||
broadcast address for the subnet <systemitem
|
||||
class="ipaddress">10.20.30</systemitem> and <systemitem
|
||||
class="fqdomainname">example.com</systemitem> is the domain
|
||||
|
@ -231,7 +235,7 @@ host2.example.com link#1 UC 0 0
|
|||
<literal>=></literal> symbol after the
|
||||
<filename>lo0</filename> interface says that an alias has been
|
||||
set in addition to the loopback address. Such routes only
|
||||
show up on the host that supports the alias; all other hosts
|
||||
show up on the host that supports the alias and all other hosts
|
||||
on the local network will have a
|
||||
<literal>link#1</literal> line for such routes.</para>
|
||||
</listitem>
|
||||
|
@ -248,177 +252,80 @@ host2.example.com link#1 UC 0 0
|
|||
</variablelist>
|
||||
|
||||
<para>Various attributes of each route can be seen in
|
||||
the <literal>Flags</literal> column. Below is a short table
|
||||
of some of these flags and their meanings:</para>
|
||||
the <literal>Flags</literal> column. <xref linkend="routeflags"/>
|
||||
summarizes some of these flags and their meanings:</para>
|
||||
|
||||
<table xml:id="routeflags" frame="none" pgwide="1">
|
||||
<title>Commonly Seen Routing Table Flags</title>
|
||||
|
||||
<informaltable frame="none" pgwide="1">
|
||||
<tgroup cols="2">
|
||||
<colspec colwidth="1*"/>
|
||||
<colspec colwidth="4*"/>
|
||||
<thead>
|
||||
<row>
|
||||
<entry>Command</entry>
|
||||
<entry>Purpose</entry>
|
||||
</row>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<row>
|
||||
<entry>U</entry>
|
||||
<entry>Up: The route is active.</entry>
|
||||
<entry>The route is active (up).</entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry>H</entry>
|
||||
<entry>Host: The route destination is a single
|
||||
<entry>The route destination is a single
|
||||
host.</entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry>G</entry>
|
||||
<entry>Gateway: Send anything for this destination on to
|
||||
this remote system, which will figure out from there
|
||||
<entry>Send anything for this destination on to
|
||||
this gateway, which will figure out from there
|
||||
where to send it.</entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry>S</entry>
|
||||
<entry>Static: This route was configured manually, not
|
||||
automatically generated by the system.</entry>
|
||||
<entry>This route was statically configured.</entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry>C</entry>
|
||||
<entry>Clone: Generates a new route based upon this
|
||||
<entry>Clones a new route based upon this
|
||||
route for machines to connect to. This type of route
|
||||
is normally used for local networks.</entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry>W</entry>
|
||||
<entry>WasCloned: Indicated a route that was
|
||||
<entry>The route was
|
||||
auto-configured based upon a local area network
|
||||
(Clone) route.</entry>
|
||||
(clone) route.</entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry>L</entry>
|
||||
<entry>Link: Route involves references to Ethernet
|
||||
<entry>Route involves references to Ethernet (link)
|
||||
hardware.</entry>
|
||||
</row>
|
||||
</tbody>
|
||||
</tgroup>
|
||||
</informaltable>
|
||||
|
||||
<para>The default route for a machine which itself is
|
||||
functioning as the gateway to the outside world, will be the
|
||||
gateway machine at the Internet Service Provider
|
||||
(<acronym>ISP</acronym>).</para>
|
||||
</table>
|
||||
|
||||
<para>This example is a common configuration for a default
|
||||
route:</para>
|
||||
|
||||
<mediaobject>
|
||||
<imageobject>
|
||||
<imagedata fileref="advanced-networking/net-routing"/>
|
||||
</imageobject>
|
||||
|
||||
<textobject>
|
||||
<literallayout class="monospaced">
|
||||
[Local2] <--ether--> [Local1] <--PPP--> [ISP-Serv] <--ether--> [T1-GW]</literallayout>
|
||||
</textobject>
|
||||
</mediaobject>
|
||||
|
||||
<para>The hosts <systemitem>Local1</systemitem> and
|
||||
<systemitem>Local2</systemitem> are on the local network.
|
||||
<systemitem>Local1</systemitem> is connected to an
|
||||
<acronym>ISP</acronym> using a
|
||||
<acronym>PPP</acronym> connection. This
|
||||
<acronym>PPP</acronym> server is connected through a local
|
||||
area network to another gateway computer through an external
|
||||
interface to the <acronym>ISP</acronym>.</para>
|
||||
|
||||
<para>The default routes for each machine will be:</para>
|
||||
|
||||
<informaltable frame="none" pgwide="1">
|
||||
<tgroup cols="3">
|
||||
<thead>
|
||||
<row>
|
||||
<entry>Host</entry>
|
||||
<entry>Default Gateway</entry>
|
||||
<entry>Interface</entry>
|
||||
</row>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<row>
|
||||
<entry>Local2</entry>
|
||||
<entry>Local1</entry>
|
||||
<entry>Ethernet</entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry>Local1</entry>
|
||||
<entry>T1-GW</entry>
|
||||
<entry>PPP</entry>
|
||||
</row>
|
||||
</tbody>
|
||||
</tgroup>
|
||||
</informaltable>
|
||||
|
||||
<para>A common question is <quote>Why is
|
||||
<systemitem>T1-GW</systemitem> configured as the default
|
||||
gateway for <systemitem>Local1</systemitem>, rather than the
|
||||
<acronym>ISP</acronym> server it is connected
|
||||
to?</quote>.</para>
|
||||
|
||||
<para>Since the <acronym>PPP</acronym> interface is using an
|
||||
address on the <acronym>ISP</acronym>'s local network for the
|
||||
local side of the connection, routes for any other machines on
|
||||
the <acronym>ISP</acronym>'s local network will be
|
||||
automatically generated. The system already knows how to
|
||||
reach the <systemitem>T1-GW</systemitem> machine, so there is
|
||||
no need for the intermediate step of sending traffic to the
|
||||
<acronym>ISP</acronym>'s server.</para>
|
||||
|
||||
<para>It is common to use the address <systemitem
|
||||
class="ipaddress">X.X.X.1</systemitem> as the gateway
|
||||
address for the local network. So, if the local class C
|
||||
address space is <systemitem
|
||||
class="ipaddress">10.20.30</systemitem> and the
|
||||
<acronym>ISP</acronym> is using <systemitem
|
||||
class="ipaddress">10.9.9</systemitem>, the default routes
|
||||
would be:</para>
|
||||
|
||||
<informaltable frame="none" pgwide="1">
|
||||
<tgroup cols="2">
|
||||
<thead>
|
||||
<row>
|
||||
<entry>Host</entry>
|
||||
<entry>Default Route</entry>
|
||||
</row>
|
||||
</thead>
|
||||
<tbody>
|
||||
<row>
|
||||
<entry>Local2 (10.20.30.2)</entry>
|
||||
<entry>Local1 (10.20.30.1)</entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry>Local1 (10.20.30.1, 10.9.9.30)</entry>
|
||||
<entry>T1-GW (10.9.9.1)</entry>
|
||||
</row>
|
||||
</tbody>
|
||||
</tgroup>
|
||||
</informaltable>
|
||||
|
||||
<para>The default route can be easily defined in
|
||||
<filename>/etc/rc.conf</filename>. In this example, on
|
||||
<systemitem>Local2</systemitem>, add the following line to
|
||||
<filename>/etc/rc.conf</filename>:</para>
|
||||
<para>On a &os; system, the default route can defined in
|
||||
<filename>/etc/rc.conf</filename> by specifying the
|
||||
<acronym>IP</acronym> address of the default gateway:</para>
|
||||
|
||||
<programlisting>defaultrouter="10.20.30.1"</programlisting>
|
||||
|
||||
<para>It is also possible to add the route directly using
|
||||
&man.route.8;:</para>
|
||||
<para>It is also possible to manually add the route using
|
||||
<command>route</command>:</para>
|
||||
|
||||
<screen>&prompt.root; <userinput>route add default 10.20.30.1</userinput></screen>
|
||||
|
||||
<para>For more information on manual manipulation of network
|
||||
<para>Note that manually added routes will not survive a reboot.
|
||||
For more information on manual manipulation of network
|
||||
routing tables, refer to &man.route.8;.</para>
|
||||
</sect2>
|
||||
|
||||
|
|
Loading…
Reference in a new issue