LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   DHCP Server (https://www.linuxquestions.org/questions/linux-networking-3/dhcp-server-547815/)

Richtown 04-21-2007 05:47 AM

DHCP Server
 
Hi,

I'm running DHCP Server on my CentOS 4.4 system. I have two clients workstations both CentOS 4.4. I want to be able to give the two client machines hostnames. But as they obtain there IP Address from the DHCP Server i cannot create them, For example:

vi /etc/hosts
127.0.0.1 localhost localdomain
XXX.XXX.XXX.XXX client.xxxxx.com

How can i give my client workstation a hostname if the IP address changes?
It's probably really simple, go easy im new at this stuff.

Thanks for any help
Rich

tredegar 04-21-2007 08:22 AM

Quote:

How can i give my client workstation a hostname if the IP address changes?
Well, I expect that there is some way of doing this, but why don't you just assign your PCs static IPs?
That way they will not change (unless you change them) and your /etc/hosts files will be correct.

JimBass 04-21-2007 11:13 AM

I would accomplish what you are looking for by editing /etc/dhclient.conf.

I would remove the comments from these lines:
Code:

#request subnet-mask, broadcast-address, time-offset, routers,
#      domain-name, domain-name-servers, host-name;

That way your client should ask the dhcp server for a hostname. You'll obviously need to configure the dhcp server to provide a hostname based on MAC address, or some parameter.

Peace,
JimBass

Richtown 04-21-2007 11:57 AM

I'm creating a router for a small network "University Project", so assigning a static IP address for the client is not a problem. I would like to be able to give the client the option to change the hostname. But it does make sense to remove the comments from the lines in /etc/dhclient.conf. As in the real world static IP addresses would be used for a dhcp server.

The only other way to do it would be to assigne static IP addressess from the dhcp server then change them from the server end.

JimBass 04-21-2007 12:30 PM

The DHCP server can assign the same address to a MAC address, or it can allow the address to come from the pool of allowed addresses. If you configure the DHCP server to give out hostnames, then it will.

I don't understand your recent post. In the first post you say you want to assign hostnames, then in the second you say you want the client to be able to change hostnames? Either the hostname is set on the machine, or it accepts a hostname from DHCP. Much like an IP address, it either is set by the client machine or the server, but not both. I also don't understand what you mean by, "in the real world static IP addresses would be used for a dhcp server." A DHCP server can assign real world IP addresses or LAN addresses. And they can be fixed per client or part of a pool. I think we might be using different names for things.

Reading the output of
Code:

man dhcpd.conf
can help if you're looking for the right syntax to assign a hostname.

Peace,
JimBass


All times are GMT -5. The time now is 08:26 PM.