腾讯云Centos7服务器修改/etc/hosts

第一次在腾讯云购买了服务器,然后我需要修改/etc/hosts文件测试安装iRedmail邮件服务器,一打开/etc/hosts文件便如以下:

# Your system has configured 'manage_etc_hosts' as True.
# As a result, if you wish for changes to this file to persist
# then you will need to either
# a.) make changes to the master file in /etc/cloud/templates/hosts.redhat.tmpl
# b.) change or remove the value of 'manage_etc_hosts' in
#     /etc/cloud/cloud.cfg or cloud-config from user-data
# 
# The following lines are desirable for IPv4 capable hosts
127.0.0.1 VM_0_12_centos VM_0_12_centos
127.0.0.1 localhost.localdomain localhost
127.0.0.1 localhost4.localdomain4 localhost4

# The following lines are desirable for IPv6 capable hosts
::1 VM_0_12_centos VM_0_12_centos
::1 localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6

修改方式和常规的直接修改方式的不一样,直接对/etc/hosts文件进行修改,比如直接添加 127.0.0.1  mail.chenxie.net 到/etc/hosts ,保存后虽然ping mail.chenxie.net可以通,但是iRedmail的安装检测脚本通不过,而且重启系统后添加的记录就消失了。

文件注释说,我的系统配置了manage_etc_hosts为True,如果要修改hosts的话

a. 需要先对/etc/cloud/templates/hosts.redhat.tmpl进行修改,

b. 然后修改或删除manage_etc_hosts的值在/etc/cloud/cloud.cfg文件中。

第一步,修改/etc/cloud/templates/hosts.redhat.tmpl文件:

直接添加你要在/etc/hosts文件中出现的文件内容:

127.0.0.1 mail.chenxie.net

关于第二步,修改manage_etc_hosts的值,在/etc/cloud/cloud.cfg文件中没有找到,那就忘掉吧。

最后reboot重启你的机器生效。

说明:安装iRadMail还要修改主机名,本次没有仔细看文档也吃了点亏,修改/etc/hostname,然后reboot生效。

版权声明:
作者:admin
链接:https://www.chenxie.net/archives/1670.html
来源:蜀小陈
文章版权归作者所有,未经允许请勿转载。

THE END
分享
二维码
< <上一篇
下一篇>>