# dnsmasq can resolve fqdn of server but can not ping

## SteveYin

I have a lan with a gateway/dhcp/samba server, now I want to switch to use dnsmasq as a name/dhcp server, so I have these in my dnsmasq.conf

```

domain-needed

bogus-priv

no-resolv

no-poll

server=61.155.5.6

server=122.200.77.34

local=/mylan.com/

interface=enp5s0

domain=mylan.com,192.168.0.0/24

dhcp-range=192.168.0.20,192.168.0.240,12h

cache-size=4096

no-negcache

log-dhcp

```

and this in my /etc/hosts

```

127.0.0.1       localhost

::1             localhost

192.168.0.1     server.mylan.com

```

if I add some dummy server to dnsmasq like address=/dummy.mylan.com/192.168.0.x, then I can nslookup the dummy or dummy.mylan.com, and also can ping these two hosts.

but my server's name is server, and I can nslookup server.mylan.com or nslookup server, both will give me correct ip address of 192.168.0.1, but I can not ping the server.mylan.com, the ping command on windows give me this

```

Ping request could not find host server.mylan.com. Please check the name and try again.

```

so what's wrong with my config? my server's ip address are static to 192.168.0.1, how can I both ping server and server.mylan.com?

----------

## SteveYin

got it!

the /etc/hosts file can only have the hostname part, so hosts file can only have

192.168.0.1 server 

and can not use the fqdn name in hosts file

then add a address line to dnsmask.conf like

address=/server.mylan.com/192.168.0.1

then this will allow ping both server and server.mylan.com

----------

## khayyam

 *SteveYin wrote:*   

> the /etc/hosts file can only have the hostname part, so hosts file can only have 192.168.0.1 server and can not use the fqdn name in hosts file

 

SteveYin ... yes it can ...

```
# echo "204.187.15.12 forums.gentoo.org" >> /etc/hosts

# ping -c 1 forums.gentoo.org

PING forums.gentoo.org (204.187.15.12) 56(84) bytes of data.

64 bytes from forums.gentoo.org (204.187.15.12): icmp_seq=1 ttl=50 time=189 ms

--- forums.gentoo.org ping statistics ---

1 packets transmitted, 1 received, 0% packet loss, time 0ms

rtt min/avg/max/mdev = 189.336/189.336/189.336/0.000 ms
```

best ... khay

----------

