Bug 1279393

Summary: Strange behaviour with DHCP exit hooks
Product: Red Hat Enterprise Linux 7 Reporter: Andrew Holway <andrew.holway>
Component: initscriptsAssignee: initscripts Maintenance Team <initscripts-maint-list>
Status: CLOSED DUPLICATE QA Contact: qe-baseos-daemons
Severity: medium Docs Contact:
Priority: unspecified    
Version: 7.1CC: andrew.holway
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-11-11 17:26:19 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:

Description Andrew Holway 2015-11-09 11:25:18 UTC
Description of problem:

for following /etc/dhcp/dhclient-exit-hooks causes some strange behavior with DHCP on AWS.

#!/bin/bash

OPTIONS="options timeout:1 attempts:1"

if grep -Fxq "$OPTIONS" /etc/resolv.conf
then
    exit
else
    echo "; generated by /etc/dhcp/dhclient-exit-hooks" >> /etc/resolv.conf
    echo ${OPTIONS} >> /etc/resolv.conf
fi


[root@piwik-prod-076 centos]# > /etc/resolv.conf 
[root@piwik-prod-076 centos]# tail -f /etc/resolv.conf 
; generated by /etc/dhcp/dhclient-exit-hooks
options timeout:1 attempts:1
tail: /etc/resolv.conf: file truncated
options timeout:1 attempts:1

In the end we just have an /etc/resolv.conf with "options timeout:1 attempts:1". It is very strange as the comment line "; generated by /etc/dhcp/dhclient-exit-hooks" gets written and then, as we can see with the above output, gets truncated. 


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

CentOS Linux release 7.1.1503 (Core) on AWS

How reproducible:

Easily reproducible with our env

Steps to Reproduce:
1. Set up dhclient-exit-hooks with the above
2. $> /etc/resolv.conf 
3  $tail -F on /etc/resolv.conf
3. systemctl network restart on another terminal.

Actual results:

[root@piwik-prod-076 centos]# cat /etc/resolv.conf 
options timeout:1 attempts:1
<extra line>

Expected results:

; generated by /etc/dhcp/dhclient-exit-hooks
options timeout:1 attempts:1
search cloud.foo.com
nameserver 1.2.3.4
nameserver 1.2.3.4

Additional info:

Using a custom dotp from AWS with two name servers and a search domain.

[root@piwik-prod-076 centos]# tcpdump -i eth0 port 67 or port 68 -e -n -vvv
tcpdump: listening on eth0, link-type EN10MB (Ethernet), capture size 65535 bytes
10:55:36.212268 02:32:0d:4e:ce:2f > Broadcast, ethertype IPv4 (0x0800), length 342: (tos 0x10, ttl 128, id 0, offset 0, flags [none], proto UDP (17), length 328)
    0.0.0.0.bootpc > 255.255.255.255.bootps: [udp sum ok] BOOTP/DHCP, Request from 02:32:0d:4e:ce:2f, length 300, xid 0xb9586021, Flags [none] (0x0000)
	  Client-Ethernet-Address 02:32:0d:4e:ce:2f
	  Vendor-rfc1048 Extensions
	    Magic Cookie 0x63825363
	    DHCP-Message Option 53, length 1: Request
	    Requested-IP Option 50, length 4: 10.141.5.132
	    Parameter-Request Option 55, length 13: 
	      Subnet-Mask, BR, Time-Zone, Classless-Static-Route
	      Domain-Name, Domain-Name-Server, Hostname, YD
	      YS, NTP, MTU, Option 119
	      Default-Gateway
	    END Option 255, length 0
	    PAD Option 0, length 0, occurs 35
10:55:36.212767 02:85:83:3b:2a:47 > 02:32:0d:4e:ce:2f, ethertype IPv4 (0x0800), length 363: (tos 0x10, ttl 16, id 0, offset 0, flags [none], proto UDP (17), length 349)
    10.141.5.1.bootps > 10.141.5.132.bootpc: [udp sum ok] BOOTP/DHCP, Reply, length 321, xid 0xb9586021, Flags [none] (0x0000)
	  Your-IP 10.141.5.132
	  Client-Ethernet-Address 02:32:0d:4e:ce:2f
	  Vendor-rfc1048 Extensions
	    Magic Cookie 0x63825363
	    DHCP-Message Option 53, length 1: ACK
	    Server-ID Option 54, length 4: 10.141.5.1
	    Lease-Time Option 51, length 4: 3600
	    Subnet-Mask Option 1, length 4: 255.255.255.0
	    BR Option 28, length 4: 10.141.5.255
	    Domain-Name Option 15, length 14: "cloud.dcmn.com"
	    Domain-Name-Server Option 6, length 8: 10.141.10.231,10.141.9.153
	    Hostname Option 12, length 15: "ip-10-141-5-132"
	    MTU Option 26, length 2: 9001
	    Default-Gateway Option 3, length 4: 10.141.5.1
	    END Option 255, length 0

Comment 2 Jiri Popelka 2015-11-11 17:26:19 UTC
Most likely duplicate of bug #1212883

*** This bug has been marked as a duplicate of bug 1212883 ***