Changing the system Host Name
A static Host Name can be specified in the /etc/hostname .
Older version of RHEL(RHEL 6 and previous version) stores host name in /etc/sysconfig/network
The hostnamectl command is used to modify the file /etc/hostname .
If the file doesn't exist hostname is set by Reverse DNS query once the interface has an IP address.
[root@rhel7-server1 ~]# hostnamectl set-hostname server1.example.com [root@rhel7-server1 ~]# hostnamectl status Static hostname: server1.example.com Icon name: computer-vm Chassis: vm Machine ID: 6208cf32c49449969e11e369a02b77d8 Boot ID: 7e4ae6a0fa4d4e989928c0d2b40b7205 Virtualization: kvm Operating System: Red Hat Enterprise Linux Server 7.3 (Maipo) CPE OS Name: cpe:/o:redhat:enterprise_linux:7.3:GA:server Kernel: Linux 3.10.0-514.el7.x86_64 Architecture: x86-64 [root@rhel7-server1 ~]# cat /etc/hostname server1.example.com
Configure Name Resolution
The stub resolver is used to convert host names to IP addresses or the reverse.
The Stub resolver check the following things for Name Resolution in the the order
- /etc/hosts are checked first
- /etc/resolv.conf , If the entry is not found in /etc/hosts file, Stub resolver looks for DNS nameservers in /etc/resolv.conf
[root@server1 ~]# cat /etc/resolv.conf
# Generated by NetworkManager
search example.com
nameserver 192.168.18.1
nameserver The IP address of a nameserver to query.
Up to three nameserver directive may be given to provide backups if one is down.
search a list of domain names to try with a short host names.
NetworkManager will update the /etc/resolve.conf file using DNS setting in the connection configuration files. Use the nmcli to modify the connection.
[root@server1 ~]# nmcli connection modify "default" +ipv4.dns 8.8.8.8
[root@server1 ~]# nmcli connection up "default"
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/4)
[root@server1 ~]# nmcli connection show "default" | grep IP4.DNS
IP4.DNS[1]: 192.168.18.1
IP4.DNS[2]: 8.8.8.8
[root@server1 ~]# cat /etc/resolv.conf
# Generated by NetworkManager
search example.com
nameserver 192.168.18.1
nameserver 8.8.8.8
The default behavior of nmcli con mod ipv4.dns IP is to replace any previus DNS setting with the new IP list provided.
A +/- symbol in front of the ipv4.dns argument will add or remove an individual entry.
getent hosts server1 - Used to test name resolution with the /etc/hosts
host server1.example.com - used to resolve name using DNS server
Important
If DHCP is in use, /etc/resolv.conf is automatically rewritten as interface are started. Unless you specify PEERDNS=no in the relevant interface configuration files.
This can be change can be made with nmcli
[root@server1 ~]# nmcli connection modify "default" ipv4.ignore-auto-dns yes
No comments:
Post a Comment