Bug 139532

Summary: dhcp client doesn't transmit /etc/HOSTNAME any longer
Product: [openSUSE] SUSE Linux 10.1 Reporter: Andreas Kleen <ak>
Component: NetworkAssignee: Ruediger Oertel <ro>
Status: VERIFIED FIXED QA Contact: E-mail List <qa-bugs>
Severity: Major    
Priority: P5 - None CC: aj, ccox, meissner, suse-beta
Version: Beta 3   
Target Milestone: ---   
Hardware: Other   
OS: Other   
Whiteboard:
Found By: Other Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---
Attachments: Patch to add command line flag to dhclient to accept a hostname to send to the DHCP server

Description Andreas Kleen 2005-12-16 03:14:55 UTC
With Network Manager running the dhcp client doesn't seem to transmit
the host name to the DHCP server any longer.

/etc/HOSTNAME is set and /etc/sysconfig/network/dhcp has
DHCLIENT_HOSTNAME_OPTION="AUTO"

This is a problem in networks where the name server is set up automatically
from this hostname. Name resolution for the host doesn't work anymore.
Comment 1 Peter Poeml 2005-12-21 11:47:03 UTC
It is implemented only with dhcpcd.

To get dhclient to do this, it needs to be configured for that.
Probably this needs to be done by NetworkManager, I assume it writes a
configuration (or does it use the default file only?). 

The configuration is described in man dhclient.conf, see fqdn.

Robert?
Comment 2 Andreas Kleen 2006-02-07 18:20:44 UTC
The problem is still there in beta3. Any news?
Comment 3 Robert Love 2006-02-07 18:24:17 UTC
Timo, what would it take to support this?  I suppose we would have to modify NM and dhcdbd?
Comment 4 Timo Hoenig 2006-02-07 19:55:05 UTC
If I understood this issue correctly, we have to add

   send fqdn.fqdn "somehost.domain.com"
   send fqdn.encoded on;

to dhclient.conf in order to get dhclient sending the hostname.  Am I getting this right?

Two proposals:

1.) Let YaST write the entries to dhclient.conf once the hostname is changed by YaST.  If I got things right, YaST would have to remove those entries once DHCLIENT_HOSTNAME_OPTION is changed to "".

2.) Let NM modify dhclient.conf.  This is not nice as one might use dhclient _without_ NM.  In this case, dhclient.conf we can not ensure that it reflects the latest settings of DHCLIENT_HOSTNAME_OPTION.

With 1.) we still have a bad configuration if a user decides to edit /etc/sysconfig/network/dhcp by hand.  But this is less frequent than running dhclient by manually, I guess.

Any comments from the experts?

cc'ing Christian.
Comment 5 Timo Hoenig 2006-02-14 20:46:43 UTC
Peter, Christian, could you please comment?  I'd love to see this one fixed.
Comment 6 Christian Zoz 2006-02-16 07:53:25 UTC
Proposal 1 is imho an bad idea.

Better use
  dhclient -cf <NM dhclient config file>
This will not conflict with running dhclient manually.
Comment 7 Peter Poeml 2006-02-16 15:10:56 UTC
I agree with Christian.
Comment 8 Robert Love 2006-02-16 17:28:55 UTC
Timo?  You looked into this more than I, what do you think?
Comment 9 Timo Hoenig 2006-02-16 17:45:26 UTC
On IRC, ak mentioned that Fedora has some magic to solve this problem.  It would definitely be nice to merge this with our setup.
Comment 10 Christian Zoz 2006-02-17 07:25:10 UTC
Would you tell us more about that magic?
Comment 11 Timo Hoenig 2006-02-17 12:15:48 UTC
No, as I don't know more than what I've stated in comment #9,  I don't even know whether it is magic.
Comment 12 Timo Hoenig 2006-02-17 12:17:56 UTC
Danny, how recent is the Fedora installation you got?
Comment 13 Andreas Kleen 2006-02-17 12:19:45 UTC
From a yellowdog system (should be older fedora based)'s ifup:

Doesn't look very magic to me.

 Remove any temporary references which were previously added to dhclient config
if [ -w /etc/dhclient-${DEVICE}.conf ] && [ -x /sbin/dhclient ] ; then
   LC_ALL=C grep -v "# temporary RHL ifup addition" /etc/dhclient-${DEVICE}.conf > /etc/dhclient-${DEVICE}.co
nf.ifupnew 2> /dev/null
   cat /etc/dhclient-${DEVICE}.conf.ifupnew > /etc/dhclient-${DEVICE}.conf
   rm -f /etc/dhclient-${DEVICE}.conf.ifupnew
fi
                     
if [ -n "${DYNCONFIG}" ]; then
    PUMPARGS=$PUMPARGS
    DHCPCDARGS="$DHCPCDARGS -n"
    DHCLIENTARGS="${DHCLIENTARGS} -1 -q -lf /var/lib/dhcp/dhclient-${DEVICE}.leases -pf /var/run/dhclient-${D
EVICE}.pid -cf /etc/dhclient-${DEVICE}.conf"
    if [ -n "${DHCP_HOSTNAME}" ]; then
       # Send a host-name to the DHCP server (requ. by some dhcp servers).
       PUMPARGS="${PUMPARGS} -h ${DHCP_HOSTNAME}"
       DHCPCDARGS="${DHCPCDARGS} -h ${DHCP_HOSTNAME}"
       if [ -x /sbin/dhclient ] ; then
          if [ -w /etc/dhclient-${DEVICE}.conf ] ; then
             if ! LC_ALL=C grep "send *host-name *\"${DHCP_HOSTNAME}\"" /etc/dhclient-${DEVICE}.conf > /dev/n
ull 2>&1 ; then
                echo "send host-name \"${DHCP_HOSTNAME}\";  # temporary RHL ifup addition" >> /etc/dhclient-$
{DEVICE}.conf
             fi
          elif ! [ -e /etc/dhclient-${DEVICE}.conf ] ; then
             echo "send host-name \"${DHCP_HOSTNAME}\";  # temporary RHL ifup addition" >> /etc/dhclient-${DE
VICE}.conf
          fi
       fi
    fi
    if need_hostname; then
       # Set hostname of host to host-name option supplied by DHCP.
       PUMPARGS="${PUMPARGS} --lookup-hostname"
       DHCPCDARGS="${DHCPCDARGS} -H"
    fi
    if [ "${PEERDNS}" = "no" ]; then
       # Do not update/replace resolv.conf.
       PUMPARGS="${PUMPARGS} -d"
       DHCPCDARGS="${DHCPCDARGS} -R"
    fi
    echo
    echo -n $"Determining IP information for ${DEVICE}..."
    if check_link_down ${DEVICE}; then
        echo $" failed; no link present.  Check cable?"
        ip link set dev ${DEVICE} down >/dev/null 2>&1
        exit 1
    fi
   if [ -n "$ETHTOOL_OPTS" ] ; then
        /sbin/ethtool -s ${REALDEVICE} $ETHTOOL_OPTS
    fi

    # DHCP clients need DNS to be available, and we don't know
    # what DNS server they're using until they are done.
    FWHACK=
    if [ -n "$FWACTIVE" -a "$FIREWALL_MODS" != "no" ]; then
        iptables -I RH-Lokkit-0-50-INPUT -m udp -s 0/0 --sport 53 -d 0/0 --dport 1025:65535 -p udp -j ACCEPT
        FWHACK=1
    fi
    
    if [ -x /sbin/dhclient ] && /sbin/dhclient ${DHCLIENTARGS} ${DEVICE} ; then
        echo $" done."
    elif [ -z "`pidof -x dhclient`" ] && [ -x /sbin/dhcpcd ] && /sbin/dhcpcd ${DHCPCDARGS} ${DEVICE} ; then
        echo $" done."
    elif [ -z "`pidof -x dhclient`" ] && [ -z "`pidof -x dhcpcd`" ] && [ -x /sbin/pump ] && /sbin/pump ${PUMP
ARGS} -i ${DEVICE}; then
        echo $" done."
    else
        echo $" failed."
        [ -n "$FWHACK" ] && iptables -D RH-Lokkit-0-50-INPUT -m udp -s 0/0 --sport 53 -d 0/0 --dport 1025:655
35 -p udp -j ACCEPT
        exit 1
    fi

    [ -n "$FWHACK" ] && iptables -D RH-Lokkit-0-50-INPUT -m udp -s 0/0 --sport 53 -d 0/0 --dport 1025:65535 -
p udp -j ACCEPT

    # DHCP likes to create duplicate routes.  Fix that up.
    NUMDEFROUTES=`ip -o route | \
                  awk '/^default/ { nlines++ } END { print nlines }'`
    if [ -n "$NUMDEFROUTES" ] && [ "$NUMDEFROUTES" -gt 1 ]; then
        # remove the default route for the new device (old route wins)
        ip route del default dev ${DEVICE}
    fi
# end dynamic device configuration
Comment 14 Danny Al-Gaaf 2006-02-17 12:40:43 UTC
Fedora Core 5 Test 2 (IMO with hal/dbus updates)
Comment 15 JP Rosevear 2006-03-28 19:40:41 UTC
Can we just add command lines arg for the fqdn host name and a flag to send it? 
Comment 16 JP Rosevear 2006-04-18 18:07:34 UTC
Hello?  Its been 3 weeks without a response.
Comment 17 Peter Poeml 2006-04-19 10:45:52 UTC
Is there a problem implementing the suggestion that Christian gave in
comment #6? (Doesn't NM generate a config file anyway?)

What kind of info can I provide?
Comment 18 Robert Love 2006-04-19 14:36:52 UTC
We currently do not touch the configuration file.
Comment 19 JP Rosevear 2006-04-20 12:55:07 UTC
*** Bug 167914 has been marked as a duplicate of this bug. ***
Comment 20 Peter Poeml 2006-04-20 13:15:20 UTC
*** Bug 167604 has been marked as a duplicate of this bug. ***
Comment 21 JP Rosevear 2006-04-24 13:54:22 UTC
Comment #17:

Peter, the information you could provide is whether or not its feasible to add command line options to dhclient to send the host name like the fqdn host name stuff in the config file.  If so, we can add NM support for this fairly easily.
Comment 22 Peter Poeml 2006-04-24 16:26:25 UTC
I don't think there is a way to pass options on the commandline,
currently. I don't know how feasible it would be to add it. I think the
easiest thing to do is to call dhclient with an ad hoc configuration
file which is /etc/dhclient.conf plus hostname option, as Christian has
suggested before.
Comment 23 Robert Love 2006-05-04 17:28:16 UTC
In the following attachment, find a patch to add an "-H <hostname>" option to dhclient that sends the given client hostname to the DHCP server via the "host-name" option.

I spoke with poeml earlier and we both agree that we want the "host-name" option, not the "fqdn.fqdn" option (which doesn't seem to work right, even if it was what we want).  Note that "host-name" is what the Fedora script Andi posted sent, too.
Comment 24 Robert Love 2006-05-04 17:29:52 UTC
Created attachment 82070 [details]
Patch to add command line flag to dhclient to accept a hostname to send to the DHCP server
Comment 25 Pete Goodall 2006-05-04 19:26:38 UTC
We definitely need this fixed.  Approved from my perspective.
Comment 26 Robert Love 2006-05-04 20:11:27 UTC
Thanks, Pete.

Alright -- The dhcdbd changes are now done as well, so we are all set and able to close this bug once the above patch is checked into autobuild.  I will commit the dhcdbd changes.  poeml, I would be happy to also commit the dhclient patch if you like.

The behavior with NetworkManager is now as follows:

If dhcp:DHCLIENT_HOSTNAME_OPTION is "AUTO", the hostname in /etc/HOSTNAME is sent to the DHCP server via the "host-name" option.

If dhcp:DHCLIENT_HOSTNAME_OPTION is "", we send nothing.

If dhcp:DHCLIENT_HOSTNAME_OPTION is non-empty but not "AUTO", that string is sent to the DHCP server.

This should be the expected behavior and resolve this bug.
Comment 27 Peter Poeml 2006-05-04 20:55:21 UTC
This is the behaviour as it should be, correct. I agree that it would be
very good to have this fixed. Robert, it would be very kind of you if
you go ahead and add the patch.

A final word regarding the confusion about the 'send host-name' versus
'send fqdn.fqdn etc' configuration: the former just sends a hostname
to the DHCP server (in the DHCPREQUEST). The latter sends a dynamic DNS
update attempt to a DNS server, which is not what we want. It is better
to let the DHCP server do the actual DNS update, because it is easier to
set this up securely.
Comment 28 Robert Love 2006-05-04 21:05:11 UTC
Excellent.

Submitted dhcdbd and dhcp package updates.  Bug is fixed.

This almost certainly won't make it for SUSE 10.1, but it will for SLES/SLED 10.

Thank you for the help, poeml.
Comment 29 Marcus Meissner 2006-05-06 07:30:27 UTC
should this be a candidate for a 10.1 YOU update?
Comment 30 Andreas Jaeger 2006-05-08 08:52:07 UTC
Yes, please!

MaintenanceTracker-4121
Comment 31 JP Rosevear 2006-05-08 13:04:59 UTC
I'm not so sure, note that this involves 3 different packages and only affects laptops by default in SL 10.1.
Comment 32 Robert Love 2006-05-08 14:17:13 UTC
Submitted packages and patchinfo for 10.1 YOU update.

If someone wants to confirm that I did every right, please do so.  ;-)
Comment 33 Ruediger Oertel 2006-05-10 10:23:18 UTC
the patchinfos mention SL10.0 and SL10.1. typo in the patchinfo files ?
Comment 34 Ruediger Oertel 2006-05-10 10:24:47 UTC
(the german translation for DESCRIPTION is still missing in the patchinfos
but I can take care of that)
Comment 35 JP Rosevear 2006-05-10 13:12:40 UTC
We should only put this out for 10.1, NM wasn't even a default for anything in 10.0.
Comment 36 Robert Love 2006-05-10 14:44:00 UTC
Yes, 10.1 only.

I spoke to ro and he will handle fixing the patchinfos.
Comment 37 Ruediger Oertel 2006-05-11 00:02:23 UTC
yes.
packages have been built in 10.1 and patchinfos have been checked in.
Comment 38 Anja Stock 2006-05-22 10:19:10 UTC
released