网络重启后,主机名和/ etc / hosts会不断更改为实例/项目名称。需要具有固定的主机名设置

时间:2016-12-24 01:14:47

标签: google-compute-engine

我有一台运行Google提供的CentOS 7操作系统映像的Google Compute Engine / VM(x16_64建于2016-12-12)并且一直在运行主机名和/ etc / hosts的问题,这些问题因某些自定义修改/服务而发生变化由Google完成。

Google会在相关部分

中的site here上记录有关其图片的详细信息
  

主机名是通过DHCP退出挂钩设置的,并且会在网络启动时重新配置以匹配实例名称。

这就是问题所在,我的实例似乎没有那些我可以改变或覆盖这种行为的脚本 - 我已经在这个图像上设置我的应用程序所以我宁愿不下载公共centos图像并且当所有我需要的是删除这个" hack"他们建立了他们的形象。

查找DHCP init脚本,但在这些文件夹中找不到任何内容:

[root@cponly2 dhcp]# pwd
/etc/dhcp
[root@cponly2 dhcp]# ls -lah
total 16K
drwxr-x---.  3 root root  23 Dec 23 23:47 .
drwxr-xr-x. 87 root root 12K Dec 24 01:00 ..
drwxr-xr-x.  2 root root  45 Dec 23 23:41 dhclient.d
[root@cponly2 dhcp]# ls -lah dhclient.d/
total 8.0K
drwxr-xr-x. 2 root root   45 Dec 23 23:41 .
drwxr-x---. 3 root root   23 Dec 23 23:47 ..
-rwxr-xr-x. 1 root root 2.2K Nov 14 16:18 ntp.sh
-rw-r--r--. 1 root root   41 Dec 23 23:41 set_hostname.sh

我尝试添加脚本set_hostname.sh来更改主机名但没有成功。

我还尝试通过元数据设置主机名,但在重新启动VM /实例时,主机名未正确设置。我已经验证了元数据存在于:

curl "http://metadata.google.internal/computeMetadata/v1/instance/hostname" -H "Metadata-Flavor: Google"

未返回"自定义元数据"我为这个特定的VM设置了,但不断返回instance-name.c.project-id.internal

重新启动网络时,

/ var / log / messages如下所示:

Dec 24 21:05:38 cponly2 systemd: Starting LSB: Bring up/down networking...
Dec 24 21:05:38 cponly2 kernel: IPv6: ADDRCONF(NETDEV_UP): lo: link is not ready
Dec 24 21:05:38 cponly2 NetworkManager[543]: <info>  [1482613538.4466] device (lo): link connected
Dec 24 21:05:38 cponly2 network: Bringing up loopback interface:  [  OK  ]
Dec 24 21:05:38 cponly2 NetworkManager[543]: <info>  [1482613538.6687] device (eth0): Activation: starting connection 'eth0' (18214b23-9ad6-45df-9a5d-41355fa07c59)
Dec 24 21:05:38 cponly2 NetworkManager[543]: <info>  [1482613538.6688] audit: op="connection-activate" uuid="18214b23-9ad6-45df-9a5d-41355fa07c59" name="eth0" pid=25261 uid=0 result="success"
Dec 24 21:05:38 cponly2 NetworkManager[543]: <info>  [1482613538.6689] device (eth0): state change: disconnected -> prepare (reason 'none') [30 40 0]
Dec 24 21:05:38 cponly2 NetworkManager[543]: <info>  [1482613538.6690] manager: NetworkManager state is now CONNECTING
Dec 24 21:05:38 cponly2 NetworkManager[543]: <info>  [1482613538.6692] device (eth0): state change: prepare -> config (reason 'none') [40 50 0]
Dec 24 21:05:38 cponly2 NetworkManager[543]: <info>  [1482613538.6890] device (eth0): state change: config -> ip-config (reason 'none') [50 70 0]
Dec 24 21:05:38 cponly2 NetworkManager[543]: <info>  [1482613538.6896] dhcp4 (eth0): activation: beginning transaction (timeout in 45 seconds)
Dec 24 21:05:38 cponly2 kernel: IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
Dec 24 21:05:38 cponly2 NetworkManager[543]: <info>  [1482613538.7046] dhcp4 (eth0): dhclient started with pid 25268
Dec 24 21:05:38 cponly2 dhclient[25268]: DHCPREQUEST on eth0 to 255.255.255.255 port 67 (xid=0xba5315d)
Dec 24 21:05:38 cponly2 dhclient[25268]: DHCPACK from 169.254.169.254 (xid=0xba5315d)
Dec 24 21:05:38 cponly2 NetworkManager[543]: <info>  [1482613538.7352] dhcp4 (eth0):   address 10.142.0.2
Dec 24 21:05:38 cponly2 NetworkManager[543]: <info>  [1482613538.7355] dhcp4 (eth0):   plen 32 (255.255.255.255)
Dec 24 21:05:38 cponly2 NetworkManager[543]: <info>  [1482613538.7355] dhcp4 (eth0):   classless static route 10.142.0.1/32 gw 0.0.0.0
Dec 24 21:05:38 cponly2 NetworkManager[543]: <info>  [1482613538.7355] dhcp4 (eth0):   gateway 10.142.0.1
Dec 24 21:05:38 cponly2 NetworkManager[543]: <info>  [1482613538.7355] dhcp4 (eth0):   server identifier 169.254.169.254
Dec 24 21:05:38 cponly2 NetworkManager[543]: <info>  [1482613538.7355] dhcp4 (eth0):   lease time 86400
Dec 24 21:05:38 cponly2 NetworkManager[543]: <info>  [1482613538.7355] dhcp4 (eth0):   hostname 'cponly2.c.test.internal'
Dec 24 21:05:38 cponly2 NetworkManager[543]: <info>  [1482613538.7355] dhcp4 (eth0):   nameserver '169.254.169.254'
Dec 24 21:05:38 cponly2 NetworkManager[543]: <info>  [1482613538.7355] dhcp4 (eth0):   domain name 'c.test.internal.'
Dec 24 21:05:38 cponly2 NetworkManager[543]: <info>  [1482613538.7356] dhcp (eth0):   domain search 'c.test.internal.'
Dec 24 21:05:38 cponly2 NetworkManager[543]: <info>  [1482613538.7356] dhcp4 (eth0): state changed unknown -> bound
Dec 24 21:05:38 cponly2 NetworkManager[543]: <info>  [1482613538.7363] device (eth0): state change: ip-config -> ip-check (reason 'none') [70 80 0]
Dec 24 21:05:38 cponly2 avahi-daemon[342]: Joining mDNS multicast group on interface eth0.IPv4 with address 10.142.0.2.
Dec 24 21:05:38 cponly2 avahi-daemon[342]: New relevant interface eth0.IPv4 for mDNS.
Dec 24 21:05:38 cponly2 avahi-daemon[342]: Registering new address record for 10.142.0.2 on eth0.IPv4.

所以这让我相信NetworkManager正在使用中,进一步检查它看起来像ifcfg-rh插件的设置。阅读一些NetworkManager settings documentation for&#34; ifcfg-rh&#34;插件持久主机名设置从/ etc / hostname中提取并回退到/ etc / sysconfig / network&#39; hostname&#39;它们都设置为我想要的主机名,但Google Compute引擎继续回退其内部名称。

不知道还有什么可以尝试,请事先感谢您的帮助。

0 个答案:

没有答案