1

I've got a Nas doing DHCP and DNS ip adress = 192.168.0.1

local names are correctly resolved when raspberrypi-0-w ip is set to dynamic

pi@raspberrypi0-w2:~ $ ping munin
PING munin.cesan.lan (192.168.0.51) 56(84) bytes of data.
64 bytes from 192.168.0.51 (192.168.0.51): icmp_seq=1 ttl=64 time=5.07 ms

After setting static ip in /etc/dhcpcd.conf, adress is outside dhcp range

# Inform the DHCP server of our hostname for DDNS.
hostname
# Use the hardware address of the interface for the Client ID.
clientid
# Persist interface configuration when dhcpcd exits.
persistent
# Rapid commit support.
# Safe to enable by default because it requires the equivalent option set
# on the server to actually work.
option rapid_commit
# A list of options to request from the DHCP server.
option domain_name_servers, domain_name, domain_search, host_name
option classless_static_routes
# Most distributions have NTP support.
option ntp_servers
# Respect the network MTU. This is applied to DHCP routes.
option interface_mtu
# A ServerID is required by RFC2131.
require dhcp_server_identifier
# Generate Stable Private IPv6 Addresses instead of hardware based ones
slaac private
# Static IP configuration:
interface wlan0
static ip_address=192.168.0.53/24
static routers=192.168.0.1
static domain_name_servers=192.168.0.1

after reboot:

pi@raspberrypi0-w2:~ $ ping munin
ping: munin: Nom ou service inconnu

local host is unknown

If I ping with adress it's ok

pi@raspberrypi0-w2:~ $ ping 192.168.0.1
PING 192.168.0.1 (192.168.0.1) 56(84) bytes of data.
64 bytes from 192.168.0.1: icmp_seq=1 ttl=64 time=2.48 ms

if I ping outside LAN it seems to resolve the name but I don't get the ping

pi@raspberrypi0-w2:~ $ ping raspberrypi.stackexchange.com
PING raspberrypi.stackexchange.com (151.101.129.69) 56(84) bytes of data.

Is it a problem on Raspbian side or on the DNS side?

cat /etc/resolv.conf

# Generated by resolvconf
nameserver 192.168.0.1
  • may i see your output of 'cat /etc/resolv.conf' – Nicholai Cornilliac Sep 27 '17 at 21:02
  • # Generated by resolvconf nameserver 192.168.0.1 – Penbeuz Sep 27 '17 at 21:03
  • Do you have an entry in your /etc/hosts file such as : 192.168.0.1 munin – Nicholai Cornilliac Sep 27 '17 at 21:20
  • no, just standard hosts file – Penbeuz Sep 27 '17 at 21:25
  • 1
    You should set static domain_search=.local to use non-fqdn based lookups, generally speaking this is specific to your router but .local is common (sometimes .home or something, it should be in router settings). You may also need to set domain_name=.local as well but search should be sufficient – crasic Sep 28 '17 at 0:57
1
  • Add the host IP to the local hosts file

OR

  • Set the DNS Search domain in dhcpcd.conf

    static domain_search=.local

If you want the inverse of this (ping pi based on hostname only) You may also need to add

  • static domain_name=.local or hostname_short

DNS Lookups require a Fully Qualified Domain Name (FQDN), e.g. abc.com

When you do a simple name lookup e.g. ping abc, unless the name is defined in the hosts file, it will not resolved. However, the setting domain_search ` adds one (or more) default domains to append to the dns lookup.

Your router will usually have a default domain, for example .local, but this may be different so look at the configurations

  • Doesn't seem to change anything for me. I will stick to dhcp with some scripts on my NAS to make DHCP know to DNS which machine is connected. – Penbeuz Sep 28 '17 at 11:03
  • I've been running a DNS server on my NAS for months and have very little in my hosts file, certainly not all the computers in my little corner of the internet. And I don't have any problem in lookups, even when I add a new computer. – NomadMaker Jul 16 '18 at 0:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.