1 | <sect1 id="dhcpclient" xreflabel="Configuring dhcp for a client">
|
---|
2 | <?dbhtml filename="configdhcp.html" dir="connect"?>
|
---|
3 | <title>Configuring dhcp for a client</title>
|
---|
4 |
|
---|
5 | <sect2><title>Config files</title>
|
---|
6 | <para><userinput>/etc/sysconfig/network,
|
---|
7 | /etc/sysconfig/network-devices/ifup-eth0,
|
---|
8 | /etc/sysconfig/network-devices/ifdown-eth0,
|
---|
9 | /etc/sysconfig/networkdevices/ifconfig.eth0</userinput></para>
|
---|
10 | </sect2>
|
---|
11 |
|
---|
12 | <sect2><title>Configuration Information</title>
|
---|
13 |
|
---|
14 | <para>Note that we use <userinput>eth0</userinput> as the interface
|
---|
15 | throughout these instructions. If you want to configure a different (or
|
---|
16 | more than one) interface, simply replace <userinput>eth0</userinput>
|
---|
17 | with the interface you wish to use.</para>
|
---|
18 |
|
---|
19 | <para>These instructions will convert the configuration files from LFS
|
---|
20 | (a static configuration) to a DHCP configuration. Note that static and
|
---|
21 | DHCP interfaces can co-exist on a LFS system, only make the
|
---|
22 | alterations to those interfaces which need to support DHCP.</para>
|
---|
23 |
|
---|
24 | <para>The first step is to remove the GATEWAY and GATEWAY_IF variables
|
---|
25 | from <filename>/etc/sysconfig/network</filename>. This should only be done
|
---|
26 | if the default interface you intend to use will be using DHCP and only
|
---|
27 | needs to be done once; regardless of how many interfaces you are setting
|
---|
28 | up.</para>
|
---|
29 |
|
---|
30 | <para><screen><userinput>cd /etc/sysconfig &&
|
---|
31 | cp network network.bak &&
|
---|
32 | sed "s/GATEWAY/# GATEWAY/" network.bak > network</userinput></screen></para>
|
---|
33 |
|
---|
34 | <para>Now you can create the appropriate <filename>ifconfig.eth0</filename>
|
---|
35 | file with the following commands (note that this will overwrite any
|
---|
36 | existing file):</para>
|
---|
37 |
|
---|
38 | <para><screen><userinput>cd /etc/sysconfig/network-devices &&
|
---|
39 | cat > ifconfig.eth0 << "EOF"</userinput>
|
---|
40 | ONBOOT=yes
|
---|
41 | DHCP_PROG=<path to dhcp>
|
---|
42 | DHCP_START=<start parameters>
|
---|
43 | DHCP_STOP=<stop parameter>
|
---|
44 | <userinput>EOF</userinput></screen></para>
|
---|
45 |
|
---|
46 | <para>Review the appropriate manpages for parameters; for example, the
|
---|
47 | stop parameter for dhcpcd is '-k', while the stop parameter for dhclient
|
---|
48 | is '-r'.</para>
|
---|
49 |
|
---|
50 | <para>You then need to create DHCP specific scripts. First, the
|
---|
51 | <filename>ifup-eth0</filename> script:</para>
|
---|
52 |
|
---|
53 | <para><screen><userinput>cat > ifup-eth0 << "EOF" </userinput>
|
---|
54 | #!/bin/sh
|
---|
55 |
|
---|
56 | source /etc/sysconfig/rc || exit
|
---|
57 | source $rc_functions || exit
|
---|
58 | source $network_devices/ifconfig.eth0 || exit
|
---|
59 |
|
---|
60 | echo "Bringing up the eth0 interface..."
|
---|
61 | modprobe eth0
|
---|
62 | loadproc $DHCP_PROG $DHCP_START
|
---|
63 | <userinput>EOF</userinput></screen></para>
|
---|
64 |
|
---|
65 | <para>Then the <filename>ifdown-eth0</filename> script:</para>
|
---|
66 |
|
---|
67 | <para><screen><userinput>cat > ifdown-eth0 << "EOF" </userinput>
|
---|
68 | #!/bin/sh
|
---|
69 |
|
---|
70 | source /etc/sysconfig/rc || exit
|
---|
71 | source $rc_functions || exit
|
---|
72 | source $network_devices/ifconfig.eth0 || exit
|
---|
73 |
|
---|
74 | echo "Bringing down the eth0 interface..."
|
---|
75 | $DHCP_PROG $DHCP_STOP
|
---|
76 | evaluate_retval
|
---|
77 | <userinput>EOF</userinput></screen></para>
|
---|
78 |
|
---|
79 | <para>Finally, we need to make these scripts executable:</para>
|
---|
80 |
|
---|
81 | <para><screen><userinput>chmod 755 ifup-eth0 &&
|
---|
82 | chmod 755 ifdown-eth0</userinput></screen></para>
|
---|
83 |
|
---|
84 | </sect2>
|
---|
85 |
|
---|
86 | </sect1>
|
---|
87 |
|
---|