<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
  "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [
  <!ENTITY % general-entities SYSTEM "../../general.ent">
  %general-entities;
]>

<sect1 id="ch-scripts-network">
  <?dbhtml filename="network.html"?>

  <title>Configuring the network Script</title>

  <indexterm zone="ch-scripts-network">
    <primary sortas="d-network">network</primary>
  <secondary>configuring</secondary></indexterm>

  <sect2>
    <title>Creating Network Interface Configuration Files</title>

    <para>Which interfaces are brought up and down by the network script
    depends on the files and directories in the <filename
    class="directory">/etc/network.d</filename> hierarchy.
    This directory should contain a file  for each interface to be
    configured, such as <filename>interface.xyz</filename>, where
    <quote>xyz</quote> is a network interface name. Inside this file we
    would be defining the attributes to this interface, such as its IP
    address(es), subnet masks, and so forth.</para>

    <para>The following command creates the <filename>network.conf</filename>
    file for use by the entire system:</para>

<screen><userinput>cat &gt; ${CLFS}/etc/network.conf &lt;&lt; "EOF"
<literal># /etc/network.conf
# Global Networking Configuration
# interface configuration is in /etc/network.d/

# set to yes to enable networking
NETWORKING=yes

# set to yes to set default route to gateway
USE_GATEWAY=no

# set to gateway IP address
GATEWAY=192.168.0.1</literal>
EOF</userinput></screen>

    <para>The <envar>GATEWAY</envar> variable should contain the default
    gateway IP address, if one is present. If not, then comment out the
    variable entirely.</para>

    <para>The following command creates a sample <filename>interface.eth0</filename>
    file for the <emphasis>eth0</emphasis> device:</para>

<screen><userinput>mkdir ${CLFS}/etc/network.d &amp;&amp;
cat &gt; ${CLFS}/etc/network.d/interface.eth0 &lt;&lt; "EOF"
<literal># Network Interface Configuration

# network device name
INTERFACE=eth0

# set to yes to use DHCP instead of the settings below
DHCP=no

# IP address
IPADDRESS=192.168.1.2

# netmask
NETMASK=255.255.255.0

# broadcast address
BROADCAST=192.168.1.255</literal>
EOF</userinput></screen>

    <para>The <envar>INTERFACE</envar> variable should contain the name of
    the interface interface.</para>

    <para>The <envar>DHCP</envar> variable if set to yes will allow you to
    use dhcp. If set to no, you will need to configure the rest of the options.</para>

    <para>The <envar>IPADDRESS</envar> variable should contain the default
    IP address for this interface.</para>

    <para>The <envar>NETMASK</envar> variable should contain the default
    Subnet Mask for the IP address for this interface.</para>

    <para>The <envar>BROADCAST</envar> variable should contain the default
    Broadcast Address for the Subnet Mask of the IP Range being used on
    this interface.</para>

  </sect2>

  <sect2 id="resolv.conf">
    <title>Creating the ${CLFS}/etc/resolv.conf File</title>

    <indexterm zone="resolv.conf">
      <primary sortas="e-/etc/resolv.conf">/etc/resolv.conf</primary>
    </indexterm>

    <para>If the system is going to be connected to the Internet, it will
    need some means of Domain Name Service (DNS) name resolution to
    resolve Internet domain names to IP addresses, and vice versa. This is
    best achieved by placing the IP address of the DNS server, available
    from the ISP or network administrator, into
    <filename>/etc/resolv.conf</filename>. Create the file by running the
    following:</para>

<screen><userinput>cat &gt; ${CLFS}/etc/resolv.conf &lt;&lt; "EOF"
<literal># Begin /etc/resolv.conf

domain <replaceable>[Your Domain Name]</replaceable>
nameserver <replaceable>[IP address of your primary nameserver]</replaceable>
nameserver <replaceable>[IP address of your secondary nameserver]</replaceable>

# End /etc/resolv.conf</literal>
EOF</userinput></screen>

    <para>Replace <replaceable>[IP address of the nameserver]</replaceable>
    with the IP address of the DNS most appropriate for the setup. There will
    often be more than one entry (requirements demand secondary servers for
    fallback capability). If you only need or want one DNS server, remove the
    second <emphasis>nameserver</emphasis> line from the file. The IP address
    may also be a router on the local network.</para>

  </sect2>

</sect1>
