-1

My Raspberry Pi 4 B is connected (for the first time) to the WiFi of my PC (running Windows). Then the raspberry(ip) showed up in the list in Network Scanner of MobaXterm. What surprised me is that the list also shows the name of my Pi. And ping -a ip also shows the name.

How does this work?

Lyndon Gingerich
  • 604
  • 7
  • 17
BAKE ZQ
  • 765
  • 6
  • 22

1 Answers1

3

When the Raspberry Pi connects to your WiFi it doesn't just get an IP address assigned. It also gets a host name assigned. It either sends its own host name to the DHCP server or the DHCP server assigns a host name.

Now, when you have an IP address, you can do a reverse search. Usually DNS works in the way that you give it a name and it returns the IP address. But there is also reverse search, give it an IP address and get a name back.

In your local network the DHCP server and your DNS resolver work together. Whenever a reverse search for a local IP address is made, the answer is fetched from the DHCP server. And the DHCP server answers with the host name from step one.

In most WiFi routers dnsmasq does this for you, on a Windows machine it is built into Windows.

Wai Ha Lee
  • 8,598
  • 83
  • 57
  • 92
Ulrich Wisser
  • 56
  • 1
  • 1