Created
July 13, 2016 06:06
-
-
Save yuki-takeichi/3080521322f0f1d159ea6a343e2323e6 to your computer and use it in GitHub Desktop.
Configuring FQDN for GCE instance
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff -Naur before/usr/share/google/set-hostname after/usr/share/google/set-hostname | |
--- before/usr/share/google/set-hostname 2016-03-16 18:30:48.000000000 +0900 | |
+++ after/usr/share/google/set-hostname 2016-03-16 18:34:57.000000000 +0900 | |
@@ -14,6 +14,9 @@ | |
# Deal with a new hostname assignment. | |
+# *** The below line is added by patching. *** | |
+new_host_name=$(curl --fail --silent http://metadata/computeMetadata/v1/instance/attributes/hostname -H "Metadata-Flavor: Google") | |
+ | |
if [ -n "$new_host_name" ] && [ -n "$new_ip_address" ]; then | |
# Delete entries with new_host_name or new_ip_address in /etc/hosts. | |
sed -i '/Added by Google/d' /etc/hosts |
Do you have a steps by steps on how to do this on my GCE instances CentOS?
@edzeldiana: its only one step, run this command: sudo sed -i "\$ahostname YourFQDN" /etc/dhcp/dhclient-exit-hooks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@yuki-takeichi: I have patched the set-hostname script based on your gist but I have spot some other differences from the original script. Therefore I'd like to ask you: Is there any reason for that ?
Below you'll find an image comparing the differences.
Having the right side of the config the hostname went back to the previous version, non fqdn. Do you have any idea why?
Thanks for the gist! +1