Get the most out of your Centmin Mod LEMP stack
Become a Member

Centos network manager on Centos 7.2 revert settings from /etc/hosts and /etc/resolv.conf

Discussion in 'System Administration' started by pamamolf, Feb 5, 2016.

  1. pamamolf

    pamamolf Premium Member Premium Member

    4,087
    428
    83
    May 31, 2014
    Ratings:
    +834
    Local Time:
    12:34 PM
    Nginx-1.25.x
    MariaDB 10.3.x
    Hi

    Centos network manager on Centos 7.2 revert settings from /etc/hosts and /etc/resolv.conf and create network issues :(

    Anyone with any tips related?


    Thank you
     
  2. eva2000

    eva2000 Administrator Staff Member

    54,935
    12,240
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,812
    Local Time:
    8:34 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
  3. pamamolf

    pamamolf Premium Member Premium Member

    4,087
    428
    83
    May 31, 2014
    Ratings:
    +834
    Local Time:
    12:34 PM
    Nginx-1.25.x
    MariaDB 10.3.x
    Great but do you think that is related to the overwrite also here? :

    Code:
    /etc/hosts
     
  4. eva2000

    eva2000 Administrator Staff Member

    54,935
    12,240
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,812
    Local Time:
    8:34 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    who's the web host ? what virtualisation ? xen, openvz, kvm, vmware ?

    could be elated to cloud.cfg on some virtual machines not sure
    i.e. on Vultr /etc/cloud/cloud.cfg
    Code:
    users:
    - default
    
    disable_root: 1
    ssh_pwauth:   0
    
    locale_configfile: /etc/sysconfig/i18n
    mount_default_fields: [~, ~, 'auto', 'defaults,nofail', '0', '2']
    resize_rootfs_tmp: /dev
    ssh_deletekeys:   0
    ssh_genkeytypes:  ~
    syslog_fix_perms: ~
    
    cloud_init_modules:
    - migrator
    - bootcmd
    - write-files
    - growpart
    - resizefs
    - set_hostname
    - update_hostname
    - update_etc_hosts
    - rsyslog
    - users-groups
    - ssh
    
    cloud_config_modules:
    - mounts
    - locale
    - set-passwords
    - yum-add-repo
    - package-update-upgrade-install
    - timezone
    - puppet
    - chef
    - salt-minion
    - mcollective
    - disable-ec2-metadata
    - runcmd
    
    cloud_final_modules:
    - rightscale_userdata
    - scripts-per-once
    - scripts-per-boot
    - scripts-per-instance
    - scripts-user
    - ssh-authkey-fingerprints
    - keys-to-console
    - phone-home
    - final-message
    
    system_info:
      default_user:
        name: centos
        lock_passwd: true
        gecos: Cloud User
        groups: [wheel, adm, systemd-journal]
        sudo: ["ALL=(ALL) NOPASSWD:ALL"]
        shell: /bin/bash
      distro: rhel
      paths:
        cloud_dir: /var/lib/cloud
        templates_dir: /etc/cloud/templates
      ssh_svcname: sshd
    
    # vim:syntax=yaml
    
    Code:
    ls -lahR /etc/cloud/
    /etc/cloud/:
    total 28K
    drwxr-xr-x  4 root root 4.0K Aug 10 14:04 .
    drwxr-xr-x 92 root root  12K Feb  4 16:45 ..
    -rw-rw-r--  1 root root 1.2K Jul 29  2014 cloud.cfg
    drwxr-xr-x  2 root root 4.0K Aug 10 14:04 cloud.cfg.d
    drwxr-xr-x  2 root root 4.0K Aug 10 14:04 templates
    
    /etc/cloud/cloud.cfg.d:
    total 20K
    drwxr-xr-x 2 root root 4.0K Aug 10 14:04 .
    drwxr-xr-x 4 root root 4.0K Aug 10 14:04 ..
    -rw-r--r-- 1 root root 1.9K Apr  1  2014 05_logging.cfg
    -rw-r--r-- 1 root root  679 Aug 10 14:04 90_vultr.cfg
    -rw-r--r-- 1 root root  141 Apr  1  2014 README
    
    /etc/cloud/templates:
    total 36K
    drwxr-xr-x 2 root root 4.0K Aug 10 14:04 .
    drwxr-xr-x 4 root root 4.0K Aug 10 14:04 ..
    -rw-r--r-- 1 root root  892 Apr  1  2014 chef_client.rb.tmpl
    -rw-r--r-- 1 root root  934 Apr  1  2014 hosts.debian.tmpl
    -rw-r--r-- 1 root root  906 Apr  1  2014 hosts.redhat.tmpl
    -rw-r--r-- 1 root root  862 Apr  1  2014 hosts.suse.tmpl
    -rw-r--r-- 1 root root  785 Apr  1  2014 resolv.conf.tmpl
    -rw-r--r-- 1 root root 1.5K Apr  1  2014 sources.list.debian.tmpl
    -rw-r--r-- 1 root root 2.8K Apr  1  2014 sources.list.ubuntu.tmpl
    from /etc/cloud/templates/hosts.redhat.tmpl
    Code:
    #*
        This file /etc/cloud/templates/hosts.redhat.tmpl is only utilized
        if enabled in cloud-config.  Specifically, in order to enable it
        you need to add the following to config:
          manage_etc_hosts: True
    *#
    # 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 ${fqdn} ${hostname}
    127.0.0.1 localhost.localdomain localhost
    127.0.0.1 localhost4.localdomain4 localhost4
    
    # The following lines are desirable for IPv6 capable hosts
    ::1 ${fqdn} ${hostname}
    ::1 localhost.localdomain localhost
    ::1 localhost6.localdomain6 localhost6
    
    so you could add your custom /etc/hosts entry into template at /etc/cloud/templates/hosts.redhat.tmpl

    for /etc/resolv.conf and /etc/cloud/templates/resolv.conf.tmpl
    Code:
    #
    # Your system has been configured with 'manage-resolv-conf' set to true.
    # As a result, cloud-init has written this file with configuration data
    # that it has been provided. Cloud-init, by default, will write this file
    # a single time (PER_ONCE).
    #
    
    #if $varExists('nameservers')
    #for $server in $nameservers
    nameserver $server
    #end for
    #end if
    #if $varExists('searchdomains')
    search #slurp
    #for $search in $searchdomains
    $search #slurp
    #end for
    
    #end if
    #if $varExists('domain')
    domain $domain
    #end if
    #if $varExists('sortlist')
    sortlist #slurp
    #for $sort in $sortlist
    $sort #slurp
    #end for
    
    #end if
    #if $varExists('options') or $varExists('flags')
    options #slurp
    #for $flag in $flags
    $flag #slurp
    #end for
    #for $key, $value in $options.items()
    $key:$value #slurp
    #end for
    
    #end if
    
     
  5. pamamolf

    pamamolf Premium Member Premium Member

    4,087
    428
    83
    May 31, 2014
    Ratings:
    +834
    Local Time:
    12:34 PM
    Nginx-1.25.x
    MariaDB 10.3.x
    It is a dedicated server without any virtualisation software....