Debian DHCP configuration


17 posts
by MrEngman » Tue May 08, 2012 4:09 pm
I am using the latest Debian release and I have my RPi connected to a Windows network with a Windows2003 server running as a domain controller. I have no problems with internet/network access from the RPi BUT...

The Pi connects to the network OK but the W2003 server shows no hostname for the RPI, only the IP address so I can only access RPi across the network using the IP address - which remains unchanged after rebooting.

I have tried other distributions and the W2003 server shows the hostname with those and I can access the RPi from Windows using the host name, but not with Debian.

Guess there must be some configuration setting that must be set somewhere to report the hostname to the server during DHCP.

Can someone help, please? Answers using plain English rather than Linux speak would be prefered ;) as I'm still at Linux Primary School.

Thanks
Simplicity is a prerequisite for reliability. Edsger W. Dijkstra

Please post ALL technical questions on the forum. Please Do Not send private messages.
Posts: 3474
Joined: Fri Feb 03, 2012 2:17 pm
Location: Southampton, UK
by Paul Webster » Tue May 08, 2012 5:47 pm
I"ve not checked this with recent Debian - but old solution was: to add the following line to
/etc/dhcp3/dhclient.conf

send host-name "mypiname";
User avatar
Posts: 665
Joined: Sat Jul 30, 2011 4:49 am
Location: London, UK
by bredman » Tue May 08, 2012 5:51 pm
I have never successfully managed to get a Windows PC working with a Linux hostname, but this is only because I never really needed to.

Apparently, the magic bit is to install winbind on the Debian machine to support Windows name binding.

Search this forum for the word "winbind", it has been mentioned several times. You could also search the wider internet for "Debian winbind" to see if this helps.
Posts: 1415
Joined: Tue Jan 17, 2012 2:38 pm
by bredman » Tue May 08, 2012 5:54 pm
Paul Webster said:


I"ve not checked this with recent Debian - but old solution was: to add the following line to
/etc/dhcp3/dhclient.conf

send host-name "mypiname";


If this method works, it would be much cleaner to enter it as

send host-name "`hostname`"

Note the reverse quote marks. This means you do not need to edit dhclient.conf every time you change the hostname.
Posts: 1415
Joined: Tue Jan 17, 2012 2:38 pm
by MrEngman » Tue May 08, 2012 7:45 pm
Paul Webster said:


I"ve not checked this with recent Debian - but old solution was: to add the following line to
/etc/dhcp3/dhclient.conf

send host-name "mypiname";


and


bredman said:



I have never successfully managed to get a Windows PC working with a Linux hostname, but this is only because I never really needed to.

Apparently, the magic bit is to install winbind on the Debian machine to support Windows name binding.

Search this forum for the word "winbind", it has been mentioned several times. You could also search the wider internet for "Debian winbind" to see if this helps.



Thanks for the suggestions guys but no luck so far. I've installed winbind, again without any change, so need to look into that some more but it hasn't helped so far.

I have found a conf file (/etc/resolve.conf) that I guess has been automatically generated that references my internal domain name so things are not all bad.

Just a bit annoying that the distro I prefer - Debian - doesn't provide a host name to my server and the ones I prefer not to use do.

At least I have got my wifi working so the wife has stopped grumbling about network cables all over the lounge floor. ;)

Richard
Simplicity is a prerequisite for reliability. Edsger W. Dijkstra

Please post ALL technical questions on the forum. Please Do Not send private messages.
Posts: 3474
Joined: Fri Feb 03, 2012 2:17 pm
Location: Southampton, UK
by error404 » Tue May 08, 2012 10:22 pm
a) Have you set the hostname properly? (ie. does the command 'hostname' return the desired hostname)

b) You don't need winbind, it is for something else

c) On my system running 'unstable', the line in /etc/dhcp/dhclient.conf is 'send host-name gethostname();', but that is also the default setting. This fix seems to be in 'testing' as well. Which distribution are you using?
Posts: 351
Joined: Wed Dec 21, 2011 11:49 pm
by MrEngman » Tue May 08, 2012 11:17 pm
error404 said:


a) Have you set the hostname properly? (ie. does the command 'hostname' return the desired hostname)

b) You don't need winbind, it is for something else

c) On my system running 'unstable', the line in /etc/dhcp/dhclient.conf is 'send host-name gethostname();', but that is also the default setting. This fix seems to be in 'testing' as well. Which distribution are you using?


The command hostname returns "raspberrypi", the default hostname I think.

I have already tried with /etc/dhcp/dhclient.conf to send host-name "raspberrypi", and I have now tried your setting but no change.

I'm using "debian6-19-04-2012" from the download page.

Just to make my setup clear I have a small local network using a Windows 2003 server as primary domain controller and mail server. The 2003 server also provides the gateway to the internet. There are a variety of machines connected to the local network - windows XP/7 and macs - and all showing a hostname in the server DHCP and DNS servers.

It is only my new RPi that only shows up on the server as an IP address and no hostname - with the current debian distro. I have tried Arch and Fedora and at least one and I'm fairly certain both supplied a hostname to the 2003 server.

One final bit of info. From the RPi I can ping any other machine on the network using either their hostnames or IP address. Guess that says netbios is kind of OK.

Thank for taking an interest in this problem.
Simplicity is a prerequisite for reliability. Edsger W. Dijkstra

Please post ALL technical questions on the forum. Please Do Not send private messages.
Posts: 3474
Joined: Fri Feb 03, 2012 2:17 pm
Location: Southampton, UK
by error404 » Wed May 09, 2012 12:18 am
Can you post your full /etc/dhcp/dhclient.conf? Also debian6, 'stable' I think has both 'dhcp-client' and 'dhcp3-client'. I'm not sure which is installed in the image, but Debian usually leaves old config files laying around so you may have both /etc/dhcp and /etc/dhcp3.

I've no idea about Windows as I avoid it, especially for infrastructure tasks like serving DHCP, but not sending the hostname was the default in Debian 6, so I think it's expected behaviour.

Also hopefully not insulting, but did you restart networking after changing the configuration? You will need to drop and renew your lease to have the change take effect (/etc/init.d/networking restart).
Posts: 351
Joined: Wed Dec 21, 2011 11:49 pm
by MrEngman » Wed May 09, 2012 11:29 am
error404 said:


Also hopefully not insulting, but did you restart networking after changing the configuration? You will need to drop and renew your lease to have the change take effect (/etc/init.d/networking restart).


Not insulting at all. A useful suggestion for anyone else reading these posts. I generally reboot after making any changes but I've now tried /etc/init.d/networking restart and it proved very useful.

It showed up an error - a semicolon was missing in dhclient.conf - that I hadn't noticed before. Adding that and all is now OK. The server receives the hostname and I can now use the hostname to talk to RPI.

I also tried to use your suggestion 'send host-name gethostname();' but that gave errors again about semicolons.

Also tried Bredman's suggestion 'send hostname "`hostname`";' and ended up with a hostname on my server of `hostname` ;)

dhclient.conf is below, copied text as I don't know how to attach a file. Server gets hostname OK if I use 'send host-name "raspberrypi";'

But using 'send host-name gethostname();' as shown below generates errors about semicolons. I have pasted the errors output after the dhclient.conf file.

# Configuration file for /sbin/dhclient, which is included in Debian's
# dhcp3-client package.
#
# This is a sample configuration file for dhclient. See dhclient.conf's
# man page for more information about the syntax of this file
# and a more comprehensive list of the parameters understood by
# dhclient.
#
# Normally, if the DHCP server provides reasonable information and does
# not leave anything out (like the domain name, for example), then
# few changes must be made to this file, if any.
#

option rfc3442-classless-static-routes code 121 = array of unsigned integer 8;

send host-name gethostname();
#send host-name "andare.fugue.com";
#send dhcp-client-identifier 1:0:a0:24:ab:fb:9c;
#send dhcp-lease-time 3600;
#supersede domain-name "fugue.com home.vix.com";
#prepend domain-name-servers 127.0.0.1;
request subnet-mask, broadcast-address, time-offset, routers,
domain-name, domain-name-servers, domain-search, host-name,
netbios-name-servers, netbios-scope, interface-mtu,
rfc3442-classless-static-routes, ntp-servers;
#require subnet-mask, domain-name-servers;
#timeout 60;
#retry 60;
#reboot 10;
#select-timeout 5;
#initial-interval 2;
#script "/etc/dhcp3/dhclient-script";
#media "-link0 -link1 -link2", "link0 link1";
#reject 192.33.137.209;

#alias {
#  interface "eth0";
#  fixed-address 192.5.5.213;
#  option subnet-mask 255.255.255.255;
#}

#lease {
#  interface "eth0";
#  fixed-address 192.33.137.200;
#  medium "link0 link1";
#  option host-name "andare.swiftmedia.com";
#  option subnet-mask 255.255.255.0;
#  option broadcast-address 192.33.137.255;
#  option routers 192.33.137.250;
#  option domain-name-servers 127.0.0.1;
#  renew 2 2000/1/12 00:00:01;
#  rebind 2 2000/1/12 00:00:01;
#  expire 2 2000/1/12 00:00:01;
#}

Output from '/etc/init.d/networking restart' showing errors

Internet Systems Consortium DHCP Client 4.1.1-P1
Copyright 2004-2010 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/

/etc/dhcp/dhclient.conf line 16: semicolon expected.
send host-name gethostname(
^
/etc/dhcp/dhclient.conf line 16: expecting a statement.
send host-name gethostname();
^
/etc/dhcp/dhclient.conf line 25: semicolon expected.

^
Listening on LPF/wlan0/00:11:3b:19:1f:30
Sending on   LPF/wlan0/00:11:3b:19:1f:30
Sending on   Socket/fallback
DHCPRELEASE on wlan0 to 192.168.16.2 port 67
ioctl[SIOCSIWAP]: Operation not permitted
ioctl[SIOCSIWESSID]: Operation not permitted
Internet Systems Consortium DHCP Client 4.1.1-P1
Copyright 2004-2010 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/

/etc/dhcp/dhclient.conf line 16: semicolon expected.
send host-name gethostname(
^
/etc/dhcp/dhclient.conf line 16: expecting a statement.
send host-name gethostname();
^
/etc/dhcp/dhclient.conf line 25: semicolon expected.

^
Listening on LPF/wlan0/00:11:3b:19:1f:30
Sending on   LPF/wlan0/00:11:3b:19:1f:30
Sending on   Socket/fallback
DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 6
DHCPOFFER from 192.168.16.2
DHCPREQUEST on wlan0 to 255.255.255.255 port 67
DHCPACK from 192.168.16.2
bound to 192.168.16.15 -- renewal in 321232 seconds.

Thanks again for your help.
Simplicity is a prerequisite for reliability. Edsger W. Dijkstra

Please post ALL technical questions on the forum. Please Do Not send private messages.
Posts: 3474
Joined: Fri Feb 03, 2012 2:17 pm
Location: Southampton, UK
by bredman » Wed May 09, 2012 11:47 am
Try using

send host-name `hostname`;

to see if the dhcp script can manage an unquoted shell stdout.

The following error is caused by the fact that the dhcp script does not expect the '(' character. There must be some new functionality in Debian unstable which supports this.

/etc/dhcp/dhclient.conf line 16: expecting a statement
Posts: 1415
Joined: Tue Jan 17, 2012 2:38 pm
by MrEngman » Wed May 09, 2012 12:29 pm
bredman said:


Try using

send host-name `hostname`;





This generates errors

/etc/dhcp/dhclient.conf line 16: expecting string.
send host-name `
^
/etc/dhcp/dhclient.conf line 16: expecting a statement.
send host-name `hostname`;
^
/etc/dhcp/dhclient.conf line 25: semicolon expected.

^

Guess I'll have to stick with 'send host-name "raspberrypi";' for the moment but would be nice to get something more general working. In the mean time I'll just need to remember the places where hostname is defined in case I decide to change it.
Simplicity is a prerequisite for reliability. Edsger W. Dijkstra

Please post ALL technical questions on the forum. Please Do Not send private messages.
Posts: 3474
Joined: Fri Feb 03, 2012 2:17 pm
Location: Southampton, UK
by error404 » Wed May 09, 2012 4:47 pm
Yeah, the patch that supports that must have appeared sometime after the current stable. It's a much more elegant solution. Has anyone built a testing or unstable image? These are probably more appropriate for the Pi anyway, stable is showing its age and Debian stable has never been great for desktop tasks. I'd recommend dist-upgrading to testing, but that is a long and somewhat involved process, so let's KISS for now.

You should be able to install the testing version of isc-dhcp-client without fiddling around too much, as it has few dependencies. Download these onto your Pi:

http://http.us.debian.org/debi....._armel.deb

http://http.us.debian.org/debi....._armel.deb

Install them with 'dpkg -i <filename>' (do the common files first). You may need to first remove dhcp/dhcp3 packages.
Posts: 351
Joined: Wed Dec 21, 2011 11:49 pm
by MrEngman » Wed May 09, 2012 8:47 pm
Hi Error0404

I've installed the two packages without any issues. No need to uninstall the old packages but I was asked whether I wanted to overwrite the /etc/dhclient.conf with the new one so I said yes and then restarted the network.

All is OK. I can still contact the RPi using the hostname OK and amazingly the new dhclient.conf file contains the line "send host-name = gethostname();". Note the addition of the = sign.

Thanks very much for that.

I have now found some stuff about updating the current debian image with new firmware for the Pi at http://www.ctrl-alt-del.cc/201.....s-ada.html so I'm going to look at that now.

Anyway once again thanks very much for your help - really very much appreciated.
Simplicity is a prerequisite for reliability. Edsger W. Dijkstra

Please post ALL technical questions on the forum. Please Do Not send private messages.
Posts: 3474
Joined: Fri Feb 03, 2012 2:17 pm
Location: Southampton, UK
by Darkness » Fri May 25, 2012 11:00 pm
I had been looking for quite a while to get hostnames working to be able to ping by hostname, both linux to windows and windows to linux.
There is a lot of shitty info out there talking about adding the names to /etc/hosts (won't work with DHCP) or installing a DNS server (seriously?) and some other stuff that are most of the time a flawed solution.

In the end, this is how I got it to work in a DHCP network in a simple way:
Code: Select all
sudo apt-get install samba
sudo apt-get install winbind

in /etc/samba/smb.conf, edit the workgroup variable to match your home network workgroup (as defined in windows):
Code: Select all
workgroup = HOMENETWORK


in /etc/nsswitch.conf, change the following line:
Code: Select all
hosts:         files dns
to
Code: Select all
hosts:         files dns wins
(some people say the order of files,dns and wins is important, didn't test it)

installing samba makes it work windows to Linux, installing winbind and changing the config files makes it work linux to windows.
Posts: 20
Joined: Wed May 23, 2012 12:13 am
by error404 » Sun May 27, 2012 4:46 am
Of course 'seriously'. That's exactly what DNS is for. You've just taken the standard, widely used name resolution protocol and replaced it with the weird Windows one that even Microsoft doesn't use anymore. But you're right, it can be non-trivial to set up, however if you use dnsmasq to both serve DHCP and DNS it's trivial.
Posts: 351
Joined: Wed Dec 21, 2011 11:49 pm
by m0rjc » Mon May 28, 2012 9:26 pm
There are two naming systems commonly in use in a Windows home network:

DNS - The 'proper' one, used to resolve things like this web site.
Windows Naming - The old Microsoft specific one for Windows Workgroups

How things work for you depends on the machine (or all-in-one ADSL router wifi box thing) you have running your network.

I remember in the past some accepted a DHCP request from a host, then used Windows Name Lookup to ask the host what it's name was. This may then have been placed in the DNS table (if your home internet router wasn't too old) to refer to the host.

Some do accept the host name as part of the DHCP request, which is what that send host-name instruction in /etc/dhcp/dhclient.conf is for.

Even if your home router does not do DNS or pay attention to the name in the DHCP request, any Windows machines on the network may choose to use the old Windows Naming system to find a host. That way, installing Samba allows your machine to be found.

Windows Naming works by network broadcasts. Machines routinely shout out "Hello, Raspberry here!". Windows networks are very chatty! It is very limited. It only works over one subnet (the shouts don't pass through routers unless they're doing something special), and needs the broadcast to have been received before the information can be used. It really is designed for small networks - homes, small offices. On the other hand DNS is good for big networks.

I received my Raspberry Pi today and have plugged it in. Sadly I didn't have the right HDMI cable, so I just put the Debian distribution on an SD card and plugged it into the network hoping to be able to log in remotely. Unfortunately my network is managed by a BT Home Hub 2 - which seems to be a bit intermittent with Linux machines. For example it will happily hand out an IP address, serve the host name through DNS, and most of the time not forget about them. For some reason the machines don't show up in its management interface. I'll have to find more time to experiment more - see if I can either find the right HDMI cable or use a packet sniffer to watch for DHCP requests. The lights on the PI did flash in a very promising way though.
Posts: 1
Joined: Mon May 28, 2012 9:13 pm
by sanketss84 » Sat Sep 08, 2012 9:18 am
Darkness wrote:In the end, this is how I got it to work in a DHCP network in a simple way:
Code: Select all
sudo apt-get install samba
sudo apt-get install winbind

in /etc/samba/smb.conf, edit the workgroup variable to match your home network workgroup (as defined in windows):
Code: Select all
workgroup = HOMENETWORK


in /etc/nsswitch.conf, change the following line:
Code: Select all
hosts:         files dns
to
Code: Select all
hosts:         files dns wins
(some people say the order of files,dns and wins is important, didn't test it)

installing samba makes it work windows to Linux, installing winbind and changing the config files makes it work linux to windows.


These steps worked perfectly for me.
Thanks a World

no need to edit the dhclient.conf and add
Code: Select all
 send host-name "mypiname";


Just follow these steps and you are done :)
Posts: 1
Joined: Tue Aug 14, 2012 8:03 am
Location: Mumbai,IN