mirror of
https://git.linuxfromscratch.org/lfs.git
synced 2025-06-19 03:39:20 +01:00
last changes
git-svn-id: http://svn.linuxfromscratch.org/LFS/trunk/BOOK@1445 4aa44e1e-78dd-0310-a6d2-fbcd4c07a689
This commit is contained in:
parent
a3be86d628
commit
00a2bd121d
@ -8,7 +8,7 @@
|
|||||||
&c7-setclock;
|
&c7-setclock;
|
||||||
&c7-hostname;
|
&c7-hostname;
|
||||||
&c7-hosts;
|
&c7-hosts;
|
||||||
&c7-ethnet;
|
&c7-network;
|
||||||
|
|
||||||
</chapter>
|
</chapter>
|
||||||
|
|
||||||
|
@ -1,166 +0,0 @@
|
|||||||
<sect1 id="ch07-ethnet">
|
|
||||||
<title>Creating the ethnet script</title>
|
|
||||||
<?dbhtml filename="ethnet.html" dir="chapter07"?>
|
|
||||||
|
|
||||||
<para>This section only applies if a user is going to configure a network card.
|
|
||||||
If not, this section can be skipped.</para>
|
|
||||||
|
|
||||||
<para>Create the <filename>/etc/init.d/ethnet</filename> script by running the
|
|
||||||
following command:</para>
|
|
||||||
|
|
||||||
<para><screen><userinput>cat > /etc/init.d/ethnet << "EOF"</userinput>
|
|
||||||
#!/bin/sh
|
|
||||||
# Begin /etc/init.d/ethnet
|
|
||||||
#
|
|
||||||
# Main script by Gerard Beekmans - gerard@linuxfromscratch.org
|
|
||||||
# GATEWAY check by Jean-François Le Ray - jfleray@club-internet.fr
|
|
||||||
# "Specify which IF to use to reach default GATEWAY" by
|
|
||||||
# Graham Cantin - gcantin@pacbell.net
|
|
||||||
#
|
|
||||||
|
|
||||||
#
|
|
||||||
# Include the functions declared in the /etc/init.d/functions file
|
|
||||||
# and the variables from the /etc/sysconfig/network file.
|
|
||||||
#
|
|
||||||
|
|
||||||
source /etc/init.d/functions
|
|
||||||
source /etc/sysconfig/network
|
|
||||||
|
|
||||||
case "$1" in
|
|
||||||
start)
|
|
||||||
|
|
||||||
#
|
|
||||||
# Obtain all the network card configuration files
|
|
||||||
#
|
|
||||||
|
|
||||||
for interface in $(/bin/ls /etc/sysconfig/nic-config/ifcfg* | \
|
|
||||||
grep -v ifcfg-lo)
|
|
||||||
do
|
|
||||||
#
|
|
||||||
# Load the variables from that file
|
|
||||||
#
|
|
||||||
|
|
||||||
source $interface
|
|
||||||
#
|
|
||||||
# If the ONBOOT variable is set to yes, process this file and bring the
|
|
||||||
# interface up.
|
|
||||||
#
|
|
||||||
|
|
||||||
if [ "$ONBOOT" == yes ]
|
|
||||||
then
|
|
||||||
echo -n "Bringing up the $DEVICE interface..."
|
|
||||||
/sbin/ifconfig $DEVICE $IP broadcast $BROADCAST \
|
|
||||||
netmask $NETMASK
|
|
||||||
evaluate_retval
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
#
|
|
||||||
# If the /etc/sysconfig/network file contains a GATEWAY variable, set
|
|
||||||
# the default gateway and the interface through which the default
|
|
||||||
# gateway can be reached.
|
|
||||||
#
|
|
||||||
|
|
||||||
if [ "$GATEWAY" != "" ]; then
|
|
||||||
echo -n "Setting up routing for $GATEWAY_IF interface..."
|
|
||||||
/sbin/route add default gateway $GATEWAY \
|
|
||||||
metric 1 dev $GATEWAY_IF
|
|
||||||
evaluate_retval
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
|
|
||||||
stop)
|
|
||||||
|
|
||||||
#
|
|
||||||
# Obtain all the network card configuration files
|
|
||||||
#
|
|
||||||
|
|
||||||
for interface in $(/bin/ls /etc/sysconfig/nic-config/ifcfg* | \
|
|
||||||
grep -v ifcfg-lo)
|
|
||||||
do
|
|
||||||
#
|
|
||||||
# Load the variables from that file
|
|
||||||
#
|
|
||||||
|
|
||||||
source $interface
|
|
||||||
#
|
|
||||||
# If the ONBOOT variable is set, process the file and bring the
|
|
||||||
# interface down
|
|
||||||
#
|
|
||||||
|
|
||||||
if [ $ONBOOT == yes ]
|
|
||||||
then
|
|
||||||
echo -n "Bringing down the $DEVICE interface..."
|
|
||||||
/sbin/ifconfig $DEVICE down
|
|
||||||
evaluate_retval
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
;;
|
|
||||||
|
|
||||||
restart)
|
|
||||||
$0 stop
|
|
||||||
sleep 1
|
|
||||||
$0 start
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo "Usage: $0 {start|stop|restart}"
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
# End /etc/init.d/ethnet
|
|
||||||
<userinput>EOF</userinput></screen></para>
|
|
||||||
|
|
||||||
<sect2>
|
|
||||||
<title>Adding default gateway to /etc/sysconfig/network</title>
|
|
||||||
|
|
||||||
<para>If a default gateway is required to be setup, the
|
|
||||||
following command does that:</para>
|
|
||||||
|
|
||||||
<para><screen><userinput>cat >> /etc/sysconfig/network << "EOF"</userinput>
|
|
||||||
GATEWAY=192.168.1.2
|
|
||||||
GATEWAY_IF=eth0
|
|
||||||
<userinput>EOF</userinput></screen></para>
|
|
||||||
|
|
||||||
<para>GATEWAY and GATEWAY_IF need to be changed to match the network setup.
|
|
||||||
GATEWAY contains the address of the default gateway, and GATEWAY_IF
|
|
||||||
contains the network interface through which that default gateway can
|
|
||||||
be reached.</para>
|
|
||||||
|
|
||||||
</sect2>
|
|
||||||
|
|
||||||
<sect2>
|
|
||||||
<title>Creating NIC configuration files</title>
|
|
||||||
|
|
||||||
<para>Which interfaces are brought up and down by the ethnet script depends on
|
|
||||||
the files in the /etc/sysconfig/nic-config directory. This
|
|
||||||
directory should contain files in the form of ifcfg-x where x is an
|
|
||||||
identification number (or whatever a user named it).</para>
|
|
||||||
|
|
||||||
<para>First the nic-config directory is created by running:</para>
|
|
||||||
|
|
||||||
<para><screen><userinput>mkdir /etc/sysconfig/nic-config</userinput></screen></para>
|
|
||||||
|
|
||||||
<para>Now, new files are created in that directory containing the following.
|
|
||||||
The following command creates a sample file ifcfg-eth0:</para>
|
|
||||||
|
|
||||||
<para><screen><userinput>cat > /etc/sysconfig/nic-config/ifcfg-eth0 << "EOF"</userinput>
|
|
||||||
ONBOOT=yes
|
|
||||||
DEVICE=eth0
|
|
||||||
IP=192.168.1.1
|
|
||||||
NETMASK=255.255.255.0
|
|
||||||
BROADCAST=192.168.1.255
|
|
||||||
<userinput>EOF</userinput></screen></para>
|
|
||||||
|
|
||||||
<para>Of course, the values of those four variables have to be changed
|
|
||||||
in every file to
|
|
||||||
match the proper setup. Usually NETMASK and BROADCAST will remain the
|
|
||||||
same, just the DEVICE and IP variables will change per network interface. If
|
|
||||||
the ONBOOT variable is set to yes, the ethnet script will bring it up
|
|
||||||
during boot up of the system. If set to anything else but yes it will be
|
|
||||||
ignored by the ethnet script and thus not brought up.</para>
|
|
||||||
|
|
||||||
</sect2>
|
|
||||||
|
|
||||||
</sect1>
|
|
||||||
|
|
60
chapter07/network.xml
Normal file
60
chapter07/network.xml
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
<sect1 id="ch07-network">
|
||||||
|
<title>Configuring the network script</title>
|
||||||
|
<?dbhtml filename="network.html" dir="chapter07"?>
|
||||||
|
|
||||||
|
<para>This section only applies if you're going to configure a network
|
||||||
|
card.</para>
|
||||||
|
|
||||||
|
<sect2>
|
||||||
|
<title>Configuring default gateway</title>
|
||||||
|
|
||||||
|
<para>If you're on a network you may need to setup the default gateway for
|
||||||
|
this machine. This is done by adding the proper values to the
|
||||||
|
/etc/sysconfig/network file by running the following:</para>
|
||||||
|
|
||||||
|
<para><screen><userinput>cat >> /etc/sysconfig/network << "EOF"</userinput>
|
||||||
|
GATEWAY=192.168.1.2
|
||||||
|
GATEWAY_IF=eth0
|
||||||
|
<userinput>EOF</userinput></screen></para>
|
||||||
|
|
||||||
|
<para>The values for GATEWAY and GATEWAY_IF need to be changed to match
|
||||||
|
your network setup. GATEWAY contains the IP address of the default
|
||||||
|
gateway, and GATEWAY_IF contains the network interface through which the
|
||||||
|
default gateway can be reached.</para>
|
||||||
|
|
||||||
|
</sect2>
|
||||||
|
|
||||||
|
<sect2>
|
||||||
|
<title>Creating network interface configuration files</title>
|
||||||
|
|
||||||
|
<para>Which interfaces are brought up and down by the network script depends on
|
||||||
|
the files in the /etc/sysconfig/network-devices directory. This
|
||||||
|
directory should contain files in the form of ifconfig.xyz, where xyz is a
|
||||||
|
network interface name (such as eth0 or eth0:1)</para>
|
||||||
|
|
||||||
|
<para>First let's create this directory by running:</para>
|
||||||
|
|
||||||
|
<para><screen><userinput>mkdir /etc/sysconfig/nic-config</userinput></screen></para>
|
||||||
|
|
||||||
|
<para>Now, new files are created in that directory containing the following.
|
||||||
|
The following command creates a sample ifconfig.eth0 file:</para>
|
||||||
|
|
||||||
|
<para><screen><userinput>cat > /etc/sysconfig/network-devices/ifconfig.eth0 << "EOF"</userinput>
|
||||||
|
ONBOOT=yes
|
||||||
|
DEVICE=eth0
|
||||||
|
IP=192.168.1.1
|
||||||
|
NETMASK=255.255.255.0
|
||||||
|
BROADCAST=192.168.1.255
|
||||||
|
<userinput>EOF</userinput></screen></para>
|
||||||
|
|
||||||
|
<para>Of course, the values of those variables have to be changed
|
||||||
|
in every file to match the proper setup. Usually NETMASK and BROADCAST
|
||||||
|
will remain the same, just the DEVICE and IP variables will change per
|
||||||
|
network interface. If the ONBOOT variable is set to yes, the network script
|
||||||
|
will bring it up during boot up of the system. If set to anything else but
|
||||||
|
yes it will be ignored by the network script and thus not brought up.</para>
|
||||||
|
|
||||||
|
</sect2>
|
||||||
|
|
||||||
|
</sect1>
|
||||||
|
|
@ -336,7 +336,7 @@
|
|||||||
<!ENTITY c7-setclock SYSTEM "chapter7/setclock.xml">
|
<!ENTITY c7-setclock SYSTEM "chapter7/setclock.xml">
|
||||||
<!ENTITY c7-hostname SYSTEM "chapter7/hostname.xml">
|
<!ENTITY c7-hostname SYSTEM "chapter7/hostname.xml">
|
||||||
<!ENTITY c7-hosts SYSTEM "chapter7/hosts.xml">
|
<!ENTITY c7-hosts SYSTEM "chapter7/hosts.xml">
|
||||||
<!ENTITY c7-ethnet SYSTEM "chapter7/ethnet.xml">
|
<!ENTITY c7-network SYSTEM "chapter7/network.xml">
|
||||||
|
|
||||||
<!ENTITY chapter8 SYSTEM "chapter8/chapter8.xml">
|
<!ENTITY chapter8 SYSTEM "chapter8/chapter8.xml">
|
||||||
<!ENTITY c8-introduction SYSTEM "chapter8/introduction.xml">
|
<!ENTITY c8-introduction SYSTEM "chapter8/introduction.xml">
|
||||||
|
Loading…
Reference in New Issue
Block a user