博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
raspberry pi_如何确保Raspberry Pi始终具有相同的IP地址
阅读量:2506 次
发布时间:2019-05-11

本文共 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:

The Router Admin Panel

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服务器面板显示了它:

The VNC Connect panel

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/

你可能感兴趣的文章
下滑线驼峰互转
查看>>
Xcode 快捷键
查看>>
table_open_cache
查看>>
Java中super的几种用法并与this的区别
查看>>
C#利用NPOI操作Excel文件
查看>>
彻底了解指针数组,数组指针,以及函数指针 .
查看>>
浏览器兼容问题【转】
查看>>
python编程 之 PyMysql包接口,python中如何使用数据库
查看>>
WinForm 简单蒙版实现控件遮盖
查看>>
ASP.NET MVC ValueProvider小结
查看>>
ES6之路第二篇:变量的解构赋值
查看>>
iOS6新特征:UICollectionView介绍
查看>>
分享一个基于Bootstrap的 ACE框架 入门(MVC+EF)
查看>>
增量关联规则挖掘—FUP算法
查看>>
spring相关—AOP编程—切入点、连接点
查看>>
animation_Frame动画图片轮播
查看>>
BZOJ 4195 - 离散化 + 并查集
查看>>
Oracle常用数据类型
查看>>
信息安全技术 作业5
查看>>
Java关键字final、static使用总结
查看>>