# Bug? dnsmasq starts dhcpcd even if configured for DNS only

## saturnalia0

dnsmasq can provide both DNS and DHCP servers. I have configured it such that it only provides the former, but starting dnsmasq via rc-service causes dhcpcd to be started also. 

```

$ equery u dnsmasq

...

 - - dhcp          : Enable support for acting as a DHCP server.

 - - dhcp-tools    : Install extra command line tools for manually managing DHCP leases.

...

```

```

$ grep /etc/dnsmasq.conf -Pe '^\w'

domain-needed

bogus-priv

strict-order

listen-address=127.0.0.1

bind-interfaces

```

If I uninstall dhcpcd then dnsmasq starts successfully, obviously without bringing up dhcpcd with it. Should I fill a bug report? 

There's the following line on the "depends" block of /etc/init.d/dhcpcd:

```

before dns

```

I tried commenting it out then `rc-service dhcpcd stop ; rc-service dnsmasq restart`, but dhcpcd is still brought up...

----------

## Logicien

For sure, if you unmerge dhcpcd, it will not be started. The Dnsmasq dhcp USE flag refer to a dhcp server feature when Dhcpcd is a dhcp client. I do not think that emerge Dnsmasq can emerge Dhcpcd as a dependancy even not any external dhcp server because, Dnsmasq IS a dhcp server.

If Dhcpcd is started as a boot script and/or some network interfaces are configure via dhcp, Dhcpcd will bring up. Be sure with rc-update and in /etc/conf.d/net that nothing need to start a dhcp client.

----------

## UberLord

dhcpcd provides the net dependency.

dnsmasq requires the net dependency to be up.

dnsmasq handling DHCP has nothing to do with your problem, it's simple services.

SOMETHING has to provide net.

dhcpcd can, /etc/init.d/network and /etc/init.d/net.* do as well.

----------

## saturnalia0

 *UberLord wrote:*   

> dhcpcd provides the net dependency.
> 
> dnsmasq requires the net dependency to be up.
> 
> dnsmasq handling DHCP has nothing to do with your problem, it's simple services.
> ...

 

I see. I'm a noob when it comes to init services. Is there any way I can prevent dhcpcd from providing net as to avoid it being started with dnsmasq? I only use dhcpcd at work, at home I have a static ip setup and do not wish it to start (I use dnsmasq both at home and at work). Furthermore I'm not using /etc/init.d/net.* to connect, I'm using a script that calls wpa_supplicant + ip/dhcpcd (not ideal, but again I'm a noob and could not configure /etc/conf.d/net to do what I need) so I'm not sure what could provide net.

----------

## Logicien

There are several ways to resolv your problem with Openrc net service. You can let Openrc start the Dhcpcd service when it start the Dnsmasq service and configure Dhcpcd to configure dynamically your network interface at work and statically at home. Dhcpcd can start by itself Wpa_supplicant for a wireless interface. Dhcpcd can ask for IP and/or DNS configuration. You need to learn how to write /etc/dhcpcd.conf.

An other way is to learn how to configure Openrc net service with /etc/conf.d/net. You can use

```
bzless /usr/share/doc/netifrc-0.2.2/net.example.bz2
```

to have examples on how to do it.

In both cases, you should stop to use a personnal script if you want to learn how to configure your network using the Dhcpcd and the Gentoo ways.

If you absolutely want use configure your network manually with Openrc not starting Dhcpcd when it bring up Dnsmasq, you have to edit /etc/rc.conf to specify what is providing and what is not providing the net service.

----------

## UberLord

 *saturnalia0 wrote:*   

> 
> 
> I see. I'm a noob when it comes to init services. Is there any way I can prevent dhcpcd from providing net as to avoid it being started with dnsmasq? I only use dhcpcd at work, at home I have a static ip setup and do not wish it to start (I use dnsmasq both at home and at work). Furthermore I'm not using /etc/init.d/net.* to connect, I'm using a script that calls wpa_supplicant + ip/dhcpcd (not ideal, but again I'm a noob and could not configure /etc/conf.d/net to do what I need) so I'm not sure what could provide net.

 

Why not use add dhcpcd and wpa_supplicant to the default runlevel and configure dhcpcd to assign your static IP for your home network?

It can work it out via SSID or ARPing by itself so no need to run a manual script when changing locations.

See dhcpcd.conf(5) for details on profiles and arping support.

----------

