1

I want to know the best way to connect my RBP by wifi using the MAC Address. I currently use sudo nmap -sn 192.168.0.0/24 and obtain this

Nmap scan report for 192.168.0.114
Host is up (0.025s latency).
MAC Address: B8:27:EB:50:00:00 (Raspberry Pi Foundation)

and after that, I connected to the RBP by SHH ssh pi@192.168.0.114

the problem is that my internet connection is so unstable so, I have to repeat this a lot of times.

Is any way to connect directly by MAC?

Edit: Actually I am using Dataplicity for alternative third-party solutions.

7
  • Hello, have you tried ssh pi@raspberrypi.local where raspberrypi is the hostname of your PiZW courtesy of the Avahi daemon and mDNS? raspberrypi.org/documentation/remote-access/ip-address.md – Roger Jones Apr 6 '19 at 16:12
  • @RogerJones raspberrypy.local is reserved for link-local addresses from 169.254.0.0/16. The RasPi has a private address so it cannot work. – Ingo Apr 6 '19 at 18:58
  • 1
    @ingo Hmmm, I thought the .local addresses were for any private address? Anyway, the question read to me as if the OP was actually asking for a way to SSH to the Pi without having to scan for it's IP address each time. – Roger Jones Apr 6 '19 at 19:29
  • 1
    @ingo link-local addresses have NOTHING to do with.local; I use .local as my normal addressing mode on my home network. – Milliways Apr 6 '19 at 22:03
  • 1
    Thank you @RogerJones! I have been able to connect with ssh pi@raspberrypi.local – Pedro Rout Apr 6 '19 at 23:52
3

You can not connect by MAC - although you could use MAC to resolve IP.

You DO NOT need to know the IP address to connect to your Pi.
You can just connect to your server by name e.g. raspberrypi.local instead of IP address.
(NOTE raspberrypi is the default hostname, and can/should be changed).

You can easily connect from Linux and OS X with ssh pi@hostname.local (the default hostname is raspberrypi) This should work with popular GUI ssh programs. This is sometimes problematic with some versions of Windows and networks which use .local in a non-standard way. (See https://en.wikipedia.org/wiki/.local)

NOTE .local resolution does not always work e.g. in rsync. The following should resolve IP (and can be included in bash scripts)

RemotePi=$(getent hosts hostname.local | awk '{ print $1 }')

If you REALLY want to know the IP address you can discover it by many means;

arp raspberrypi.local on most networks (arp raspberrypi may work on some)

e.g.

arp archpi.local
archpi.local (10.1.1.20) -- no entry

or

getent hosts archpi.local | awk '{ print $1 }'
10.1.1.20

or

ping -c 1 archpi.local
PING archpi.local (10.1.1.20): 56 data bytes
64 bytes from 10.1.1.20: icmp_seq=0 ttl=64 time=4.607 ms
2
  • Thanks! I have been able to connect with ssh pi@raspberrypi.local – Pedro Rout Apr 6 '19 at 23:53
  • 1
    It's misleading to say that, "You DO NOT need to know the IP address to connect to your Pi." At some level, the IP address must be known. If not by you explicitly, then by the software you are using. And not all systems from which someone may initiate a connection will participate in mDNS/avahi/Bonjour or the other flavors of zero configuration networking that are in play today. – Seamus Apr 7 '19 at 16:20
1

If you want to use IP network connections, then there is no other way to address devices than with ip addresses. This is by design that can be described with the OSI model (Open Systems Interconnection model). Network connections are made on Layer 3: Network Layer using ip addresses. MAC addresses are used on the underlaying Layer 2: Data Link Layer to recover the ip address from the device by using the arp protocol. But it is not used for connections.

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.