# No Internet with latest dhcp, dhcpcd, dhcdbd & openrc

## Fitzcarraldo

I had the packages dhcp, dhcpcd, dhcdbd and openrc installed, and networking and Internet access were all working. I noticed that newer versions of these four packages are available so I merged the latest versions, and now I cannot access the Internet anymore unless I manually enter the command dhclient as root user.

Here are the details of what I have installed:

```
# eix -I dhcp

[I] net-misc/dhcp            

     Available versions:  3.1.1 3.1.1-r1 (~)3.1.2 3.1.2_p1 [M](~)4.0.1 [M](~)4.1.0 {doc ipv6 kernel_linux minimal selinux static vim-syntax}

     Installed versions:  3.1.2_p1(17:35:56 16/09/09)(kernel_linux -doc -minimal -selinux -static)                                          

     Homepage:            http://www.isc.org/products/DHCP                                                                                  

     Description:         ISC Dynamic Host Configuration Protocol

[I] net-misc/dhcpcd

     Available versions:  4.0.7 4.0.13 (~)5.0.4 (~)5.0.5 (~)5.0.6 (~)5.1.0 {compat zeroconf}

     Installed versions:  5.1.0(17:35:21 16/09/09)(zeroconf)

     Homepage:            http://roy.marples.name/projects/dhcpcd/

     Description:         A fully featured, yet light weight RFC2131 compliant DHCP client

Found 2 matches.

acertm8215 bill # eix -I dhcd

[I] net-misc/dhcdbd

     Available versions:  2.8-r1 3.0 {debug}

     Installed versions:  3.0(17:37:07 16/09/09)(-debug)

     Homepage:            http://dcantrel.fedorapeople.org/dhcdbd

     Description:         DHCP D-BUS daemon (dhcdbd) controls dhclient sessions with D-BUS, stores and presents DHCP options.

acertm8215 bill # eix -I openrc

[I] sys-apps/openrc

     Available versions:  (~)0.4.1-r1 (~)0.4.2 (~)0.4.3-r1 (~)0.4.3-r2 (~)0.4.3-r3 (~)0.4.3-r5[1] **9999 {debug elibc_glibc kernel_FreeBSD kernel_linux ncurses pam unicode}

     Installed versions:  0.4.3-r5[1](17:36:41 16/09/09)(elibc_glibc kernel_linux ncurses pam unicode -debug -kernel_FreeBSD)

     Homepage:            http://roy.marples.name/openrc

     Description:         OpenRC manages the services, startup and shutdown of a host

[1] "sabayon" /usr/local/portage/layman/sabayon

#
```

Here's what I get when I enter the command dhclient:

```
# dhclient  

Internet Systems Consortium DHCP Client V3.1.2p1-Gentoo

Copyright 2004-2009 Internet Systems Consortium.       

All rights reserved.                                   

For info, please visit http://www.isc.org/sw/dhcp/     

Listening on LPF/wlan0/00:18:de:4a:8e:a8

Sending on   LPF/wlan0/00:18:de:4a:8e:a8

Listening on LPF/eth0/00:16:36:85:6d:77 

Sending on   LPF/eth0/00:16:36:85:6d:77 

Sending on   Socket/fallback            

DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 4

DHCPREQUEST on eth0 to 255.255.255.255 port 67             

DHCPACK from 192.168.1.254                                 

bound to 192.168.1.77 -- renewal in 33748 seconds.         

#
```

The dhcp-3.1.2_p1 ebuild displayed the following message on the console when I merged it:

```
WARNING: The dhcp init script has been renamed to dhcpd

 * /etc/init.d/dhcp and /etc/conf.d/dhcp need to be removed and

 * and dhcp should be removed from the default runlevel        

 *                                                             

 * You can edit /etc/conf.d/dhcpd to customize dhcp settings.  

 *                                                             

 * If you would like to run dhcpd in a chroot, simply configure the

 * DHCPD_CHROOT directory in /etc/conf.d/dhcpd and then run:       

 *   emerge --config =dhcp-3.1.2_p1
```

I did what it instructed me to do: I deleted /etc/conf.d/dhcp and /etc/init.d/dhcp (first making backup copy in another directory) but I did not need to remove dhcp from the default runlevel because it had already been removed (by the ebuild?):

```
# rc-update -v | grep dhc

             dhcrelay |

                dhcpd |

               dhcdbd | default

               dhcpcd |

#
```

Could anyone advise me what I need to do to fix this? Please let me know if I should post the contents of any other files or console output. Thanks in advance for your help.

----------

## Mike Hunt

So why don't you start dhcpd as the WARNING states?

```
rc-update add dhcpd default

rc
```

----------

## Fitzcarraldo

But the WARNING does not state that; it just states "and dhcp should be removed from the default runlevel". It might be obvious to an expert, but to make it foolproof the ebuild should state "dhcp should be removed from the default runlevel and dhcpd should be added to the default runlevel".

Anyway, I did as you suggested and I still cannot access the Internet until I enter the command dhclient as root. However now on TTY1 the following message is displayed while booting:

```
* //etc/dhcp/dhcpd.conf does not exist

* ERROR: dhcpd failed to start
```

Why "//etc" rather than "/etc"?  The file /etc/dhcp/dhcpd.conf does indeed not exist. However there is a file /etc/dhcp/dhcpd.conf.sample containing the following:

```
# dhcpd.conf                                                                  

#                                                                             

# Sample configuration file for ISC dhcpd                                     

#                                                                             

# option definitions common to all supported networks...

option domain-name "example.org";                       

option domain-name-servers ns1.example.org, ns2.example.org;

default-lease-time 600;

max-lease-time 7200;   

# Use this to enble / disable dynamic dns updates globally.

#ddns-update-style none;                                   

# If this DHCP server is the official DHCP server for the local

# network, the authoritative directive should be uncommented.  

#authoritative;                                                

# Use this to send dhcp log messages to a different log file (you also

# have to hack syslog.conf to complete the redirection).              

log-facility local7;                                                  

# No service will be given on this subnet, but declaring it helps the 

# DHCP server to understand the network topology.                     

subnet 10.152.187.0 netmask 255.255.255.0 {

}                                          

# This is a very basic subnet declaration.

subnet 10.254.239.0 netmask 255.255.255.224 {

  range 10.254.239.10 10.254.239.20;         

  option routers rtr-239-0-1.example.org, rtr-239-0-2.example.org;

}                                                                 

# This declaration allows BOOTP clients to get dynamic addresses,

# which we don't really recommend.                               

subnet 10.254.239.32 netmask 255.255.255.224 {

  range dynamic-bootp 10.254.239.40 10.254.239.60;

  option broadcast-address 10.254.239.31;         

  option routers rtr-239-32-1.example.org;        

}                                                 

# A slightly different configuration for an internal subnet.

subnet 10.5.5.0 netmask 255.255.255.224 {                   

  range 10.5.5.26 10.5.5.30;                                

  option domain-name-servers ns1.internal.example.org;      

  option domain-name "internal.example.org";                

  option routers 10.5.5.1;                                  

  option broadcast-address 10.5.5.31;                       

  default-lease-time 600;                                   

  max-lease-time 7200;                                      

}                                                           

# Hosts which require special configuration options can be listed in

# host statements.   If no address is specified, the address will be

# allocated dynamically (if possible), but the host-specific information

# will still come from the host declaration.                            

host passacaglia {

  hardware ethernet 0:0:c0:5d:bd:95;

  filename "vmunix.passacaglia";    

  server-name "toccata.fugue.com";  

}                                   

# Fixed IP addresses can also be specified for hosts.   These addresses

# should not also be listed as being available for dynamic assignment. 

# Hosts for which fixed IP addresses have been specified can boot using

# BOOTP or DHCP.   Hosts for which no fixed address is specified can only

# be booted with DHCP, unless there is an address range on the subnet    

# to which a BOOTP client is connected which has the dynamic-bootp flag  

# set.                                                                   

host fantasia {                                                          

  hardware ethernet 08:00:07:26:c0:a5;                                   

  fixed-address fantasia.fugue.com;                                      

}                                                                        

# You can declare a class of clients and then do address allocation

# based on that.   The example below shows a case where all clients

# in a certain class get addresses on the 10.17.224/24 subnet, and all

# other clients get addresses on the 10.0.29/24 subnet.

class "foo" {

  match if substring (option vendor-class-identifier, 0, 4) = "SUNW";

}

shared-network 224-29 {

  subnet 10.17.224.0 netmask 255.255.255.0 {

    option routers rtr-224.example.org;

  }

  subnet 10.0.29.0 netmask 255.255.255.0 {

    option routers rtr-29.example.org;

  }

  pool {

    allow members of "foo";

    range 10.17.224.10 10.17.224.250;

  }

  pool {

    deny members of "foo";

    range 10.0.29.10 10.0.29.230;

  }

}
```

How on Earth do I create /etc/dhcp/dhcpd.conf? I have no idea. I'm using dynamic IP addressing, not static. The file /etc/dhcp/dhclient.conf looks like this on my laptop:

```
send host-name "acertm8215";

supersede host-name "acertm8215";
```

dhclient seems much easier to use than dhcpd.

I also removed dhcdbd from the default runlevel to see what would happen, but that made no apparent difference. I can still connect to the Internet if I manually run dhclient.

Do you use dynamic IP addressing? If so, what does your /etc/dhcp/dhcpd.conf contain?

Could it be that, before I merged the latest versions of dhcp, dhcpcd, dhcdbd and openrc a couple of days ago, dhcp, dhcpcd and dhcdbd were actually doing nothing and it was dhclient that was actually running? Perhaps merging the latest version of these four packages disabled dhclient? How would dhclient normally be made to run automatically at boot?

(According to the Gentoo Handbook here, the package that installs dhclient is dhcp.)

----------

## cwr

Well. dhclient and dhcpd are two different things; one is a client, the other is

a server.  I don't think you want the server, and the only thing I have in

/etc/dhcp/dhclient.conf is "timeout 10;" (w/o the '"', of course).

If you are running a dhcp server, for some reason, then it will need to go

in the default runlevel - at least that's where I put it; there are various

race conditions, ISTR, if it goes in the boot runlevel.  Configuring a DHCP

server is left as an exercise for the student ...

dhclient (or indeed any client) is run from net.ethx when the interface comes

up; check /etc/conf.d/net for the details, it's pretty complete.  I just have a

config_eth0 ("dhclient") and a fallback_eth0=( "xxx.xxx.xxx.xxx netmask

255.255.255.0 broadcast xxx.xxx.xxx.xxx" ) for when there's no dhcp

server around.  You may not even need the config_eth0 ("dhclient") if

you set modules("dhclient") as the default.

Good luck - Will

----------

## Fitzcarraldo

Thanks, Will, for your useful post.

I have solved the problem. As you wrote, dhcpd is not a DHCP client, it is a DHCP server. The file /etc/dhcp/dhcp.conf is a configuration file for a DHCP server, not a DHCP client. What I find confusing is that, according to the Gentoo Handbook (see link I posted earlier), the package dhcp also installs dhclient.

The problem was solved by adding a DHCP client to the default runlevel. As I could not see how to add dhclient to the default runlevel, I chose to add dhcpcd instead, as that is also a DHCP client. Even before I did this, eth0 was allocated an IP address by my home DHCP server (my router) -- is this being done by NetworkManager?   :Confused:   -- but not DNS information from my home network router. This I discovered by entering the ifconfig command, which showed that eth0 on my laptop was allocated an IP address by my home network's DHCP server (my router). I also could ping an external IP address but not any domain names. Thus the problem was a DNS resolution problem.

This is precisely what I did:

1. I removed dhcdbd from the default runlevel, because it seemed to me to relate to DHCP server configuration. I also removed dhcpd from the default runlevel because dhcpd is not a DHCP client, it's a DHCP server. So the situation looked like this:

```
# rc-update -v | grep dhc

             dhcrelay |

                dhcpd |

               dhcdbd |

               dhcpcd |

#
```

2. I edited /etc/conf.d/net to look like this:

```
#Following line added 18.09.09 by Fitzcarraldo

modules="dhcpcd"

config_eth0="dhcp"

#Following line commented out 18.09.09 by Fitzcarraldo

#dhcp_eth0="nosendhost"
```

3. I added dhcpcd to default runlevel. So the situation now looked like this:

```
# rc-update show -v | grep dhc

             dhcrelay |

                dhcpd |

               dhcdbd |

               dhcpcd | default

#
```

4. I started the dhcpcd DHCP client:

```
/etc/init.d/dhcpcd restart
```

and now I can access the Internet using domain names as well as IP addresses, so Firefox is working again. My only question now is: What was the DHCP client before I upgraded the packages dhcp, dhcpcd, dhcdbd and openrc a couple of days ago? If it was dhclient (which I think it was as the files /var/lib/dhclient/dhclient-eth0.leases, /var/lib/dhclient/dhclient-wlan0.leases and /var/lib/dhcp/dhclient.leases existed and were used), what was launching it, and how?   :Confused: 

----------

## cwr

It was almost certainly being launched as the default from /etc/conf.d/net, via

/etc/runlevels/default/net.eth0, a link to /etc/init.d/net.eth0, in turn linked to

/etc/init.d/net.lo.

Check /etc/resolv.conf - it may well say, as mine does:

 # Generated by dhclient for interface eth0

 192.168.0.1

which by a curious coincidence is the address of my local router ...

Will

----------

## Fitzcarraldo

This is what /etc/resolv.conf contains now:

```
# Generated by resolvconf

search home

nameserver 192.168.1.254
```

and 192.168.1.254 is indeed the IP address of my home router.Last edited by Fitzcarraldo on Fri Sep 18, 2009 8:54 pm; edited 1 time in total

----------

## Fitzcarraldo

Now that I have the DHCP client dhcpcd running instead of dhclient, the leases files are /var/lib/dhcpcd/dhcpcd-eth0.lease and /var/lib/dhcpcd/dhcpcd-wlan0.lease, and the dhclient leases files no longer exist on my HDD.

----------

