[networking-guide] master: Improve: Configuring Static Routes in ifcfg files (87b16bf)

stephenw at fedoraproject.org stephenw at fedoraproject.org
Fri Jan 2 07:54:17 UTC 2015


Repository : http://git.fedorahosted.org/cgit/docs/networking-guide.git

On branch  : master

>---------------------------------------------------------------

commit 87b16bff2f164da0a49674b586966facc5c65bf3
Author: Stephen Wadeley <swadeley at redhat.com>
Date:   Thu Jan 1 18:28:28 2015 +0100

    Improve: Configuring Static Routes in ifcfg files


>---------------------------------------------------------------

 en-US/Configure_Networking.xml |   46 +++++++++++++++------------------------
 1 files changed, 18 insertions(+), 28 deletions(-)

diff --git a/en-US/Configure_Networking.xml b/en-US/Configure_Networking.xml
index 11c3c80..5f04c3e 100644
--- a/en-US/Configure_Networking.xml
+++ b/en-US/Configure_Networking.xml
@@ -1691,12 +1691,11 @@ The address assignment of a specific device can be viewed as follows:
 <section id="sec-Configuring_Static_Routes_in_ifcfg_files">
 <title>Configuring Static Routes in ifcfg files</title>
 <para>
-Static routes set using <application>ip</application> commands on the command line will be lost if the system is shutdown or restarted. To configure static routes to be persistent after a system restart, they must be placed in per-interface configuration files in the <filename class="directory">/etc/sysconfig/network-scripts/</filename> directory. The file name should be of the format <filename>route-<replaceable>ethX</replaceable></filename>. There are two types of commands to use in the configuration files; <application>ip</application> commands as explained in <xref linkend="bh-networkscripts-static-routes-ip-command" /> and the <firstterm>Network/Netmask</firstterm> format as explained in <xref linkend="bh-networkscripts-static-routes-network-netmask-directives" />.
+Static routes set using <application>ip</application> commands on the command line will be lost if the system is shutdown or restarted. To configure static routes to be persistent after a system restart, they must be placed in per-interface configuration files in the <filename class="directory">/etc/sysconfig/network-scripts/</filename> directory. The file name should be of the format <filename>route-<replaceable>ifname</replaceable></filename>. There are two types of commands to use in the configuration files; <application>ip</application> commands as explained in <xref linkend="sec-networkscripts-static-routes-ip-command" /> and the <firstterm>Network/Netmask</firstterm> format as explained in <xref linkend="sec-networkscripts-static-routes-network-netmask-directives" />.
 </para>
 
-<bridgehead id="bh-networkscripts-static-routes-ip-command">
-      Static Routes Using the IP Command Arguments Format
-    </bridgehead>
+<section id="sec-networkscripts-static-routes-ip-command">
+      <title>Static Routes Using the IP Command Arguments Format</title>
     <para>
       If required in a per-interface configuration file, for example <filename>/etc/sysconfig/network-scripts/route-eth0</filename>, define a route to a default gateway on the first line. This is only required if the gateway is not set via <systemitem class="protocol">DHCP</systemitem> and is not set globally in the <filename>/etc/sysconfig/network</filename> file:
     </para>
@@ -1705,33 +1704,32 @@ Static routes set using <application>ip</application> commands on the command li
       where <replaceable>192.168.1.1</replaceable> is the <systemitem class="protocol">IP</systemitem> address of the default gateway. The <replaceable>interface</replaceable> is the interface that is connected to, or can reach, the default gateway. The <option>dev</option> option can be omitted, it is optional. Note that this setting takes precedence over a setting in the <filename>/etc/sysconfig/network</filename> file.
     </para>
     <para>
-      If a route to a remote network is required, define a static route. Each line is parsed as an individual route:
+      If a route to a remote network is required, a static route can be specified as follows. Each line is parsed as an individual route:
     </para>
-    <synopsis><replaceable>10.10.10.0/24</replaceable> via <replaceable>192.168.1.1</replaceable> <option>dev</option> <replaceable>interface</replaceable></synopsis>
+    <synopsis><replaceable>10.10.10.0/24</replaceable> via <replaceable>192.168.1.1</replaceable> <optional><option>dev</option> <replaceable>interface</replaceable></optional></synopsis>
     <para>
-      where <replaceable>10.10.10.0/24</replaceable> is the network address and netmask of the remote network or host. <replaceable>192.168.1.1</replaceable> and <replaceable>interface</replaceable> are the <systemitem class="protocol">IP</systemitem> address and interface for the gateway leading to the remote network. Add as many static routes as required.
+      where <replaceable>10.10.10.0/24</replaceable> is the network address and prefix length of the remote or destination network. The address <replaceable>192.168.1.1</replaceable> is the <systemitem class="protocol">IP</systemitem> address leading to the remote network. It is preferably the <firstterm>next hop address</firstterm> but the address of the exit interface will work. The <quote>next hop</quote> means the remote end of a link, for example a gateway or router. The <option>dev</option> option can be used to specify the exit interface <replaceable>interface</replaceable> but it is not required. Add as many static routes as required.
     </para>
     <para>
-      The following is a sample <filename>route-eth0</filename> file using the <application>ip</application> command arguments format. The default gateway is <systemitem class="ipaddress">192.168.0.1</systemitem>, interface <interface>eth0</interface> and a leased line or WAN connection is available at <systemitem class="ipaddress">192.168.0.10</systemitem>. The two static routes are for reaching the <systemitem class="ipaddress">10.10.10.0/24</systemitem> network and the <systemitem class="ipaddress">172.16.1.10/32</systemitem> host:
+      The following is an example of a <filename>route-<replaceable>interface</replaceable></filename> file using the <application>ip</application> command arguments format. The default gateway is <systemitem class="ipaddress">192.168.0.1</systemitem>, interface <interface>eth0</interface> and a leased line or WAN connection is available at <systemitem class="ipaddress">192.168.0.10</systemitem>. The two static routes are for reaching the <systemitem class="ipaddress">10.10.10.0/24</systemitem> network and the <systemitem class="ipaddress">172.16.1.10/32</systemitem> host:
     </para>
     <screen>default via 192.168.0.1 dev eth0
 10.10.10.0/24 via 192.168.0.10 dev eth0
 172.16.1.10/32 via 192.168.0.10 dev eth0</screen>
     <para>
-      Static routes should only be configured for remote networks or hosts, that is to say, networks or hosts that are not directly attached to the system. Packets going to the <systemitem class="ipaddress">192.168.0.0/24</systemitem> network will be directed out the interface attached to that network. Packets to unknown, remote, networks will use the default gateway. Below is an example of setting static routes to a different network, on a machine in the <systemitem class="ipaddress">192.168.0.0/24</systemitem> network. The example machine has an <interface>eth0</interface> interface in the <systemitem class="ipaddress">192.168.0.0/24</systemitem> network, and an <interface>eth1</interface> interface (with address <systemitem class="ipaddress">10.10.10.1</systemitem>) in the <systemitem class="ipaddress">10.10.10.0/24</systemitem> network:
-    </para>
-    <screen>10.10.10.0/24 via 10.10.10.1 dev eth1</screen>
+    In the above example, packets going to the local <systemitem class="ipaddress">192.168.0.0/24</systemitem> network will be directed out the interface attached to that network. Packets going to the <systemitem class="ipaddress">10.10.10.0/24</systemitem> network and <systemitem class="ipaddress">172.16.1.10/32</systemitem> host will be directed to <systemitem class="ipaddress">192.168.0.10</systemitem>. Packets to unknown, remote, networks will use the default gateway therefore static routes should only be configured for remote networks or hosts if the default route is not suitable. Remote in this context means any networks or hosts that are not directly attached to the system.</para>
+   <!-- Adding in this comment as per [Bug 446997] Static routes and default gateway are interface -specific ? -->
     <para>
     Specifying an exit interface is optional. It can be useful if you want to force traffic out of a specific interface. For example, in the case of a VPN, you can force traffic to a remote network to pass through a <interface>tun0</interface> interface even when the interface is in a different subnet to the destination network.
       </para>
     <important>
       <title>Duplicate default gateways</title>
       <para>
-        If the default gateway is already assigned by <systemitem class="protocol">DHCP</systemitem>, the <application>ip</application> command arguments format can cause one of two errors during start-up, or when bringing up an interface from the down state using the <command>ifup</command> command: "RTNETLINK answers: File exists" or 'Error: either "to" is a duplicate, or "<replaceable>X.X.X.X</replaceable>" is a garbage.', where <replaceable>X.X.X.X</replaceable> is the gateway, or a different <systemitem class="protocol">IP</systemitem> address. These errors can also occur if you have another route to another network using the default gateway. Both of these errors are safe to ignore.
-      </para>
+        If the default gateway is already assigned by <systemitem class="protocol">DHCP</systemitem> and if the same gateway with the same metric is specified in a configuration file, an error during start-up, or when bringing up an interface, will occur. The follow error message may be shown: "RTNETLINK answers: File exists". This error may be ignored.</para>
     </important>
-    <bridgehead id="bh-networkscripts-static-routes-network-netmask-directives">
-      Network/Netmask Directives Format</bridgehead>
+    </section>
+    <section id="sec-networkscripts-static-routes-network-netmask-directives">
+      <title>Network/Netmask Directives Format</title>
     <para>
       You can also use the network/netmask directives format for <filename>route-<replaceable>interface</replaceable></filename> files. The following is a template for the network/netmask format, with instructions following afterwards:
     </para>
@@ -1758,26 +1756,18 @@ Static routes set using <application>ip</application> commands on the command li
       </listitem>
     </itemizedlist>
     <para>
-      The following is a sample <filename>route-eth0</filename> file using the network/netmask directives format. The default gateway is <systemitem class="ipaddress">192.168.0.1</systemitem>, interface <interface>eth0</interface>. The two static routes are for reaching the <systemitem class="ipaddress">10.10.10.0/24</systemitem> and <systemitem class="ipaddress">172.16.1.0/24</systemitem> networks. This example is not necessary as traffic trying to reach a remote network or host would use the default gateway anyway:
+      The following is an example of a <filename>route-<replaceable>interface</replaceable></filename> file using the network/netmask directives format. The default gateway is <systemitem class="ipaddress">192.168.0.1</systemitem> but a leased line or WAN connection is available at <systemitem class="ipaddress">192.168.0.10</systemitem>. The two static routes are for reaching the <systemitem class="ipaddress">10.10.10.0/24</systemitem> and <systemitem class="ipaddress">172.16.1.0/24</systemitem> networks:
       </para>
     <programlisting>ADDRESS0=10.10.10.0
 NETMASK0=255.255.255.0
-GATEWAY0=192.168.0.1
-ADDRESS1=172.16.1.0
+GATEWAY0=192.168.0.10
+ADDRESS1=172.16.1.10
 NETMASK1=255.255.255.0
-GATEWAY1=192.168.0.1</programlisting>
+GATEWAY1=192.168.0.10</programlisting>
     <para>
       Subsequent static routes must be numbered sequentially, and must not skip any values. For example, <computeroutput>ADDRESS0</computeroutput>, <computeroutput>ADDRESS1</computeroutput>, <computeroutput>ADDRESS2</computeroutput>, and so on.
     </para>
-    <para>
-      Below is an example of setting static routes to a different network, on a machine in the <systemitem class="ipaddress">192.168.0.0/24</systemitem> network. The example machine has an <interface>eth0</interface> interface in the  <systemitem class="ipaddress">192.168.0.0/24</systemitem> network, and an <interface>eth1</interface> interface ( with address <systemitem class="ipaddress">10.10.10.1</systemitem>) in the <systemitem class="ipaddress">10.10.10.0/24</systemitem> network:
-    </para>
-    <programlisting>ADDRESS0=10.10.10.0
-NETMASK0=255.255.255.0
-GATEWAY0=10.10.10.1</programlisting>
-    <para>
-      Note that if <systemitem class="protocol">DHCP</systemitem> is used, it can assign these settings automatically.
-    </para>
+  </section>
   </section>
 
 



More information about the docs-commits mailing list