# dnsmasq doesn't learn hostnames

## Cr0t

The router is running DNSMAQ, but for some reasons I feel like DNSMASQ is not learning the machine names in the network. Does anyone know how to force DNSMASQ to learn HOSTNAMES inside the network.

Why does not DNSMASQ learn the hostnames inside the network?

Any clues?

mod edit: Converted topic to lowercase

amne

----------

## Cr0t

 *Cr0t wrote:*   

> The router is running DNSMAQ, but for some reasons I feel like DNSMASQ is not learning the machine names in the network. Does anyone know how to force DNSMASQ to learn HOSTNAMES inside the network.
> 
> Why does not DNSMASQ learn the hostnames inside the network?
> 
> Any clues?

 

*UpDate*: Isn't it possible to connect DNSMASQ with the DHCPs lease file?

----------

## Chris W

If you are using dnsmasq for both the DNS and DHCP services then it will automatically insert hostnames into the DNS for leases issued.  In order for this to work with Gentoo boxes as the DHCP client, you must ensure that a host name is sent with the DHCP request.  Dhcpcd does not do this by default.  You can arrange it by adding the "-h" option in /etc/conf.d/net, e.g.

```
dhcpcd_eth0="-h myhostname"
```

.  If you then refresh your lease with 

```
# dhcpcd -n eth0
```

 the machine should become available as "myhostname" in the DNS.

----------

## Cr0t

 *Chris W wrote:*   

> If you are using dnsmasq for both the DNS and DHCP services then it will automatically insert hostnames into the DNS for leases issued.  In order for this to work with Gentoo boxes as the DHCP client, you must ensure that a host name is sent with the DHCP request.  Dhcpcd does not do this by default.  You can arrange it by adding the "-h" option in /etc/conf.d/net, e.g.
> 
> ```
> dhcpcd_eth0="-h myhostname"
> ```
> ...

 What about Windows machines?

----------

## Chris W

On my LAN Windows machines send the hostname they are configured with and show up in DNSmasq's DNS automatically.  If you have more than one machine with the same name then you might have problems.

----------

## oktexan

Thank you!  I've been fighting this same issue for a day.  All my windows box names show up in the leases files, but the gentoo boxes didn't.

Thanks alot

----------

## John R. Graham

 *Chris W wrote:*   

> You can arrange it by adding the "-h" option in /etc/conf.d/net, e.g.
> 
> ```
> dhcpcd_eth0="-h myhostname"
> ```
> ...

 

Or, 

```
dhcpcd_eth0="-h `/bin/hostname`"
```

which avoids the small maintenance issue of having the host name in two different locations.

- John

----------

## Chris W

There should no longer be any need to hardcode this.   The new baselayout (1.11+) sends the hostname by default.  If the user explicitly sends their own with a line like the ones above or specifies "nosendhost" in $dhcp_eth0 then the baselayout code does not add the (another) hostname.   See /lib/rcscripts/net.modules.d/dhcpcd for the gory details.

----------

## John R. Graham

Chris,

You're absolutely right.  I had earlier coded a solution to a problem and didn't notice it when the problem went away.

Regards,

John

----------

