By default, AWS assigns a hostname to an instance at launch based on the instance’s private IPv4 address. This hostname can change when the instance is recycled or replaced.
If your workloads require a consistent hostname, you can configure a custom hostname that persists across recycle operations. You can also derive a stable hostname from the instance’s private IP when private IP persistence is enabled.
Set a custom static hostname
You can configure a custom hostname that continues to be used during instance recycle.
-
Update the hostname configuration
Edit the system hostname and hosts files so the hostname persists:
sudo gedit /etc/hostname /etc/hosts -
Apply a persistent custom hostname
Use the following script to define and persist a custom hostname:
#!/bin/bash CUSTOM_HOSTNAME="my-custom-hostname" echo "preserve_hostname: true" > /etc/cloud/cloud.cfg.d/99_persist_hostname.cfg echo "$CUSTOM_HOSTNAME" > /etc/hostname sed -i "s/^127\.0\.0\.1.*/127.0.0.1 localhost $CUSTOM_HOSTNAME/" /etc/hosts hostnamectl set-hostname "$CUSTOM_HOSTNAME"This configuration prevents cloud‑init from resetting the hostname during future lifecycle events.
Use a hostname based on the original private IP address
If you want the hostname to reflect the instance’s original private IPv4 address, make sure private IP persistence is enabled and configure the hostname dynamically.
-
Retrieve the instance private IP
Use the AWS instance metadata service to get the private IPv4 address:
-
Instance metadata service (linked to https://169.254.169.254/latest/meta-data/local-ipv4)
-
-
Enable private IP persistence
In the Flexera console, open the stateful node configuration:
-
Select Actions > Edit configuration
-
Go to Persistent resources > Network
-
Enable Persist private IP and enter the IP address
-
-
Update the user data script
In the Flexera console, go to Actions > Edit configuration > Initialization and termination.
Add the following script to User data:
#!/bin/bash PRIVATE_IP=$(curl -s http://169.254.169.254/latest/meta-data/local-ipv4) AWS_HOSTNAME="ip-$(echo $PRIVATE_IP | tr '.' '-')" echo "preserve_hostname: true" > /etc/cloud/cloud.cfg.d/99_persist_hostname.cfg echo "$AWS_HOSTNAME" > /etc/hostname sed -i "s/^127\.0\.0\.1.*/127.0.0.1 localhost ${AWS_HOSTNAME}/" /etc/hosts hostnamectl set-hostname "$AWS_HOSTNAME"Because the hostname is derived from the persistent private IP, it remains consistent during instance replacement.
Supported operating systems
Hostname persistence is supported on the following operating systems:
-
RHEL 7, 8, and 9
-
CentOS 7, 8, and 9
Related Articles
Can you use a static endpoint with Ocean Controller version 2? 6Number of Views Resolve SSH connection issues to Flexera-managed AWS instances 2Number of Views Does autohealing work on locked AWS instances? 6Number of Views Inventory device records for AWS instances are deleted if AWS status was "terminated" or failed to be retrieved at any tim… 6Number of Views Inventory returned from AWS EC2 x86_64 Linux instances contains blank agent ID values 9Number of Views
Hi, I am Reva - Ask me anything.
No new updates
Thanks for the feedback!
Your feedback has been saved.Rate this response:
Add Additional feedback ( Optional )
Are you sure you want to cancel
the case creation?
Are you sure you want to cancel the case creation?
Are you sure you want to close this case
| Products | Region | Phone Numbers |
|---|---|---|
| FlexNet Operations FlexNet Embedded FlexNet Publisher FlexNet Connect FlexNet Code Insight InstallAnywhere InstallShield |
North America * |
+1 630-332-2513 (toll) +1 877-279-2853 (toll-free in North America) |
| Europe * |
+44 1925 944367 (toll) +44 800 047 8642 (toll-free in Europe) |
|
| Japan * | +81 3-4540-5335 (select option 2) | |
| Australia * |
+61 3 9895 2177 +61 1800 560 603 (toll-free in Australia) |
|
|
Usage Intelligence (formerly
Revulytics) Compliance Intelligence |
Please use the Case Portal to submit your support ticket or reach out to your Revenera contact. | |
Revenera Assistant
Case id: 00001065
Activity: Status change: 2 hours ago