Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
dhcpd.conf hostnames instead of ip addresses stopped working
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
AchilleTalon
Guru
Guru


Joined: 11 Apr 2004
Posts: 368
Location: Montreal, Quebec, Canada

PostPosted: Tue Oct 07, 2014 4:22 pm    Post subject: dhcpd.conf hostnames instead of ip addresses stopped working Reply with quote

I have my dhcp server on the same box as the nameserver. I am using systemd as well on this box. Both dhcp server and nameserver are chrooted, they were both working fine. They nameserver is still working fine, however for an unknown reason since I didn't catch the problem when it occurs, the dhcpd.conf file no longer accepts a hostname in the fixed-address definition, it requires an ip address to work properly.

The man page for dhcpd.conf clearly state the hostname is an admissible entry instead of the ip address. It should work everywhere an ip address is required like option routers, option domain-name-servers, etc.

Anyone has an idea why this stopped working?

# emerge --info net-misc/dhcp
Code:

Portage 2.2.8-r1 (default/linux/arm/13.0/armv6j, gcc-4.7.3, glibc-2.19-r1, 3.12.26 armv6l)
=================================================================
                        System Settings
=================================================================
System uname: Linux-3.12.26-armv6l-with-gentoo-2.2
KiB Mem:      123096 total,     14276 free
KiB Swap:     262140 total,    260328 free
Timestamp of tree: Thu, 25 Sep 2014 15:30:01 +0000
ld GNU ld (Gentoo 2.23.2 p1.0) 2.23.2
distcc 3.1 armv6j-hardfloat-linux-gnueabi [enabled]
app-shells/bash:          4.2_p48-r1
dev-lang/python:          2.7.7, 3.3.5-r1
dev-util/cmake:           2.8.12.2-r1
dev-util/pkgconfig:       0.28-r1
sys-apps/baselayout:      2.2
sys-apps/openrc:          0.12.4
sys-apps/sandbox:         2.6-r1
sys-devel/autoconf:       2.69
sys-devel/automake:       1.11.6, 1.12.6, 1.13.4
sys-devel/binutils:       2.23.2
sys-devel/gcc:            4.7.3-r1
sys-devel/gcc-config:     1.7.3
sys-devel/libtool:        2.4.2-r1
sys-devel/make:           3.82-r4
sys-kernel/linux-headers: 3.13 (virtual/os-headers)
sys-libs/glibc:           2.19-r1
Repositories: gentoo My-Raspberry-Pi-portage-overlay
ACCEPT_KEYWORDS="arm"
ACCEPT_LICENSE="* -@EULA dlj-1.1 PUEL AdobeFlash-10.3"
CBUILD="armv6j-hardfloat-linux-gnueabi"
CFLAGS="-O2 -pipe -march=armv6j -mfpu=vfp -mfloat-abi=hard"
CHOST="armv6j-hardfloat-linux-gnueabi"
CONFIG_PROTECT="/etc /usr/share/gnupg/qualified.txt /var/bind"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo"
CXXFLAGS="-O2 -pipe -march=armv6j -mfpu=vfp -mfloat-abi=hard"
DISTDIR="/var/tmp/distfiles"
FCFLAGS="-O2 -pipe -march=armv6j"
FEATURES="assume-digests binpkg-logs buildpkg config-protect-if-modified distcc distcc-pump distlocks ebuild-locks fixlafiles merge-sync news parallel-fetch preserve-libs protect-owned sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync"
FFLAGS="-O2 -pipe -march=armv6j"
GENTOO_MIRRORS="http://gentoo.gossamerhost.com http://gentoo.mirrors.tera-byte.com/ http://mirror.csclub.uwaterloo.ca/gentoo-distfiles/ http://gentoo.arcticnetwork.ca/ http://mirror.the-best-hosting.net http://gentoo.cites.uiuc.edu/pub/gentoo/ http://gentoo.llarian.net/ http://mirror.iawnet.sandia.gov/gentoo/ http://mirror.lug.udel.edu/pub/gentoo/ ftp://mirrors.tera-byte.com/pub/gentoo ftp://gentoo.arcticnetwork.ca/pub/gentoo/ ftp://mirror.csclub.uwaterloo.ca/gentoo-distfiles/ ftp://ftp.lug.udel.edu/pub/gentoo/ ftp://mirror.iawnet.sandia.gov/pub/gentoo/ ftp://mirror.mcs.anl.gov/pub/gentoo/ "
LANG="fr_CA.UTF-8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
MAKEOPTS="-j19 -l1"
PKGDIR="/var/tmp/packages"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/usr/local/portage/my"
SYNC="rsync://chadwick.cids.ca/gentoo-portage"
USE="a52 acl acpi aim alsa arm avahi berkdb bind bluetooth bzip2 calendar caps cli cracklib crypt cups curl cxx dbus dirac dlz dns dri encode fbcon ffmpeg flac foomaticdb fortran gcrypt gdbm gssapi gtalk gzip httpd iconv imap ipv6 jabber jfs jpeg kerberos ldap ldap-sasl lua maildir mailwrapper mbox mcal mikmod modules mp3 mpeg named ncurses nls nntp nptl odbc ogg opencv opengl openldap openmp pam pam_krb5 pam_ssh pcre pdf png policykit postgres ppds prefork pthreads pulseaudio python radius readline rtsp sane sasl sendmail session sha512 sharedmem slp smartcard snmp soap speex ssl svg swscale syslog systemd tcpd theora threads tiff truetype udev unicode usb v4l vlm vnc vorbis xinetd xml zlib" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="kexi words flow plan sheets stage tables krita karbon braindump author" CAMERAS="ptp2" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf superstar2 timing tsip tripmate tnt ublox ubx" INPUT_DEVICES="evdev" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" LINGUAS="en fr" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php5-5" PYTHON_SINGLE_TARGET="python2_7" PYTHON_TARGETS="python2_7 python3_3" RUBY_TARGETS="ruby19 ruby20" SANE_BACKENDS="net epson epson2" USERLAND="GNU" VIDEO_CARDS="v4l" VOICEMAIL_STORAGE="file" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account"
Unset:  CPPFLAGS, CTARGET, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LC_ALL, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, USE_PYTHON

=================================================================
                        Package Settings
=================================================================

net-misc/dhcp-4.2.5_p1-r2 was built with the following:
USE="client ipv6 ldap server ssl (-selinux) -vim-syntax"

_________________
Achille Talon Hop!
Back to top
View user's profile Send private message
AchilleTalon
Guru
Guru


Joined: 11 Apr 2004
Posts: 368
Location: Montreal, Quebec, Canada

PostPosted: Tue Oct 07, 2014 5:01 pm    Post subject: Reply with quote

For the records, my chroot directory is /chroot/dhcp and the content of /chroot/dhcp/etc/resolv.conf is:

Code:
domain my.domain.com
nameserver 127.0.0.1

_________________
Achille Talon Hop!
Back to top
View user's profile Send private message
UberLord
Retired Dev
Retired Dev


Joined: 18 Sep 2003
Posts: 6737
Location: Blighty

PostPosted: Tue Oct 07, 2014 8:21 pm    Post subject: Reply with quote

The DHCP server cannot resolve the hosname to an IP adress.
This could be a variety of reasons, one being that DHCP server was started *before* DNS is actually available.
_________________
Use dhcpcd for all your automated network configuration needs
Use dhcpcd-ui (GTK+/Qt) as your System Tray Network tool
Back to top
View user's profile Send private message
AchilleTalon
Guru
Guru


Joined: 11 Apr 2004
Posts: 368
Location: Montreal, Quebec, Canada

PostPosted: Tue Oct 07, 2014 8:51 pm    Post subject: Reply with quote

Nope, the DNS is up and running. I did the test after everything is up and running and restarting the dhcp server, wiping out the leases. There is something else, however the output doesn't provide with much information to discover what is going on.

I can see the DHCPDISCOVER with the hardware ethernet address given to the server which replies with a DHCPOFFER skipping the fixed-address stanza to pick an address in the dynamic address pool instead, then the offer is accepted and acknowledged.

I am trying to recompile this thing to provide more debugging information about the lease finding step which seems where the problem occurs.
_________________
Achille Talon Hop!
Back to top
View user's profile Send private message
AchilleTalon
Guru
Guru


Joined: 11 Apr 2004
Posts: 368
Location: Montreal, Quebec, Canada

PostPosted: Wed Oct 08, 2014 2:39 am    Post subject: Reply with quote

After patching the code to make the debugging messages working properly here is the kind of messages I get:

Code:

(...)
Looking up curie.cids.ca
common/tree.c: gethostbyname(): Resolver Error 0 (no error)
default h_errno condition: Resolver Error 0 (no error)
data: DNS lookup (curie.cids.ca) = NULL
Not returning a lease.
(...)


So, gethostbyname() doesn't return an host entry for the looked up name, however there is no error neither.

Any hints?
_________________
Achille Talon Hop!
Back to top
View user's profile Send private message
UberLord
Retired Dev
Retired Dev


Joined: 18 Sep 2003
Posts: 6737
Location: Blighty

PostPosted: Wed Oct 08, 2014 8:58 am    Post subject: Reply with quote

Can you lookup the hostname from within the DHCP chroot?
ie

Code:
host curie.cids.ca

_________________
Use dhcpcd for all your automated network configuration needs
Use dhcpcd-ui (GTK+/Qt) as your System Tray Network tool
Back to top
View user's profile Send private message
AchilleTalon
Guru
Guru


Joined: 11 Apr 2004
Posts: 368
Location: Montreal, Quebec, Canada

PostPosted: Wed Oct 08, 2014 3:09 pm    Post subject: Reply with quote

Since I don't have access to the bind tools from within the chroot environment I cannot perform this test right now. The dhcpd implementation is compiling its own set of bind related libraries and functions. The best thing would be to compile a utility command to perform the binding using these libraries or to extend some piece of code called at initialization to perform a dummy test.

I am looking at it.

Addendum:
From the netdb.h file the set of errors for gethostbyname() and their meaning is as follow:

Code:
/* Possible values left in `h_errno'.  */
# define HOST_NOT_FOUND 1       /* Authoritative Answer Host not found.  */
# define TRY_AGAIN      2       /* Non-Authoritative Host not found,
                                   or SERVERFAIL.  */
# define NO_RECOVERY    3       /* Non recoverable errors, FORMERR, REFUSED,
                                   NOTIMP.  */
# define NO_DATA        4       /* Valid name, no data record of requested
                                   type.  */
#endif
#if defined __USE_MISC || defined __USE_GNU
# define NETDB_INTERNAL -1      /* See errno.  */
# define NETDB_SUCCESS  0       /* No problem.  */
# define NO_ADDRESS     NO_DATA /* No address, look for MX record.  */
#endif


I should get an h_errno == 2 from the gethostbyname() function if the name server cannot be found.
_________________
Achille Talon Hop!
Back to top
View user's profile Send private message
AchilleTalon
Guru
Guru


Joined: 11 Apr 2004
Posts: 368
Location: Montreal, Quebec, Canada

PostPosted: Wed Oct 08, 2014 6:07 pm    Post subject: Reply with quote

I did write a test function which loops around a list of hostnames to query resolution from the initialization code of dhcpd. No matter what the hostname is, even for those which do not exist at all, the gethostbyname() function always returns h_errno == 0; as if there was no error while the returned pointer is NULL.

The real gethostbyname() function seems wrapped by some code in the bind version bundled with dhcpd.

It did work before, same version of dhcp. The only things I can think it depends on is /chroot/dhcp/etc/resolv.conf, /dev, /proc and /sys even if /dev and /sys were not mounted in the chrooted environment before it doesn't change anything if I mount them or not.

I tested dhcpd outside a chrooted environment and it is working fine. It is then something with the chroot environment.
_________________
Achille Talon Hop!
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum