Hostname as a FQDN

2,681 views
Skip to first unread message

Alex Szilagyi

unread,
Oct 19, 2016, 6:46:08 PM10/19/16
to gce-discussion
Hello everyone, I'm using a GCE instance for quite a while and I still have one more issue to solve.

I'm trying to keep hostname as a FQDN (since I have cPanel installed on it and trying to switch to https with letsencrypt) but I am not sure how to achieve that:

Here's a patch (https://gist.github.com/yuki-takeichi/3080521322f0f1d159ea6a343e2323e6#gistcomment-1876232) that I've tried but it seems that it doesn't works properly. Has anyone tried the same thing, if yes and was able to achieve it would you mind to share that experience with me?

Thanks in advance!,
Alex
(P.S. - added to the G+ community, no response till now - https://plus.google.com/112854127725034100147/posts/28GX1vogXbH)

Alex Szilagyi

unread,
Oct 19, 2016, 6:47:35 PM10/19/16
to gce-discussion
Please note that I've already tried all examples from SO (for example this one)

Kamran (Google Cloud Support)

unread,
Oct 19, 2016, 10:19:22 PM10/19/16
to gce-discussion

Hey Alex,

Add the following line in /etc/rc.local script file and the hostname should be changed to your FQDN upon reboot.

hostname <your FQDN>

I hope this helps.

Alex Szilagyi

unread,
Oct 20, 2016, 3:31:23 AM10/20/16
to Kamran (Google Cloud Support), gce-discussion
Hey Kamran,

So if I got it right, it would option #1 (see: https://gist.github.com/alexszilagyi/911f37ab2dc7031679db5ef49db5a803 ); right?

Regards,
Alex

--
© 2016 Google Inc. 1600 Amphitheatre Parkway, Mountain View, CA 94043
 
Email preferences: You received this email because you signed up for the Google Compute Engine Discussion Google Group (gce-discussion@googlegroups.com) to participate in discussions with other members of the Google Compute Engine community and the Google Compute Engine Team.
---
You received this message because you are subscribed to a topic in the Google Groups "gce-discussion" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gce-discussion/olG_nXZ-Jaw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to gce-discussion+unsubscribe@googlegroups.com.
To post to this group, send email to gce-discussion@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gce-discussion/737f3b43-0b46-46b3-ae6e-18cbb657f384%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Alex Szilagyi

Kamran (Google Cloud Support)

unread,
Oct 20, 2016, 6:32:14 PM10/20/16
to gce-dis...@googlegroups.com, khas...@google.com

That's right. In your script the option #1 should do the job.

Please let me know if you have further questions about this.

Sincerely,




On Thursday, October 20, 2016 at 3:31:23 AM UTC-4, Alex Szilagyi wrote:
Hey Kamran,

So if I got it right, it would option #1 (see: https://gist.github.com/alexszilagyi/911f37ab2dc7031679db5ef49db5a803 ); right?

Regards,
Alex

Alex Szilagyi

unread,
Oct 20, 2016, 7:07:40 PM10/20/16
to Kamran (Google Cloud Support), gce-discussion
Hey Kamran,


Ok, after a short test it proves to work. I'll keep monitoring but hope to be the working fix.

Although I have another question but it may sound a good idea to start a new topic (since its related to the snapshots).


Thanks, have a great day,

On 21 October 2016 at 01:32, 'Kamran (Google Cloud Support)' via gce-discussion <gce-dis...@googlegroups.com> wrote:

That's right. In your script the option #1 should do the job.

Please let me know if you have further question about this.

Sincerely,



To post to this group, send email to gce-dis...@googlegroups.com.



--
Alex Szilagyi

--
© 2016 Google Inc. 1600 Amphitheatre Parkway, Mountain View, CA 94043
 
Email preferences: You received this email because you signed up for the Google Compute Engine Discussion Google Group (gce-discussion@googlegroups.com) to participate in discussions with other members of the Google Compute Engine community and the Google Compute Engine Team.
---
You received this message because you are subscribed to a topic in the Google Groups "gce-discussion" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gce-discussion/olG_nXZ-Jaw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to gce-discussion+unsubscribe@googlegroups.com.
To post to this group, send email to gce-discussion@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Alex Szilagyi

Alex Szilagyi

unread,
Oct 21, 2016, 8:24:29 AM10/21/16
to Kamran (Google Cloud Support), gce-discussion
Hey Kamran,

It seems that after couple of hours the hostname went back to a non-fqdn; and I don't know who changed that.

Could be the live migration feature? Is there a change to keep the same hostname?

Regards,
Alex

On 21 October 2016 at 02:07, Alex Szilagyi <alex.s...@gmail.com> wrote:
Hey Kamran,


Ok, after a short test it proves to work. I'll keep monitoring but hope to be the working fix.

Although I have another question but it may sound a good idea to start a new topic (since its related to the snapshots).


Thanks, have a great day,



--
Alex Szilagyi



--
Alex Szilagyi

Kamran (Google Cloud Support)

unread,
Oct 22, 2016, 5:21:27 PM10/22/16
to gce-discussion, khas...@google.com

Hey Alex,

Which Google Compute Engine image is your VM created from?

Sincerely,



To post to this group, send email to gce-discussion@googlegroups.com.



--
Alex Szilagyi

--
© 2016 Google Inc. 1600 Amphitheatre Parkway, Mountain View, CA 94043
 
Email preferences: You received this email because you signed up for the Google Compute Engine Discussion Google Group (gce-discussion@googlegroups.com) to participate in discussions with other members of the Google Compute Engine community and the Google Compute Engine Team.
---
You received this message because you are subscribed to a topic in the Google Groups "gce-discussion" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gce-discussion/olG_nXZ-Jaw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to gce-discussion+unsubscribe@googlegroups.com.
To post to this group, send email to gce-discussion@googlegroups.com.



--
Alex Szilagyi



--
Alex Szilagyi

Alex Szilagyi

unread,
Oct 22, 2016, 7:54:49 PM10/22/16
to Kamran (Google Cloud Support), gce-discussion
Hey Kamran,

The image used was from GCE repository:

CentOS 6

x86_64 built on 2016-09-21


(I think that the build date would be different since at that time it wasn't the same date: two days ago, 21th of October)

Regards,

Sincerely,



To post to this group, send email to gce-dis...@googlegroups.com.



--
Alex Szilagyi

--
© 2016 Google Inc. 1600 Amphitheatre Parkway, Mountain View, CA 94043
 
Email preferences: You received this email because you signed up for the Google Compute Engine Discussion Google Group (gce-discussion@googlegroups.com) to participate in discussions with other members of the Google Compute Engine community and the Google Compute Engine Team.
---
You received this message because you are subscribed to a topic in the Google Groups "gce-discussion" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gce-discussion/olG_nXZ-Jaw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to gce-discussion+unsubscribe@googlegroups.com.
To post to this group, send email to gce-dis...@googlegroups.com.



--
Alex Szilagyi



--
Alex Szilagyi

--
© 2016 Google Inc. 1600 Amphitheatre Parkway, Mountain View, CA 94043
 
Email preferences: You received this email because you signed up for the Google Compute Engine Discussion Google Group (gce-discussion@googlegroups.com) to participate in discussions with other members of the Google Compute Engine community and the Google Compute Engine Team.
---
You received this message because you are subscribed to a topic in the Google Groups "gce-discussion" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gce-discussion/olG_nXZ-Jaw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to gce-discussion+unsubscribe@googlegroups.com.
To post to this group, send email to gce-discussion@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Alex Szilagyi

Kamran (Google Cloud Support)

unread,
Oct 23, 2016, 3:55:54 PM10/23/16
to gce-dis...@googlegroups.com, khas...@google.com

Hey Alex, 

It seems a DHCP hook script called set_hostname located in the /etc/dhcp/dhclient-exit-hooks.d directory set the hostname back to its initial value. This has been described under "Notable differences from standard CentOS images" section of this article, 

  • The hostname is set via a DHCP exit hook and will be re-configured to match the instance name anytime the network is brought up.

It is not recommended to alter this behavior, however if your application needs to use a FQDN as hostname you can add a new DHCP exit hook script under the same directory with the following content:

hostname <your FQDN>

This will maintain your hostname permanently. Note that DHCP hook scripts run in a lexical order (alphabetical order). This means that you will need to select a suitable name for your script to be run after "set_hostname" script. You may name it "set_myhostname".

Now you can add an entry for your hostname/ip address in /etc/hosts file.

I hope this helps.

Sincerely,



On Saturday, October 22, 2016 at 7:54:49 PM UTC-4, Alex Szilagyi wrote:
Hey Kamran,

The image used was from GCE repository:

CentOS 6

x86_64 built on 2016-09-21


(I think that the build date would be different since at that time it wasn't the same date: two days ago, 21th of October)

Regards,
Sincerely,



To post to this group, send email to gce-discussion@googlegroups.com.



--
Alex Szilagyi

--
© 2016 Google Inc. 1600 Amphitheatre Parkway, Mountain View, CA 94043
 
Email preferences: You received this email because you signed up for the Google Compute Engine Discussion Google Group (gce-discussion@googlegroups.com) to participate in discussions with other members of the Google Compute Engine community and the Google Compute Engine Team.
---
You received this message because you are subscribed to a topic in the Google Groups "gce-discussion" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gce-discussion/olG_nXZ-Jaw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to gce-discussion+unsubscribe@googlegroups.com.
To post to this group, send email to gce-discussion@googlegroups.com.



--
Alex Szilagyi



--
Alex Szilagyi

--
© 2016 Google Inc. 1600 Amphitheatre Parkway, Mountain View, CA 94043
 
Email preferences: You received this email because you signed up for the Google Compute Engine Discussion Google Group (gce-discussion@googlegroups.com) to participate in discussions with other members of the Google Compute Engine community and the Google Compute Engine Team.
---
You received this message because you are subscribed to a topic in the Google Groups "gce-discussion" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gce-discussion/olG_nXZ-Jaw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to gce-discussion+unsubscribe@googlegroups.com.
To post to this group, send email to gce-discussion@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gce-discussion/cc329ab2-dd40-4c44-ad48-64d5d669de66%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Alex Szilagyi

Alex Szilagyi

unread,
Oct 23, 2016, 4:13:28 PM10/23/16
to Kamran (Google Cloud Support), gce-discussion
Hey Kamran,

'till I'll get to that can you help to get access back to my instance? Currently I'm out of access since I've enabled cPanel to deny any IPs that are suspicios for flood attack and since my IP is dynamic from the ISP I can no longer connect via ssh.

What I'd need is to:
1. get access to my instance and change the hostname to a fqdn
2. Run the cPanel activate license
3. Then I'm able to log in and fix the security policy that I have applied.

(I can't provide any info about the server, only in a separate private email though)

Can you suggest me how to proceed? I have couple of hours to fix this....


On 23 October 2016 at 22:55, 'Kamran (Google Cloud Support)' via gce-discussion <gce-dis...@googlegroups.com> wrote:

Hey Alex, 

It seems a DHCP hook script called set_hostname located in the /etc/dhcp/dhclient-exit-hooks directory set the hostname back to its initial value. This has been described under "Notable differences from standard CentOS images" section of this article, 

Sincerely,



To post to this group, send email to gce-dis...@googlegroups.com.



--
Alex Szilagyi

--
© 2016 Google Inc. 1600 Amphitheatre Parkway, Mountain View, CA 94043
 
Email preferences: You received this email because you signed up for the Google Compute Engine Discussion Google Group (gce-discussion@googlegroups.com) to participate in discussions with other members of the Google Compute Engine community and the Google Compute Engine Team.
---
You received this message because you are subscribed to a topic in the Google Groups "gce-discussion" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gce-discussion/olG_nXZ-Jaw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to gce-discussion+unsubscribe@googlegroups.com.
To post to this group, send email to gce-dis...@googlegroups.com.



--
Alex Szilagyi



--
Alex Szilagyi

--
© 2016 Google Inc. 1600 Amphitheatre Parkway, Mountain View, CA 94043
 
Email preferences: You received this email because you signed up for the Google Compute Engine Discussion Google Group (gce-discussion@googlegroups.com) to participate in discussions with other members of the Google Compute Engine community and the Google Compute Engine Team.
---
You received this message because you are subscribed to a topic in the Google Groups "gce-discussion" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gce-discussion/olG_nXZ-Jaw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to gce-discussion+unsubscribe@googlegroups.com.
To post to this group, send email to gce-dis...@googlegroups.com.



--
Alex Szilagyi

--
© 2016 Google Inc. 1600 Amphitheatre Parkway, Mountain View, CA 94043
 
Email preferences: You received this email because you signed up for the Google Compute Engine Discussion Google Group (gce-discussion@googlegroups.com) to participate in discussions with other members of the Google Compute Engine community and the Google Compute Engine Team.
---
You received this message because you are subscribed to a topic in the Google Groups "gce-discussion" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gce-discussion/olG_nXZ-Jaw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to gce-discussion+unsubscribe@googlegroups.com.
To post to this group, send email to gce-discussion@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Alex Szilagyi

Kamran (Google Cloud Support)

unread,
Oct 23, 2016, 4:57:32 PM10/23/16
to gce-discussion, khas...@google.com
You can enable interactive access to the serial console to troubleshoot instances that are not booting properly or that are otherwise inaccessible. See Interacting with the Serial Console for more information.

In order to interact with your VM using serial console, via Cloud Console go to your VM instance properties page, click on Edit and select "Enable connecting to serial ports" feature. Save it. Click on "Connect to serial port" button. Now you can use your credential (Linux username and password) to login to your VM to fix the issue.

Let me know if you have further questions about this.

Sincerely,




On Sunday, October 23, 2016 at 4:13:28 PM UTC-4, Alex Szilagyi wrote:
Hey Kamran,

'till I'll get to that can you help to get access back to my instance? Currently I'm out of access since I've enabled cPanel to deny any IPs that are suspicios for flood attack and since my IP is dynamic from the ISP I can no longer connect via ssh.

What I'd need is to:
1. get access to my instance and change the hostname to a fqdn
2. Run the cPanel activate license
3. Then I'm able to log in and fix the security policy that I have applied.

(I can't provide any info about the server, only in a separate private email though)

Can you suggest me how to proceed? I have couple of hours to fix this....

Sincerely,



To post to this group, send email to gce-discussion@googlegroups.com.



--
Alex Szilagyi

--
© 2016 Google Inc. 1600 Amphitheatre Parkway, Mountain View, CA 94043
 
Email preferences: You received this email because you signed up for the Google Compute Engine Discussion Google Group (gce-discussion@googlegroups.com) to participate in discussions with other members of the Google Compute Engine community and the Google Compute Engine Team.
---
You received this message because you are subscribed to a topic in the Google Groups "gce-discussion" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gce-discussion/olG_nXZ-Jaw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to gce-discussion+unsubscribe@googlegroups.com.
To post to this group, send email to gce-discussion@googlegroups.com.



--
Alex Szilagyi



--
Alex Szilagyi

--
© 2016 Google Inc. 1600 Amphitheatre Parkway, Mountain View, CA 94043
 
Email preferences: You received this email because you signed up for the Google Compute Engine Discussion Google Group (gce-discussion@googlegroups.com) to participate in discussions with other members of the Google Compute Engine community and the Google Compute Engine Team.
---
You received this message because you are subscribed to a topic in the Google Groups "gce-discussion" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gce-discussion/olG_nXZ-Jaw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to gce-discussion+unsubscribe@googlegroups.com.
To post to this group, send email to gce-discussion@googlegroups.com.



--
Alex Szilagyi

--
© 2016 Google Inc. 1600 Amphitheatre Parkway, Mountain View, CA 94043
 
Email preferences: You received this email because you signed up for the Google Compute Engine Discussion Google Group (gce-discussion@googlegroups.com) to participate in discussions with other members of the Google Compute Engine community and the Google Compute Engine Team.
---
You received this message because you are subscribed to a topic in the Google Groups "gce-discussion" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gce-discussion/olG_nXZ-Jaw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to gce-discussion+unsubscribe@googlegroups.com.
To post to this group, send email to gce-discussion@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gce-discussion/a903dafc-8eb5-4cdd-93fa-25708f880fc8%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Alex Szilagyi

Alex Szilagyi

unread,
Oct 23, 2016, 5:29:10 PM10/23/16
to Kamran (Google Cloud Support), gce-discussion
Hey Kamran,

Thanks a ton! That's a gold feature! Glad to see that is saved my day :D

About the hostname change, I've checked the path that you've mentioned and is seems that I have the following folders:

pwd - /etc/dhcp/

./  ../  dhclient-exit-hooks*  dhclient.d/

pwd - /etc/dhcp/

ntp.sh*  zzz-set-fqdn

bash: cd: dhclient-exit-hooks: Not a directory

I don't think that its a good approach to change the content of the dhclient-exit-hooks (I think its a script / bash marked executable, right) ?

I think one of the reasons to not change that is when updates will occur at os level then this file might be overwritten (changes will be lost), right?


I am sorry but I didn't get this part:

you can add a new DHCP exit hook script under the same directory with the following content.


Misunderstandings: 

DHCP hook script called set_hostname (dhclient-exit-hooks is not a folder :( )
 
Regards,
Alex

Sincerely,
Sincerely,



To post to this group, send email to gce-dis...@googlegroups.com.



--
Alex Szilagyi

--
© 2016 Google Inc. 1600 Amphitheatre Parkway, Mountain View, CA 94043
 
Email preferences: You received this email because you signed up for the Google Compute Engine Discussion Google Group (gce-discussion@googlegroups.com) to participate in discussions with other members of the Google Compute Engine community and the Google Compute Engine Team.
---
You received this message because you are subscribed to a topic in the Google Groups "gce-discussion" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gce-discussion/olG_nXZ-Jaw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to gce-discussion+unsubscribe@googlegroups.com.
To post to this group, send email to gce-dis...@googlegroups.com.



--
Alex Szilagyi



--
Alex Szilagyi

--
© 2016 Google Inc. 1600 Amphitheatre Parkway, Mountain View, CA 94043
 
Email preferences: You received this email because you signed up for the Google Compute Engine Discussion Google Group (gce-discussion@googlegroups.com) to participate in discussions with other members of the Google Compute Engine community and the Google Compute Engine Team.
---
You received this message because you are subscribed to a topic in the Google Groups "gce-discussion" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gce-discussion/olG_nXZ-Jaw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to gce-discussion+unsubscribe@googlegroups.com.
To post to this group, send email to gce-dis...@googlegroups.com.



--
Alex Szilagyi

--
© 2016 Google Inc. 1600 Amphitheatre Parkway, Mountain View, CA 94043
 
Email preferences: You received this email because you signed up for the Google Compute Engine Discussion Google Group (gce-discussion@googlegroups.com) to participate in discussions with other members of the Google Compute Engine community and the Google Compute Engine Team.
---
You received this message because you are subscribed to a topic in the Google Groups "gce-discussion" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gce-discussion/olG_nXZ-Jaw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to gce-discussion+unsubscribe@googlegroups.com.
To post to this group, send email to gce-dis...@googlegroups.com.



--
Alex Szilagyi

--
© 2016 Google Inc. 1600 Amphitheatre Parkway, Mountain View, CA 94043
 
Email preferences: You received this email because you signed up for the Google Compute Engine Discussion Google Group (gce-discussion@googlegroups.com) to participate in discussions with other members of the Google Compute Engine community and the Google Compute Engine Team.
---
You received this message because you are subscribed to a topic in the Google Groups "gce-discussion" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gce-discussion/olG_nXZ-Jaw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to gce-discussion+unsubscribe@googlegroups.com.
To post to this group, send email to gce-discussion@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Alex Szilagyi

Kamran (Google Cloud Support)

unread,
Oct 23, 2016, 6:11:19 PM10/23/16
to gce-dis...@googlegroups.com, khas...@google.com
Hey Alex,

I'm glad to hear that you've been able to recover your access to VM using Interactive Serial Console. 

About the directory path, apologize that a typo happened in my response. The correct path is:  /etc/dhcp/dhclient-exit-hooks.d

About your other question, as you pointed out set_hostname script is part of Compute Image Packages and may be overwritten when there is new updates.

To summarize the steps that I've provided, you can run the following commands to create your DHCP hook script to maintain your desired hostname (replace YourFQDN with your real FQDN value) :


$ echo "hostname YourFQDN" | sudo tee /etc/dhcp/dhclient-exit-hooks.d/set_myhostname

$ sudo chmod 755 /etc/dhcp/dhclient-exit-hooks.d/set_myhostname


Two above commands will create a script inside /etc/dhcp/dhclient-exit-hooks.d/  directory that can be listed using this command:

$ ls /etc/dhcp/dhclient-exit-hooks.d/



Sincerely,








On Sunday, October 23, 2016 at 5:29:10 PM UTC-4, Alex Szilagyi wrote:
Hey Kamran,

Thanks a ton! That's a gold feature! Glad to see that is saved my day :D

About the hostname change, I've checked the path that you've mentioned and is seems that I have the following folders:

pwd - /etc/dhcp/

./  ../  dhclient-exit-hooks*  dhclient.d/

pwd - /etc/dhcp/

ntp.sh*  zzz-set-fqdn

bash: cd: dhclient-exit-hooks: Not a directory

I don't think that its a good approach to change the content of the dhclient-exit-hooks (I think its a script / bash marked executable, right) ?

I think one of the reasons to not change that is when updates will occur at os level then this file might be overwritten (changes will be lost), right?


I am sorry but I didn't get this part:

you can add a new DHCP exit hook script under the same directory with the following content.


Misunderstandings: 

DHCP hook script called set_hostname (dhclient-exit-hooks is not a folder :( )
 
Regards,
Alex
Sincerely,
Sincerely,



To post to this group, send email to gce-discussion@googlegroups.com.



--
Alex Szilagyi

--
© 2016 Google Inc. 1600 Amphitheatre Parkway, Mountain View, CA 94043
 
Email preferences: You received this email because you signed up for the Google Compute Engine Discussion Google Group (gce-discussion@googlegroups.com) to participate in discussions with other members of the Google Compute Engine community and the Google Compute Engine Team.
---
You received this message because you are subscribed to a topic in the Google Groups "gce-discussion" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gce-discussion/olG_nXZ-Jaw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to gce-discussion+unsubscribe@googlegroups.com.
To post to this group, send email to gce-discussion@googlegroups.com.



--
Alex Szilagyi



--
Alex Szilagyi

--
© 2016 Google Inc. 1600 Amphitheatre Parkway, Mountain View, CA 94043
 
Email preferences: You received this email because you signed up for the Google Compute Engine Discussion Google Group (gce-discussion@googlegroups.com) to participate in discussions with other members of the Google Compute Engine community and the Google Compute Engine Team.
---
You received this message because you are subscribed to a topic in the Google Groups "gce-discussion" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gce-discussion/olG_nXZ-Jaw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to gce-discussion+unsubscribe@googlegroups.com.
To post to this group, send email to gce-discussion@googlegroups.com.



--
Alex Szilagyi

--
© 2016 Google Inc. 1600 Amphitheatre Parkway, Mountain View, CA 94043
 
Email preferences: You received this email because you signed up for the Google Compute Engine Discussion Google Group (gce-discussion@googlegroups.com) to participate in discussions with other members of the Google Compute Engine community and the Google Compute Engine Team.
---
You received this message because you are subscribed to a topic in the Google Groups "gce-discussion" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gce-discussion/olG_nXZ-Jaw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to gce-discussion+unsubscribe@googlegroups.com.
To post to this group, send email to gce-discussion@googlegroups.com.



--
Alex Szilagyi

--
© 2016 Google Inc. 1600 Amphitheatre Parkway, Mountain View, CA 94043
 
Email preferences: You received this email because you signed up for the Google Compute Engine Discussion Google Group (gce-discussion@googlegroups.com) to participate in discussions with other members of the Google Compute Engine community and the Google Compute Engine Team.
---
You received this message because you are subscribed to a topic in the Google Groups "gce-discussion" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gce-discussion/olG_nXZ-Jaw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to gce-discussion+unsubscribe@googlegroups.com.
To post to this group, send email to gce-discussion@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gce-discussion/97dc3e4c-67bd-4a3b-8700-bc467ae359be%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Alex Szilagyi

Alex Szilagyi

unread,
Oct 23, 2016, 6:28:54 PM10/23/16
to Kamran (Google Cloud Support), gce-discussion
Hey Kamran,

Thanks for prompt reply! 

Please note that I'm not running CentOS 7, still:

CentOS release 6.8 (Final)

bash: cd: dhclient-exit-hooks.d: No such file or directory

Could be just dhclient.d/ folder ?





Regards,
Alex

On 24 October 2016 at 01:11, 'Kamran (Google Cloud Support)' via gce-discussion <gce-dis...@googlegroups.com> wrote:
Hey Alex,

I'm glad to hear that you've been able to recover your access to VM using Interactive Serial Console. 

About the directory path, apologize that a typo happened in my response. The correct path is:  /etc/dhcp/dhclient-exit-hooks.d

About your other question, as you pointed out set_hostname script is part of Compute Image Packages and may be overwritten when there is new updates.

To summarize the steps that I've provided, you can run the following commands to create your DHCP hook script to maintain your desired hostname (replace YourFQDN with your real FQDN value) :


$ echo "hostname YourFQDN" | sudo tee /etc/dhcp/dhclient-exit-hooks.d/set_myhostname

$ sudo chmod 755 /etc/dhcp/dhclient-exit-hooks.d/set_myhostname


Tow above command will create a script inside /etc/dhcp/dhclient-exit-hooks.d/  directory that can be listed using this command:

$ ls /etc/dhcp/dhclient-exit-hooks.d/



Sincerely,
Sincerely,
Sincerely,



To post to this group, send email to gce-dis...@googlegroups.com.



--
Alex Szilagyi

--
© 2016 Google Inc. 1600 Amphitheatre Parkway, Mountain View, CA 94043
 
Email preferences: You received this email because you signed up for the Google Compute Engine Discussion Google Group (gce-discussion@googlegroups.com) to participate in discussions with other members of the Google Compute Engine community and the Google Compute Engine Team.
---
You received this message because you are subscribed to a topic in the Google Groups "gce-discussion" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gce-discussion/olG_nXZ-Jaw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to gce-discussion+unsubscribe@googlegroups.com.
To post to this group, send email to gce-dis...@googlegroups.com.



--
Alex Szilagyi



--
Alex Szilagyi

--
© 2016 Google Inc. 1600 Amphitheatre Parkway, Mountain View, CA 94043
 
Email preferences: You received this email because you signed up for the Google Compute Engine Discussion Google Group (gce-discussion@googlegroups.com) to participate in discussions with other members of the Google Compute Engine community and the Google Compute Engine Team.
---
You received this message because you are subscribed to a topic in the Google Groups "gce-discussion" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gce-discussion/olG_nXZ-Jaw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to gce-discussion+unsubscribe@googlegroups.com.
To post to this group, send email to gce-dis...@googlegroups.com.



--
Alex Szilagyi

--
© 2016 Google Inc. 1600 Amphitheatre Parkway, Mountain View, CA 94043
 
Email preferences: You received this email because you signed up for the Google Compute Engine Discussion Google Group (gce-discussion@googlegroups.com) to participate in discussions with other members of the Google Compute Engine community and the Google Compute Engine Team.
---
You received this message because you are subscribed to a topic in the Google Groups "gce-discussion" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gce-discussion/olG_nXZ-Jaw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to gce-discussion+unsubscribe@googlegroups.com.
To post to this group, send email to gce-dis...@googlegroups.com.



--
Alex Szilagyi

--
© 2016 Google Inc. 1600 Amphitheatre Parkway, Mountain View, CA 94043
 
Email preferences: You received this email because you signed up for the Google Compute Engine Discussion Google Group (gce-discussion@googlegroups.com) to participate in discussions with other members of the Google Compute Engine community and the Google Compute Engine Team.
---
You received this message because you are subscribed to a topic in the Google Groups "gce-discussion" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gce-discussion/olG_nXZ-Jaw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to gce-discussion+unsubscribe@googlegroups.com.
To post to this group, send email to gce-dis...@googlegroups.com.



--
Alex Szilagyi

--
© 2016 Google Inc. 1600 Amphitheatre Parkway, Mountain View, CA 94043
 
Email preferences: You received this email because you signed up for the Google Compute Engine Discussion Google Group (gce-discussion@googlegroups.com) to participate in discussions with other members of the Google Compute Engine community and the Google Compute Engine Team.
---
You received this message because you are subscribed to a topic in the Google Groups "gce-discussion" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gce-discussion/olG_nXZ-Jaw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to gce-discussion+unsubscribe@googlegroups.com.
To post to this group, send email to gce-discussion@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Alex Szilagyi

Kamran (Google Cloud Support)

unread,
Oct 23, 2016, 7:24:38 PM10/23/16
to gce-discussion, khas...@google.com

Hey Alex,

Your VM has been created from an old build of CentOS image which has been deprecated. I emailed you a solution.

I hope it works.

Sincerely,

On Sunday, October 23, 2016 at 6:28:54 PM UTC-4, Alex Szilagyi wrote:
Hey Kamran,

Thanks for prompt reply! 

Please note that I'm not running CentOS 7, still:

CentOS release 6.8 (Final)

bash: cd: dhclient-exit-hooks.d: No such file or directory

Could be just dhclient.d/ folder ?





Regards,
Alex
Sincerely,
Sincerely,



To post to this group, send email to gce-discussion@googlegroups.com.



--
Alex Szilagyi

--
© 2016 Google Inc. 1600 Amphitheatre Parkway, Mountain View, CA 94043
 
Email preferences: You received this email because you signed up for the Google Compute Engine Discussion Google Group (gce-discussion@googlegroups.com) to participate in discussions with other members of the Google Compute Engine community and the Google Compute Engine Team.
---
You received this message because you are subscribed to a topic in the Google Groups "gce-discussion" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gce-discussion/olG_nXZ-Jaw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to gce-discussion+unsubscribe@googlegroups.com.
To post to this group, send email to gce-discussion@googlegroups.com.



--
Alex Szilagyi



--
Alex Szilagyi

--
© 2016 Google Inc. 1600 Amphitheatre Parkway, Mountain View, CA 94043
 
Email preferences: You received this email because you signed up for the Google Compute Engine Discussion Google Group (gce-discussion@googlegroups.com) to participate in discussions with other members of the Google Compute Engine community and the Google Compute Engine Team.
---
You received this message because you are subscribed to a topic in the Google Groups "gce-discussion" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gce-discussion/olG_nXZ-Jaw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to gce-discussion+unsubscribe@googlegroups.com.
To post to this group, send email to gce-discussion@googlegroups.com.



--
Alex Szilagyi

--
© 2016 Google Inc. 1600 Amphitheatre Parkway, Mountain View, CA 94043
 
Email preferences: You received this email because you signed up for the Google Compute Engine Discussion Google Group (gce-discussion@googlegroups.com) to participate in discussions with other members of the Google Compute Engine community and the Google Compute Engine Team.
---
You received this message because you are subscribed to a topic in the Google Groups "gce-discussion" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gce-discussion/olG_nXZ-Jaw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to gce-discussion+unsubscribe@googlegroups.com.
To post to this group, send email to gce-discussion@googlegroups.com.



--
Alex Szilagyi

--
© 2016 Google Inc. 1600 Amphitheatre Parkway, Mountain View, CA 94043
 
Email preferences: You received this email because you signed up for the Google Compute Engine Discussion Google Group (gce-discussion@googlegroups.com) to participate in discussions with other members of the Google Compute Engine community and the Google Compute Engine Team.
---
You received this message because you are subscribed to a topic in the Google Groups "gce-discussion" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gce-discussion/olG_nXZ-Jaw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to gce-discussion+unsubscribe@googlegroups.com.
To post to this group, send email to gce-discussion@googlegroups.com.



--
Alex Szilagyi

--
© 2016 Google Inc. 1600 Amphitheatre Parkway, Mountain View, CA 94043
 
Email preferences: You received this email because you signed up for the Google Compute Engine Discussion Google Group (gce-discussion@googlegroups.com) to participate in discussions with other members of the Google Compute Engine community and the Google Compute Engine Team.
---
You received this message because you are subscribed to a topic in the Google Groups "gce-discussion" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gce-discussion/olG_nXZ-Jaw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to gce-discussion+unsubscribe@googlegroups.com.
To post to this group, send email to gce-discussion@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gce-discussion/7ac98e6f-c87d-4dca-8d24-7a0fa36ef608%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Alex Szilagyi

Alex Szilagyi

unread,
Oct 23, 2016, 7:30:35 PM10/23/16
to Kamran (Google Cloud Support), gce-discussion
Hey Kamran,

Thanks for the solution (hope to help others that are using the same source image like me: "sourceImage": "projects/centos-cloud/global/images/centos-6-v20141205")

Run the following command and change the YourFQDN to your case

sudo sed -i "\$ahostname YourFQDN" /etc/dhcp/dhclient-exit-hooks

Have a great day!,

Sincerely,
Sincerely,



To post to this group, send email to gce-dis...@googlegroups.com.



--
Alex Szilagyi

--
© 2016 Google Inc. 1600 Amphitheatre Parkway, Mountain View, CA 94043
 
Email preferences: You received this email because you signed up for the Google Compute Engine Discussion Google Group (gce-discussion@googlegroups.com) to participate in discussions with other members of the Google Compute Engine community and the Google Compute Engine Team.
---
You received this message because you are subscribed to a topic in the Google Groups "gce-discussion" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gce-discussion/olG_nXZ-Jaw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to gce-discussion+unsubscribe@googlegroups.com.
To post to this group, send email to gce-dis...@googlegroups.com.



--
Alex Szilagyi



--
Alex Szilagyi

--
© 2016 Google Inc. 1600 Amphitheatre Parkway, Mountain View, CA 94043
 
Email preferences: You received this email because you signed up for the Google Compute Engine Discussion Google Group (gce-discussion@googlegroups.com) to participate in discussions with other members of the Google Compute Engine community and the Google Compute Engine Team.
---
You received this message because you are subscribed to a topic in the Google Groups "gce-discussion" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gce-discussion/olG_nXZ-Jaw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to gce-discussion+unsubscribe@googlegroups.com.
To post to this group, send email to gce-dis...@googlegroups.com.



--
Alex Szilagyi

--
© 2016 Google Inc. 1600 Amphitheatre Parkway, Mountain View, CA 94043
 
Email preferences: You received this email because you signed up for the Google Compute Engine Discussion Google Group (gce-discussion@googlegroups.com) to participate in discussions with other members of the Google Compute Engine community and the Google Compute Engine Team.
---
You received this message because you are subscribed to a topic in the Google Groups "gce-discussion" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gce-discussion/olG_nXZ-Jaw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to gce-discussion+unsubscribe@googlegroups.com.
To post to this group, send email to gce-dis...@googlegroups.com.



--
Alex Szilagyi

--
© 2016 Google Inc. 1600 Amphitheatre Parkway, Mountain View, CA 94043
 
Email preferences: You received this email because you signed up for the Google Compute Engine Discussion Google Group (gce-discussion@googlegroups.com) to participate in discussions with other members of the Google Compute Engine community and the Google Compute Engine Team.
---
You received this message because you are subscribed to a topic in the Google Groups "gce-discussion" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gce-discussion/olG_nXZ-Jaw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to gce-discussion+unsubscribe@googlegroups.com.
To post to this group, send email to gce-dis...@googlegroups.com.



--
Alex Szilagyi

--
© 2016 Google Inc. 1600 Amphitheatre Parkway, Mountain View, CA 94043
 
Email preferences: You received this email because you signed up for the Google Compute Engine Discussion Google Group (gce-discussion@googlegroups.com) to participate in discussions with other members of the Google Compute Engine community and the Google Compute Engine Team.
---
You received this message because you are subscribed to a topic in the Google Groups "gce-discussion" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gce-discussion/olG_nXZ-Jaw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to gce-discussion+unsubscribe@googlegroups.com.
To post to this group, send email to gce-dis...@googlegroups.com.



--
Alex Szilagyi

--
© 2016 Google Inc. 1600 Amphitheatre Parkway, Mountain View, CA 94043
 
Email preferences: You received this email because you signed up for the Google Compute Engine Discussion Google Group (gce-discussion@googlegroups.com) to participate in discussions with other members of the Google Compute Engine community and the Google Compute Engine Team.
---
You received this message because you are subscribed to a topic in the Google Groups "gce-discussion" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gce-discussion/olG_nXZ-Jaw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to gce-discussion+unsubscribe@googlegroups.com.
To post to this group, send email to gce-discussion@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Alex Szilagyi

James Maina

unread,
Sep 4, 2017, 9:01:31 AM9/4/17
to gce-discussion, khas...@google.com
Hey Alex/Google

I am having the exact same issue but with Centos 7 which is using Network Manager and does not have the dhclient-exit-hooks.

Could you assist with a command i can use to resolve the same issue? My hostname is changing every 24hours and i have a software which uses hostname for licensing, meaning i lose my license every day! as a workaround i have to manually change hostnames daily :(

Many Thanks
James


On Monday, October 24, 2016 at 1:30:35 AM UTC+2, Alex Szilagyi wrote:
Hey Kamran,

Thanks for the solution (hope to help others that are using the same source image like me: "sourceImage": "projects/centos-cloud/global/images/centos-6-v20141205")

Run the following command and change the YourFQDN to your case

sudo sed -i "\$ahostname YourFQDN" /etc/dhcp/dhclient-exit-hooks

Have a great day!,
On 24 October 2016 at 02:24, 'Kamran (Google Cloud Support)' via gce-discussion <gce-dis...@googlegroups.com> wrote:

Hey Alex,

Your VM has been created from an old build of CentOS image which has been deprecated. I emailed you a solution.

I hope it works.

Sincerely,

On Sunday, October 23, 2016 at 6:28:54 PM UTC-4, Alex Szilagyi wrote:
Hey Kamran,

Thanks for prompt reply! 

Please note that I'm not running CentOS 7, still:

CentOS release 6.8 (Final)

bash: cd: dhclient-exit-hooks.d: No such file or directory

Could be just dhclient.d/ folder ?





Regards,
Alex
Sincerely,
Sincerely,



Email preferences: You received this email because you signed up for the Google Compute Engine Discussion Google Group (gce-dis...@googlegroups.com) to participate in discussions with other members of the Google Compute Engine community and the Google Compute Engine Team.

---
You received this message because you are subscribed to a topic in the Google Groups "gce-discussion" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gce-discussion/olG_nXZ-Jaw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to gce-discussio...@googlegroups.com.

To post to this group, send email to gce-dis...@googlegroups.com.



--
Alex Szilagyi

--
© 2016 Google Inc. 1600 Amphitheatre Parkway, Mountain View, CA 94043
 
Email preferences: You received this email because you signed up for the Google Compute Engine Discussion Google Group (gce-dis...@googlegroups.com) to participate in discussions with other members of the Google Compute Engine community and the Google Compute Engine Team.

---
You received this message because you are subscribed to a topic in the Google Groups "gce-discussion" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gce-discussion/olG_nXZ-Jaw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to gce-discussio...@googlegroups.com.

To post to this group, send email to gce-dis...@googlegroups.com.



--
Alex Szilagyi



--
Alex Szilagyi

--
© 2016 Google Inc. 1600 Amphitheatre Parkway, Mountain View, CA 94043
 
Email preferences: You received this email because you signed up for the Google Compute Engine Discussion Google Group (gce-dis...@googlegroups.com) to participate in discussions with other members of the Google Compute Engine community and the Google Compute Engine Team.

---
You received this message because you are subscribed to a topic in the Google Groups "gce-discussion" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gce-discussion/olG_nXZ-Jaw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to gce-discussio...@googlegroups.com.

To post to this group, send email to gce-dis...@googlegroups.com.



--
Alex Szilagyi

--
© 2016 Google Inc. 1600 Amphitheatre Parkway, Mountain View, CA 94043
 
Email preferences: You received this email because you signed up for the Google Compute Engine Discussion Google Group (gce-dis...@googlegroups.com) to participate in discussions with other members of the Google Compute Engine community and the Google Compute Engine Team.

---
You received this message because you are subscribed to a topic in the Google Groups "gce-discussion" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gce-discussion/olG_nXZ-Jaw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to gce-discussio...@googlegroups.com.

To post to this group, send email to gce-dis...@googlegroups.com.



--
Alex Szilagyi

--
© 2016 Google Inc. 1600 Amphitheatre Parkway, Mountain View, CA 94043
 
Email preferences: You received this email because you signed up for the Google Compute Engine Discussion Google Group (gce-dis...@googlegroups.com) to participate in discussions with other members of the Google Compute Engine community and the Google Compute Engine Team.

---
You received this message because you are subscribed to a topic in the Google Groups "gce-discussion" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gce-discussion/olG_nXZ-Jaw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to gce-discussio...@googlegroups.com.

To post to this group, send email to gce-dis...@googlegroups.com.



--
Alex Szilagyi

--
© 2016 Google Inc. 1600 Amphitheatre Parkway, Mountain View, CA 94043
 
Email preferences: You received this email because you signed up for the Google Compute Engine Discussion Google Group (gce-dis...@googlegroups.com) to participate in discussions with other members of the Google Compute Engine community and the Google Compute Engine Team.

---
You received this message because you are subscribed to a topic in the Google Groups "gce-discussion" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gce-discussion/olG_nXZ-Jaw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to gce-discussio...@googlegroups.com.

To post to this group, send email to gce-dis...@googlegroups.com.



--
Alex Szilagyi

--
© 2016 Google Inc. 1600 Amphitheatre Parkway, Mountain View, CA 94043
 
Email preferences: You received this email because you signed up for the Google Compute Engine Discussion Google Group (gce-dis...@googlegroups.com) to participate in discussions with other members of the Google Compute Engine community and the Google Compute Engine Team.

---
You received this message because you are subscribed to a topic in the Google Groups "gce-discussion" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gce-discussion/olG_nXZ-Jaw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to gce-discussio...@googlegroups.com.

To post to this group, send email to gce-dis...@googlegroups.com.



--
Alex Szilagyi

Alex Szilagyi

unread,
Sep 4, 2017, 9:19:55 AM9/4/17
to James Maina, gce-discussion, Kamran (Google Cloud Support)
Hi James,

My GCE instance is using CENTOS 6.9, sorry I can't help. I'm sure that @Kamran will give a hand.

Cheers,
Alex

--
© 2017 Google Inc. 1600 Amphitheatre Parkway, Mountain View, CA 94043
 
Email preferences: You received this email because you signed up for the Google Compute Engine Discussion Google Group (gce-discussion@googlegroups.com) to participate in discussions with other members of the Google Compute Engine community and the Google Compute Engine Team.

---
You received this message because you are subscribed to a topic in the Google Groups "gce-discussion" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gce-discussion/olG_nXZ-Jaw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to gce-discussion+unsubscribe@googlegroups.com.
To post to this group, send email to gce-discussion@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gce-discussion/a70aaa8b-8094-457d-8baa-dc8e4a74db07%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Alex Szilagyi

Kamran (Google Cloud Support)

unread,
Sep 24, 2017, 1:53:58 PM9/24/17
to gce-dis...@googlegroups.com

As seems more folks are interested in modifying hostname of their Linux VMs, I'd like to rewrite my answer as below:

In fact, some distributions of Linux like CentOS and Debian use dhclient-script script to configure the network parameters of the machine. This script is invoked from time to time by dhclient which is dynamic host configuration protocol client and provides a means for configuring one or more network interfaces using the DHCP protocol, BOOTP protocol, or if these protocols fail, by statically assigning an address.

The following text is a quote from the man (manual) page of  dhclient-script:


After  all  processing  has  completed,  /usr/sbin/dhclient-script  checks  for  the  presence  of  an  executable
       /etc/dhcp/dhclient-exit-hooks  script,  which  if  present  is  invoked using the ´.´ command.  The exit status of
       dhclient-script will be passed to dhclient-exit-hooks in the exit_status shell variable, and will always  be  zero
       if  the  script  succeeded at the task for which it was invoked.   The rest of the environment as described previ‐
       ously for dhclient-enter-hooks is also present.   The /etc/dhcp/dhclient-exit-hooks script can modify the valid of
       exit_status to change the exit status of dhclient-script.


That being said, by taking a look into the code snippet of dhclient-script, we can see the script checks for the existence of an executable /etc/dhcp/dhclient-up-hooks script and all scripts in /etc/dhcp/dhclient-exit-hooks.d/ directory.

ETCDIR="/etc/dhcp"

193 exit_with_hooks() {
194     exit_status="${1}"
195 
196     if [ -x ${ETCDIR}/dhclient-exit-hooks ]; then
197         . ${ETCDIR}/dhclient-exit-hooks
198     fi
199 
200     if [ -d ${ETCDIR}/dhclient-exit-hooks.d ]; then
201         for f in ${ETCDIR}/dhclient-exit-hooks.d/*.sh ; do
202             if [ -x ${f} ]; then
203                 . ${f}204             fi
205         done
206     fi
207 
208     exit ${exit_status}209 }


Therefore, in order to modify the hostname of your Linux VM you can create a custom script with .sh extension and place it in /etc/dhcp/dhclient-exit-hooks.d/ directory. If this directory does not exist, you can create it. The content of the custom script will be:

hostname YourFQDN


I hope this solution helps.

XOOM SERVE

unread,
Jan 19, 2018, 9:01:04 PM1/19/18
to gce-discussion
Hello Kamran,

Thank you for all of this info,
I tried this, but when reboot also KVM hostname is there and not mine,
Do we need to make one on start, and  one on DHCP exist?

Please advise,
Thank you,
Tariq



--
Alex Szilagyi

Richard Terry

unread,
Mar 21, 2018, 9:22:54 PM3/21/18
to gce-discussion
It should be noted that you need to set the .sh file you create to executable to enable the script as described.  (e.g. chmod +x filename.sh)



--
Alex Szilagyi

Richard Terry

unread,
Apr 14, 2018, 5:31:32 PM4/14/18
to gce-discussion
I added my script to the folder to set the FQDN but it is not setting it when the dhclient-script actually runs.   Is there another setting or filename syntax I am missing? 

On Sunday, September 24, 2017 at 1:53:58 PM UTC-4, Kamran (Google Cloud Support) wrote:



--
Alex Szilagyi

Richard Terry

unread,
Apr 19, 2018, 2:01:00 PM4/19/18
to gce-discussion
I added my script to the folder to set the FQDN but it is not setting it when the dhclient-script actually runs.   Is there another setting or filename syntax I am missing?   It is not working on my instance properly.


On Sunday, September 24, 2017 at 1:53:58 PM UTC-4, Kamran (Google Cloud Support) wrote:



--
Alex Szilagyi

James

unread,
Dec 5, 2018, 10:51:50 PM12/5/18
to gce-discussion
Hi Kamran,

I tried this approach but still changed back the origin hostname after reboot.

Here is the script

Screenshot 2018-12-06 at 11.41.28 AM.png


Here is the set-hostname.sh

Screenshot 2018-12-06 at 11.43.10 AM.png


I ran the script to change the hostname

Screenshot 2018-12-06 at 11.45.40 AM.png


But after reboot, the hostname still is the old one

Screenshot 2018-12-06 at 11.51.21 AM.png










--
Alex Szilagyi

Adebisi Ibirogba

unread,
Dec 6, 2018, 4:13:33 PM12/6/18
to gce-discussion

Google Compute Engine-provided CentOS images contain the following difference from standard CentOS images: The hostname is set via a DHCP exit hook and will be re-configured to match the instance name anytime the network is brought up.doc [here](https://cloud.google.com/compute/docs/images?hl=en#os-details)


This is a workaround reply to one of the stackoverflow threads as regards your question [here](https://stackoverflow.com/a/48151928/10682174)


I believe there is a feature request that is being considered by our GCE team but there’s no ETA if or when this will be available.


James Wu

unread,
Dec 6, 2018, 9:52:36 PM12/6/18
to gce-discussion
Hi Adebisi,

Thanks for your reply.
I have tried but not work as well... my OS is CentOS7.
Thanks.

Adebisi Ibirogba

unread,
Dec 7, 2018, 11:49:51 AM12/7/18
to gce-discussion

I will suggest you post this issue then on [serverfault](serverfault.com) since it will have more visibility over there. This is a forum intended for discussion about GCE product rather than troubleshooting customer issues.


James Wu

unread,
Dec 8, 2018, 2:15:45 PM12/8/18
to gce-discussion
Oh, sorry about it. 
We will use official GCP Gold level support to see if there is a workable solution.
Sincerely,
Sincerely,



To unsubscribe from this topic, visit <a href="https://groups.google.com/d/topic/gce-discussion/olG_nXZ-Jaw/unsubscribe" rel="nofollow" target="_blank" onmousedown="this.href='https://groups.google.com/d/topic/gce-discussion/olG_nXZ-Jaw/unsubscribe';return true;" onclick="this.href='https://groups.g
Reply all
Reply to author
Forward
0 new messages