LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Red Hat (http://www.linuxquestions.org/questions/red-hat-31/)
-   -   Automatically renew DHCP address on RHEL4 (http://www.linuxquestions.org/questions/red-hat-31/automatically-renew-dhcp-address-on-rhel4-630825/)

Mark_667 03-26-2008 12:54 PM

Automatically renew DHCP address on RHEL4
 
I need it to report it's hostname to the DHCP server to create a DNS entry for it. I've tried a few things but no luck so far.

dhclient gives command not found
dhcpcd also command not found
as does netconf

/etc/sysconfig/network is a file
there is no dhco file in /etc/sysconfig/

from http://www.novell.com/coolsolutions/trench/16013.html

ifcfg-eth0 (under /etc/sysconfig/network-scripts)
already has
BOOTPROTO="dhcp"

rayfordj 03-26-2008 06:27 PM

If you just want it to send its hostname when requesting dhcp assigned IP you should be able to do this with the DHCP_HOSTNAME variable in the ifcfg-eth* file.

Code:

BOOTPROTO=dhcp
...
DHCP_HOSTNAME=myhost.domain.local

This should then create a file /etc/dhclient-eth*.conf with something like:
send host-name "myhost.domain.local"; that dhclient will use when requesting an IP.

Mark_667 03-27-2008 05:46 AM

after adding the line you specify and rebooting I did
Code:

ls /etc | grep dhclient
dhclient-eth0.conf
resolv.conf.predhclient

the first file contains the following
Quote:

send host name "<machine-name>.domain.local"; #temporary RHL ifup addition
The second contains
Quote:

; generated by /sbin/dhclient-script
nameserver <ip-address>
nameserver <ip-address>
dhclient is clearly installed but I still get a command not found when trying to launch it from command line (as root)? Also it says it's temporary, I need it to do it every time. Is there some way of making it permanent? thanks for the information so far :).

rayfordj 03-27-2008 06:38 AM

I'm fairly sure it is /sbin/dhclient. When you are "as root" are you a)logging in as root, b) su to root, or c) su - (or su - root)? It sounds like your $PATH may not be properly set...

As far as having it permanent that is what adding the line in the network-scripts/ifcfg-ethX file does for you. The line in the dhclient-ethX.conf _is_ temporary in-so-much as it added by an external script (ifup) and can be removed by it (ifdown) when shutting down the interface. However, as long as the variable persists in the ifcfg-ethX file it will always be added to the dhclient-ethX.conf when ifup is run on the interface.

Mark_667 03-27-2008 10:33 AM

Thanks for clarifying that rayfordj, it's been a big help. And to answer your question, I su to root as needed. I'll also take a look at that $PATH variable you mention.

Thanks again,
Mark

rayfordj 03-27-2008 04:14 PM

if you just use 'su' then you keep your user's $PATH rather than sourcing root's $PATH. 'su -' (or 'su - root') will, among other things, source root's $PATH so that you get all of the sbin directories.


All times are GMT -5. The time now is 12:59 AM.