Bug 1411687

Summary: [WALA] Fail to send hostname to DHCP server during provisioning
Product: Red Hat Enterprise Linux 7 Reporter: Yuhui Jiang <yujiang>
Component: WALinuxAgentAssignee: Vitaly Kuznetsov <vkuznets>
Status: CLOSED CURRENTRELEASE QA Contact: Virtualization Bugs <virt-bugs>
Severity: urgent Docs Contact:
Priority: high    
Version: 7.3CC: anderson, borisb, brendand, danis, hkrijger, jboutaud, jjarvis, jopoulso, jreznik, leiwang, mheslin, mrezanin, mtessun, salmy, snagar, stephen.zarkos, vkuznets, wshi, yujiang, yuxisun
Target Milestone: rcKeywords: Extras, ZStream
Target Release: 7.4   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: WALinuxAgent-2.2.0-4.el7 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 1413674 (view as bug list) Environment:
Last Closed: 2017-01-26 06:32:57 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1413674    

Description Yuhui Jiang 2017-01-10 09:57:58 UTC
Description of problem:
In RHEL-7, if NetworkManager is enabled, the hostname is not sent to DHCP server during provisioning, so that the VM internal DNS is not set to the DNS server.

Version-Release number of selected component (if applicable):
WALinuxAgent-2.2.0+

RHEL Version:
RHEL-7.3
NetworkManager-1.4.0-12

How reproducible:
100%

Steps to Reproduce:
1. Create a RHEL-7.3 VM on Azure with WALA-2.2.0+ installed(NetworkManager enabled)
2. Check if send hostname to DHCP server:
~]# cat /var/lib/NetworkManager/dhclient-eth0.conf|grep send
There's no "send host-name" line.
3. Check DNS:
1). Get domain-name(like wala73220e.i6.internal.cloudapp.net): cat /etc/resolv.conf|grep search
2). Get hostname(like wala73220e): cat /etc/hostname
3). Check DNS:
~]# nslookup wala73220e.wala73220e.i6.internal.cloudapp.net
Server:                168.63.129.16
Address:        168.63.129.16#53

** server can't find wala73220e.wala73220e.i6.internal.cloudapp.net: NXDOMAIN

Actual Result:
The hostname is not sent to the DHCP server
The domain name is not added into DNS server

Expect Result:
The hostname is sent to the DHCP server, such as:
~]# cat /var/lib/NetworkManager/dhclient-eth0.conf |grep send
send host-name "wala73220e"; # added by NetworkManager

The domain name is added into DNS server, such as:
~]# nslookup wala73220e.wala73220e.i6.internal.cloudapp.net
Server:                168.63.129.16
Address:        168.63.129.16#53

Name:        wala73220e.wala73220e.i6.internal.cloudapp.net
Address: 10.0.0.5


Additional Info:
There're 2 root causes:

1. WALA-2.2.0 use "hostname" and write "/etc/hostname" file to set hostname, which cannot send hostname message into dbus. NetworkManager get hostname from dbus, then add "send host-name" into /var/lib/NetworkManager/dhclient-eth0.conf

2. WALA-2.2.0 write "DHCP_HOSTNAME=hostname" into /etc/sysconfig/network-scripts/ifcfg-eth0, but there's no '\n' after this line. So that NetworkManager cannot read it.

NetworkManager sends the hostname to the DHCP server using the following strategy:
- if the ifcfg file specifies a DHCP_HOSTNAME, that value is sent to the DHCP server

- if DHCP_HOSTNAME is not set, NM uses the system hostname set through hostnamectl, but only if it is not '(none)', 'localhost', 'localhost6' or 'localhost.localdomain'. If it is one of these, no hostname is sent

According to the NetworkManager developer suggestion, the best way to have NetworkManager send the hostname is to simply set a valid system hostname using 'hostnamectl set-hostname myhostname' and reactivate the connection with ifup.
The DHCP_HOSTNAME is only a way to override the system configured hostname.

So we suggest to:
1. use "hostnamectl set-hostname" command to set hostname in RHEL-7.
2. remove the "DHCP_HOSTNAME".