mac地址到底是用来做什么的?

本地网络上的每个硬件除了本地路由器或服务器分配给它的IP地址外,还有一个MAC地址。那个MAC地址到底是用来干什么的?...

mac地址到底是用来做什么的?

本地网络上的每个硬件除了本地路由器或服务器分配给它的IP地址外,还有一个MAC地址。那个MAC地址到底是用**什么的?

今天的问答环节是由SuperUser提供的,SuperUser是Stack Exchange的一个分支,是一个由社区驱动的问答网站分组。

问题

超级用户读者Vishnu Vivek对MAC地址及其功能很好奇:

I understand that IP addresses are hierarchical, so that routers throughout the internet know which direction to forward a packet. With MAC addresses, there is no hierarchy, and thus packet forwarding would not be possible. So, MAC addresses are not used for packet transfer.

I don’t think it sits there for no reason. So my question is, where exactly does a MAC address come into play during a packet transfer?

到底在哪里?MAC地址的具体功能是什么?

答案

超级用户贡献者Werner Henze对MAC地址的功能提供了一些见解:

What are MAC addresses used for?

MAC addresses are the low level basics that make your ethernet based network work.

Network cards each have a unique MAC address. Packets that are sent on the ethernet are always coming from a MAC address and sent to a MAC address. If a network adapter is receiving a packet, it is comparing the packet’s destination MAC address to the adapter’s own MAC address. If the addresses match, the packet is processed, otherwise it is discarded.

There are special MAC addresses, one for example is ff:ff:ff:ff:ff:ff, which is the broadcast address and addresses every network adapter in the network.

How do IP addresses and MAC addresses work together?

IP is a protocol that is used on a layer above ethernet. Another protocol for example would be IPX.

When your computer wants to send a packet to some IP address x.x.x.x, then the first check is if the destination address is in the same IP network as the computer itself. If x.x.x.x is in the same network, then the destination IP can be reached directly, otherwise the packet needs to be sent to the configured router.

Up to now things seem to have gotten worse, because now we have two IP addresses: one is the original IP packet’s target address, the other is the IP of the device to which we should send the packet (the next hop, either the final destination or the router).

Since ethernet uses MAC addresses, the sender needs to get the MAC address of the next hop. There is a special protocol ARP (address resolution protocol) that is used for that. Once the sender has retrieved the MAC address of the next hop, he writes that target MAC address into the packet and sends the packet.

How does ARP work?

ARP itself is a protocol above ethernet, like IP or IPX. When a device wants to know the MAC address for a given IP address, it sends a packet to the broadcast MAC address asking “Who has IP address y.y.y.y?” All devices receive that packet, but only the one with the IP address y.y.y.y will respond with a packet “It’s me.” The asking device receives the answer and now knows that the source MAC address is the right MAC address to use. Of course the result will be cached, so the device does not need to resolve the MAC address every time.

Routing

I almost forgot to mention: there is no routing based on MAC addresses. Low level ethernet and MAC addresses can only reach every device on the same network (cabled or wireless). If you have two networks with a router in between you cannot have a device in network A send a packet to the MAC address of a device in network B. No device in network A has the MAC address of the device in network B, so a packet to this MAC address will be discarded by all devices in the network A (also by the router).

Routing is done on IP level. Simply seen the router is just doing what I described above in the section “How do IP addresses and MAC addresses work together?”. The router will receive packets for its own MAC address but for a different IP address. He will then check if he can directly reach the target IP address. If so, he sends the packet to the target. Otherwise the router itself also has an upstream router configured and will send the packet to that router.

Of course you can have multiple routers configured. Your home router will only have one upstream router configured, but in the internet backbone the big routers have big routing tables so they know the best ways for all packets.

Other use cases for MAC addresses

  1. Network switches store a list of MAC addresses seen at every port and only forward packets to the ports that need to see the packet.
  2. Wireless access points often use MAC addresses for access control. They only allow access for known devices (MAC address is unique and identifies devices) with the correct passphrase.
  3. DHCP servers use the MAC address to identify devices and give some devices fixed IP addresses.

有什么要补充的解释吗?在评论中发出声音。想从其他精通技术的Stack Exchange用户那里了解更多答案吗?在这里查看完整的讨论主题。

  • 发表于 2021-04-11 16:47
  • 阅读 ( 302 )
  • 分类:互联网

你可能感兴趣的文章

如何更改mac的mac地址(以及原因)

MAC地址是每个连接到internet的硬件设备附带的序列号。它是网络的组成部分,因为它可以通过网络对硬件设备进行唯一标识。这样可以确保数据包被发送到正确的位置。 ...

  • 发布于 2021-03-13 06:39
  • 阅读 ( 265 )

了解ip和mac地址:它们有什么好处?

如果“IP地址”和“MAC地址”这两个词让你头脑发晕,别担心;它们相对容易理解。事实上,这和你已经习惯的邮政服务没什么不同! ...

  • 发布于 2021-03-13 11:32
  • 阅读 ( 295 )

如何将imessage与airmessage和mac一起在android上使用

... 首先,您需要记下计算机的IP地址。打开“首选项”,然后转到“网络”。在窗口顶部附近,您将看到一条消息,显示您所连接的网络。您的IP地址也列在这里。 ...

  • 发布于 2021-03-21 16:37
  • 阅读 ( 270 )

tiktok在android手机上收集设备数据时被捕获

...未经用户同意就收集了Android设备的MAC(媒体访问控制)地址。尽管谷歌此前禁止了这种做法,但TikTok一年多来一直在秘密窃取设备数据。 ...

  • 发布于 2021-03-30 15:12
  • 阅读 ( 328 )

如何在mac上查找和更改ip地址

... 找到你的Mac的IP地址并不困难,你可以在同一个面板上改变它。为了提供信息,您可能需要再次检查Mac的IP地址,或者您遇到了“网络上的另一个设备正在使用您的计算机的IP地址”错误...

  • 发布于 2021-03-30 19:17
  • 阅读 ( 349 )

执法部门真的能追踪到有ip地址的人吗?

...是谁的面包屑。其中一些比其他的大,但最大的是你的IP地址。有了这个武器,执法人员就不难发现你的身份了。 什么是ip地址(ip addresses)? 在深入研究实用性之前,让我们先定义一下IP地址到底是什么。简言之,它是一个数字...

  • 发布于 2021-04-02 00:15
  • 阅读 ( 197 )

什么是助理服务和助理,为什么它们在我的mac上运行?

...联系人和日历约会之类的内容,这正是Siri查找电子邮件地址和日程安排所需要的。 因此,虽然我们无法确认这些进程到底在做什么,但我们可以满怀信心地说,它们是macOS的合法组成部分,它们与Siri和Spotlight有关。 一些用户报...

  • 发布于 2021-04-05 08:13
  • 阅读 ( 275 )

如何在googlewifi上更改设备名称

...以将它定位到那个位置。 相关:如何找到任何设备的IP地址、MAC地址和其他网络连接详细信息 从这里开始,最好的方法就是通过IP地址来识别这是哪个设备。因此,你需要知道如何在你所有的设备上找到IP地址,这很有挑战性。...

  • 发布于 2021-04-06 22:17
  • 阅读 ( 134 )

如何(以及为什么)在windows、linux和mac上更改mac地址

设备的MAC地址是由**商指定的,但在需要时更改或“欺骗”这些地址并不难。下面是如何做到这一点,以及为什么你可能想。 连接到网络的每个网络接口(无论是路由器、无线设备还是计算机中的网卡)都有一个唯一的媒体访...

  • 发布于 2021-04-07 15:20
  • 阅读 ( 206 )

如何查找任何设备的ip地址、mac地址和其他网络连接详细信息

...算机、智能**、平板电脑、智能家居小工具等都有一个IP地址和一个唯一的MAC地址,可以在您的网络上识别它。以下是如何在你可能拥有的所有设备上找到这些信息。 在本教程中,我们将讨论如何在本地网络上查找设备的IP地址...

  • 发布于 2021-04-07 20:34
  • 阅读 ( 180 )
qnirhuxztc
qnirhuxztc

0 篇文章

相关推荐