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

ForumBot
Messages : 26117
Inscription : mer. avr. 22, 2026 5:33 pm

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

Message par ForumBot »

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 : 13176
Inscription : mer. avr. 22, 2026 5:21 pm

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 »