I recently got a Raspberry Pi for testing, and to build some projects ideas I have, and right after installing Raspbian, the Linux version of Debian specifically made for the Raspberry Pi, I had a problem.
I attached the Raspberry Pi to the TV, using the HDMI cable, and I attached an USB mouse and USB keyboard to install the OS and get all “wired up”.
I then set up the VNC Server on the Pi to be able to connect to it from the Mac.
As I was removing all those cables, in order to only let the Raspberry Pi attached to the power cable, I realized that as soon as I restarted it, the IP address assigned to it would change.
This is because of DHCP, the protocol that is used by the WiFi router. It does not assign a fixed IP to every device connected: the IP changes all the time.
I don’t really want to spend time every time to find what’s the Raspberry Pi IP address, right? It’s annoying.
So I found out that I can assign a fixed IP to a specific device, by identifying its the MAC address. The MAC address, aka Media Access Control Address, is a unique identifier. Every device has a different one.
So I connected to my WiFi router, which is running on IP
192.168.1.1 on my local network, and I went to the DHCP Server menu.
In there, I clicked “Static DHCP” and I was able to assign a specific IP to the MAC address of my Raspberry Pi:
How did I find the MAC address of the Pi?
I knew the IP address because the VNC Server panel on the Raspberry Pi showed it:
Then using my MacBook Air I scanned the network using:
ifconfig | grep broadcast | arp -a
This printed the IP and MAC addresses of all devices connected to the network, including the one I was interested in, the Raspberry PI:
? (192.168.1.42) at dc:a6:32:60:20:81 on en0 ifscope [ethernet]
More computers tutorials:
- Finite State Machines
- The Decimal Number System
- The Binary Number System
- Converting Numbers from Decimal to Binary
- Printable ASCII characters list
- Non-printable ASCII characters list
- How to connect to a Raspberry Pi using a Mac
- How to make sure the Raspberry Pi has always the same IP address
- A very short introduction to COBOL