Ticket #320: dhcp-hosts.2.patch

File dhcp-hosts.2.patch, 1.5 KB (added by DJ Lucas, 21 years ago)

Uses output of 'ifconfig eth0' to correct the hosts file

  • BOOK/connect/dhcp/bootscripts.xml

    diff -Naur BLFS/BOOK/connect/dhcp/bootscripts.xml BLFS-DJL/BOOK/connect/dhcp/bootscripts.xml
    old new  
    4848echo "Bringing up the eth0 interface..."
    4949modprobe eth0
    5050loadproc $DHCP_PROG $DHCP_START
     51
     52echo "Setting up the /etc/hosts file..."
     53
     54IPADDR=`ifconfig eth0 | \
     55grep "inet addr" | cut -f 2 -d ":" | cut -f 1 -d " "`
     56
     57sed "s/0.0.0.0/$IPADDR/" \
     58    /etc/sysconfig/network-devices/hosts.dhcp > /etc/hosts
     59evaluate_retval
     60
    5161<userinput>EOF</userinput></screen></para>
    5262
    5363<para>Then the <filename>ifdown-eth0</filename> script:</para>
     
    6474evaluate_retval
    6575<userinput>EOF</userinput></screen></para>
    6676
    67 <para>Finally, we need to make these scripts executable:</para>
     77<para>Next, we need to make these scripts executable:</para>
    6878
    6979<para><screen><userinput>chmod 755 /etc/sysconfig/network-devices/ifup-eth0 &amp;&amp;
    7080chmod 755 /etc/sysconfig/network-devices/ifdown-eth0</userinput></screen></para>
    7181
     82<para>Make a backup copy of your /etc/hosts file and one to source for the scripts:</para>
     83
     84<para><screen><userinput>cp /etc/hosts /etc/hosts.bak &amp;&amp;
     85cp /etc/hosts /etc/sysconfig/network-devices/hosts.dhcp</userinput></screen></para>
     86
     87<para>Finally, edit the <userinput>/etc/sysconfig/network-devices/hosts.dhcp</userinput>, and replace
     88the existing IP address of the FQDN entry with <userinput>0.0.0.0</userinput>.</para>
     89
    7290</sect2>
    7391
    7492</sect1>