google-compute-engine"/>
  • 4
name

A PHP Error was encountered

Severity: Notice

Message: Undefined index: userid

Filename: views/question.php

Line Number: 191

Backtrace:

File: /home/prodcxja/public_html/questions/application/views/question.php
Line: 191
Function: _error_handler

File: /home/prodcxja/public_html/questions/application/controllers/Questions.php
Line: 433
Function: view

File: /home/prodcxja/public_html/questions/index.php
Line: 315
Function: require_once

name Punditsdkoslkdosdkoskdo

How to update hosts file on google cloud vm

Can anyone help me in updating the hosts file on google cloud vm ? I tried adding alias and bouncing the server but I dont see the update.

Here is what I have

10.12.0.2 gapp.c.flash-arbor-123843.internal gapp # Added by Google

I'm trying to update it to below but gets reset to above line after restarting the server.

10.12.0.2 gapp.c.flash-arbor-123843.internal gapp iam.sandbox.com# Added by Google

Thanks in advance !!

OS is RHEL v7

Here is the Answer

Step 1: Change Hostname

# nano /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=your.hostname.com

Step 2: Create crontab auto set Hostname

# crontab -e
@reboot hostname="your.hostname.com"; sed -i "s/.*Google.*//" /etc/hosts; hostname "$hostname"
  • 1
Reply Report

I would add the host iam.sandbox.com to a new line with the same ip, before the google entry

if you have more instances in your project, you will need to update the host file on each instance with the records in order to be able to resolve them.

I would try to avoid any network/host related editing on gce instance.

  • 0
Reply Report

in order to change the hostname on GCE, you have to use meta-data and cronjob @reboot.

[root@vmx-instance-1 ~]# crontab -l @reboot sleep 100;hostname $(curl --silent "http://metadata.google.internal/computeMetadata/v1/instance/attributes/hostname" -H "Metadata-Flavor: Google") [root@vmx-instance-1 ~]#

Also you have to add a meta-data on instance level hostname value=FQDN

  • 0
Reply Report

Warm tip !!!

This article is reproduced from Stack Exchange / Stack Overflow, please click

Trending Tags