[Solved] Hostname automatic set when using dhcp

Issues related to configuring your network
Post Reply
vibol
Posts: 5
Joined: 2015/04/10 15:52:29

[Solved] Hostname automatic set when using dhcp

Post by vibol » 2017/05/09 14:56:51

First of all hello to the community.

I'm not able to set hostname if i connect my network to dhcp.
But if i disabled the network provided by dhcp my hostname i already set is appear normally.

After test one by one i can confirm that Hostname always change to dhcppc* (and the * is the last ip provide by dhcp server).

CentOS 7

I hope i got a better answer or any explaination. :!:
Last edited by vibol on 2017/05/10 10:07:30, edited 1 time in total.

User avatar
TrevorH
Site Admin
Posts: 33202
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Hostname automatic set when using dhcp

Post by TrevorH » 2017/05/09 15:02:59

The problem is that your DNS works correctly and your admin has defined reverse records there for all the DHCP controlled ip addresses. When your system gets assigned its new ip address, it does a reverse lookup, finds it has a hostname in DNS and sets your machine name to that.

You could try adding DHCP_HOSTNAME=yourwantedhostname to the ifcfg file.
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

vibol
Posts: 5
Joined: 2015/04/10 15:52:29

Re: Hostname automatic set when using dhcp

Post by vibol » 2017/05/10 02:14:44

@TrevorH

Already set DHCP_HOSTNAME=myhostname.local in /etc/sysconfig/network-scripts/ifcfg-eth0 the ethernet with a dhcp ip.

Still the same issue.. I almost try everything follow by other result in google search include serverfault, centos forums, other howto's blog with how to change hostname but i can't get it to work.

And i hope open my new threat is a bit better resolution.

User avatar
jlehtone
Posts: 4523
Joined: 2007/12/11 08:17:33
Location: Finland

Re: Hostname automatic set when using dhcp

Post by jlehtone » 2017/05/10 07:39:01

Your name isn't really your concern. Your name is used by others to contact you, and they simply use the name to get your IP address from DNS server. Therefore, the others must refer to you by whatever name(s) is known to the DNS. In other words, it is the DNS data that you should update, not the local configuration. More than one name can resolve to same IP, it is just a matter of DNS setup.


That being said, there is command 'hostnamectl' to adjust local name:
https://access.redhat.com/documentation ... mectl.html
https://www.cyberciti.biz/faq/rhel-redh ... e-command/

The important point (mentioned in RHEL 7.3 release notes):
manual modifications done to the /etc/hostname file are no longer picked up automatically by NetworkManager; users should change the system host name through the hostnamectl utility. Also, the use of the HOSTNAME variable in the /etc/sysconfig/network file is now deprecated. (BZ#1367916)
If using NetworkManager, there are three properties of interest in the configuration of a connection: ipv4.dhcp-send-hostname, ipv4.dhcp-hostname, ipv4.dhcp-fqdn.
=== [dhcp-send-hostname] ===
[NM property description]
If TRUE, a hostname is sent to the DHCP server when acquiring a lease. Some DHCP servers use this hostname to update DNS databases, essentially providing a static hostname for the computer. If the "dhcp-hostname" property is NULL and this property is TRUE, the current persistent hostname of the computer is sent.
Some DHCP servers use ...


Is it the static, transient, or pretty name that you want to set?

vibol
Posts: 5
Joined: 2015/04/10 15:52:29

Re: Hostname automatic set when using dhcp

Post by vibol » 2017/05/10 10:06:54

Thank you! refer to the document provided by @jlehtone already know that my dhcp ready list my hostname so and when i start my next computer ti use this hostname it will return back to the dafault one.

So this is mistake by me. Everything Ok after i set hostname to another one.

[Solved]

Post Reply