2

I have a wifi extender at home, every device is connected to it, not the router. After connecting to the wifi extender, I can access RPi by local ip address, but not its hostname. When I try to ping by its hostname, it doesn't work. I can not access it by a browser.

In the wifi extender, I am able to see its hostname:

router config

Also, here is the hostname

pi@rpi ~ $ host name
rpi

I am able to access it own host name on the Raspberry Pi itself: Web Browser on rpi

here is nslookup:

Server:  UnKnown
Address:  10.0.0.1

Non-authoritative answer:
Name:    rpi
Address:  92.242.140.21
2
  • There are many answers to this. These depend on what version of Raspbian, what PC and what zeroconf software is in use.
    – Milliways
    Sep 12, 2015 at 23:00
  • Umm... Why not use its IP address? (after you set a static IP or find out the pi's current IP)
    – Aloha
    Nov 20, 2015 at 9:46

4 Answers 4

1

Do you have a local DNS server setup? You'll either need that or you'll need to add entries to your hosts files on your devices so they can resolve that hostname to ip.

1

You need either of these two things to ping any host (including RPi) by name

  1. DNS Server You may already have a locally hosted DNS server if you are in an office network. You may setup one of you RPi using dnsmasq pacakage
  2. avahi or other zeroconf Raspbian now have avahi daemon

If all you need is pinging by hostname, I would not advise you setting up a full-blown DNS Server locally (though it can speedup you DNS lookup).

So, just try hostname.local from other devices and it should work by default. In your case - ping rpi.local

Most OSes (PC as well as mobile) now come with avahi/zeroconf/bonjour, so the ping should work without a hitch.

On Windows, you get bonjour if you install iTunes. However, if you dont want to install iTunes just to get Bonjour, then download the iTunes installer and instead of running its setup, open it up like a zip file, extract the Bonjour setup inside it and execute that alone.

Hope this helps! :-)

0

Make sure you point dns to your router (update your dhcp pool to include the router first) instead of your ISP dns. Most routers can support enough to give you local name resolution and dynamic dns registration, or setup your own dns server on something like your pi.

-1

To lookup a host (your raspberry pi is a host) by name, you need a lookup table which lists hosts and their ip addresses.

In real world the lookup table can be present in several places including two below:

  1. Your source host. This is taken care by host files as droo5ki mentioned.
  2. On your network where it provides lookup service to devices on your network.

1. Hosts Files:

The first option of host file is viable where there are only a few hosts on the network. This method is manual but not very scaleable. The hoist file is local to one computer only and on a small network, you need to replicate this file to other hosts if they need to do a lookup. This solution is manual and simple. In Linux you can simply edit /etc/hosts file. Use this tutorial for Linux.

For example, in windows 7 the host file is located at %systemroot%\system32\drivers\etc\

Here is an example to edit your hosts file.

2. Lookup services on your network:

There are several services that you can deploy on your network to provide you a name lookup. These services can be DNS (most popular), NIS, NIS+, LDAP, etc.

For simplicity reasons I will only discuss DNS service here. DNS service is meant for a larger scale network. It is scalable and can provide several services apart from just name lookup. Here is how DNS works. This solution is automatic and deployment is a bit complex (relative) than #1 solution above.

To answer your question, you need to deploy one of the above solutions on your host and/or your network. Deploying DNS services is beyond the scope of this forum. Your best option will be to use hosts file if your network is small. In order to lookup your host from host itself, you need to add its' own entry in its' hosts file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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