本文共 2579 字,大约阅读时间需要 8 分钟。
raspberry pi
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.
我最近得到了一个Raspberry Pi进行测试,并建立了一些项目构想,并且在安装Raspbian(专门为Raspberry Pi制作的Linux版本的Debian)之后,我遇到了问题。
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”.
我使用HDMI电缆将Raspberry Pi连接到电视,并连接了USB鼠标和USB键盘以安装操作系统并进行“连接”。
I then set up the VNC Server on the Pi to be able to connect to it from the Mac.
然后,我在Pi上设置了VNC服务器,以便能够从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.
当我拆除所有这些电缆时,为了只让Raspberry Pi连接到电源线上,我意识到,只要重新启动它,分配给它的IP地址就会改变。
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.
这是因为DHCP,WiFi路由器使用的协议。 它不会为每个连接的设备分配固定的IP:IP一直在变化。
Sometimes it’s 192.168.1.2
. Sometimes it’s 192.168.1.30
. Sometimes it’s 192.168.1.43
.
有时是192.168.1.2
。 有时是192.168.1.30
。 有时是192.168.1.43
。
I don’t really want to spend time every time to find what’s the Raspberry Pi IP address, right? It’s annoying.
我真的不想每次都花时间去寻找Raspberry Pi IP地址是什么,对吗? 它很烦人。
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.
因此,我发现可以通过标识其MAC地址来为特定设备分配固定IP。 MAC地址(也称为媒体访问控制地址)是唯一标识符。 每种设备都有不同的设备。
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.
因此,我连接到我的WiFi路由器,该路由器在本地网络的IP 192.168.1.1
上运行,然后转到DHCP服务器菜单。
In there, I clicked “Static DHCP” and I was able to assign a specific IP to the MAC address of my Raspberry Pi:
在其中,单击“静态DHCP”,然后可以为Raspberry Pi的MAC地址分配一个特定的IP:
How did I find the MAC address of the Pi?
我如何找到Pi的MAC地址?
I knew the IP address because the VNC Server panel on the Raspberry Pi showed it:
我知道IP地址,因为Raspberry Pi上的VNC服务器面板显示了它:
Then using my MacBook Air I scanned the network using:
然后使用MacBook Air,我使用以下方法扫描了网络:
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:
这会打印出所有连接到网络的设备的IP和MAC地址,包括我感兴趣的Raspberry PI:
? (192.168.1.42) at dc:a6:32:60:20:81 on en0 ifscope [ethernet]
翻译自:
raspberry pi
转载地址:http://htmgb.baihongyu.com/