In my OpenStack instance, resolv.conf is automatically updating with below entries:
search openstacklocal
nameserver 10.10.10.21
nameserver 10.10.10.22
nameserver 10.10.10.20
I dont want any DNS entries in my resolv.conf file. I have tried manage-resolv-conf: false in cloud.cfg file but no luck.
Related
I am running Ubuntu 18.04 in a VM. When I check the hostname using hostname or the fully qualified domain name using hostname -f, hostname --fqdn or hostnamectl I get the default ubuntu for each. I want to permanently update the hostname to host and the fully qualified domain name to host.okd.dns.
I have changed the file /etc/hostname to include only the name host. I have also changed the file /etc/hosts to appear as follows (excluding IPv6 hosts):
127.0.0.1 localhost
127.0.1.1 host.okd.dns
After saving and rebooting the VM, when I check hostname it returns host as expected, but when I check the FQDN using hostname -f, hostname --fqdn or hostnamectl it also returns host only without the .okd.dns appended to it as I would expect.
There seem to be several methods of updating the FQDN for Ubuntu 18.04 and I have tried most of them, including this method, which seems to be the most common. What do I need to do to get the changes to the FQDN to update and stick?
Apparently, I needed to add host after host.okd.dns in the /etc/hosts file. I was sure I had tried this in the past, but perhaps there was some other error I had made somewhere and this wasn't reflected. Once doing this and after a reboot, hostname -f and hostname --fqdn both return host.okd.dns as expected.
I have configure my DNS in resolv.conf but it is clearing anytime the system reboots. Pls how do i configure DNS on Debian 9 to remain after reboot.
thanks
I but the line dns-nameserver 8.8.8.8 8.8.4.4 1.1.1.1 in the interfaces but not working, also I but the same line in resolv.conf but clear after system reboot
Check if the file /etc/resolv.conf contains the line
# Generated by NetworkManager
NetworkManager's configuration can be set to avoid the flushing.
I want my setup of openstack to work such that when I boot a new instance, 8.8.8.8 should be added to dns-nameservers.
This is my old /etc/resolv.conf (in the new VM which was spawned in openstack)-
nameserver 10.0.0.2
search openstacklocal
And this is the new resolv.conf that I want -
nameserver 8.8.8.8
nameserver 10.0.0.2
search openstacklocal
I followed this tutorial, and
I have added the necessary info. of resolv conf to my config file(/etc/cloud/cloud.cfg) of cloud-init -
manage_resolv_conf: true
resolv_conf:
nameservers: ['8.8.4.4', '8.8.8.8']
searchdomains:
- foo.example.com
- bar.example.com
domain: example.com
options:
rotate: true
timeout: 1
These changes are made in /etc/cloud/cloud.cfg file of the openstack host.
However, the changes don't seem to get reflected.
Any suggestions?
It will not work because cloud-init networking configuration occurs too early in the boot process.
See cloud-init stages: https://cloudinit.readthedocs.io/en/latest/topics/boot.html
Network configuration is done in the "Local" stage, but the user-data from Openstack is only downloaded at the "Config" stage after network is up. At this stage, the network configuration is ignored.
Instead, you need to edit networking files then bring interfaces up by passing commands to cloud-init with runcmd.
Cloud-init overwrites the entry of /etc/sysconfig/network file as well as resolv.conf . To disable this you can create a custom rule for cloud-init config by creating a file /etc/cloud/cloud.cfg.d/custom-network-rule.cfg which contains -
network: {config: disabled}
How to dynamically update /etc/hosts file with saltstack.
There is example that works with ansible great, but don't know how to do it with salt.
http://xmeblog.blogspot.fr/2013/06/ansible-dynamicaly-update-etchosts.html
- name: add hostname in /etc/hosts
lineinfile: dest=/etc/hosts regexp='.*{{ item }}$' line="{{ hostvars[item]['ansible_default_ipv4']['address'] }} {{item}}" state=present
when: hostvars[item]['ansible_default_ipv4']['address'] is defined
with_items: groups['all']
This will update /etc/hosts with all ansible hosts-ip and host address available in inventory file.
How it is possible with salt?
I want to collect all minions ip address and hostname and update it on all minions /etc/hosts.
minion1 => ip (192.168.1.1) hostname is (example1.net)
minion2 => ip (192.168.1.2) hostname is (example2.net)
minion3 => ip (192.168.1.3) hostname is (example3.net)
In all minions /etc/hosts file entry should be like:
127.0.0.1 localhost
::1 localhost
192.168.1.1 example1.net
192.168.1.2 example2.net
192.168.1.3 example3.net
Please take a look into https://github.com/saltstack-formulas/hostsfile-formula, hopefully it suits your needs.
This particular formula allows to 'automagically' create /etc/hosts records for all known minions.
Please no, I've noticed the formula link to Formula Documentation has been broken, try this one instead Salt Formulas installation and usage instructions.
Salt Formulas explained
Formulas are pre-written Salt States. They are as open-ended as Salt States themselves and can be used for tasks such as installing a package, configuring and starting a service, setting up users or permissions, and many other common tasks.
here are some configuration files from the virtualbox on centos5.5, i've restart the network,but also can't connect to the internet, no gateway records information listed using route command, however,while i typing "route add default gw 192.168.0.1" and it works well.how shoud i configurate the gateway ip? thanks in advance.
/etc/resolv.conf
nameserver 8.8.8.8
nameserver 8.8.4.4
/etc/sysconfig/network
GATEWAY=192.169.0.1
NETWORKING=yes
HOSTNAME=localhost
/etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE="eth0"
HWADDR="00:24:1D:8A:3D:F7"
ONBOOT="yes"
BOOTPROTO="static"
BROADCAST="192.168.0.255"
NETWORY="192.168.0.1"
IPADDR="192.168.0.109"
NETMASK="255.255.0.0"
CentOS 5 should have file route-eth0 (in /etc/sysconfig/network-scripts )
put this string into it:
default X.X.X.X dev interface
make sure you change X.X.X.X and interface to your.
Btw, take a look to http://www.centos.org/docs/5/html/5.1/Deployment_Guide/s1-networkscripts-static-routes.html