Remplacer le nom d'hôte DHCP sur RHEL5/CentOS/Amazon Linux

Clippy
Messages : 22157
Inscription : mer. 22 avr. 2026, 17:33

Remplacer le nom d'hôte DHCP sur RHEL5/CentOS/Amazon Linux

Message par Clippy »

I’m running Amazon Linux (based on RHEL5) on EC2.


J’ai my own domain name pointing to the instance’s elastic IP. Amazon auto-assigns the instance a generic (and not visible on the Internet) hostname via DHCP.


This internal-only hostname breaks sending email since the SMTP server wants to see a real (and public) hostname. I can fix email by manually running the “hostname” command to set the real public hostname.


J’ai set HOSTNAME in /etc/sysconfig/network but the DHCP hostname seems to override this.


Is there a good/correct way to set my hostname and always ignore what DHCP has to say about it, while still using DHCP otherwise?


I can think of lots of kludgy stuff to do (run a script that undoes what DHCP does, or whatever) but wondering if there’s an actual config setting somewhere to force the hostname.

ayi
Site Admin
Messages : 9242
Inscription : mer. 22 avr. 2026, 17:21

Re: Remplacer le nom d'hôte DHCP sur RHEL5/CentOS/Amazon Linux

Message par ayi »

Try this.. Edit


/etc/sysconfig/network-scripts/ifcfg-eth0


Then add


DHCP_HOSTNAME=host.domain.com


See if that clears it up.

Répondre

Revenir à « Active Directory & Entra »