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
  • 閱讀 ( 39 )
  • 分類:網際網路

你可能感興趣的文章

澱粉(starch)和麵粉(flour)的區別

...新聞,BBC,2018年10月23日。這裡提供2。”什麼是澱粉?它是用來做什麼的?我們為什麼需要它?“澱粉歐洲。這裡有3。”麵粉〉,維基百科,維基媒體基金會,2019年2月13日。此處提供2.“什麼是澱粉?它是用來做什麼的?我們...

  • 發佈於 2020-10-16 07:09
  • 閲讀 ( 52 )

appdata漫遊和本地漫遊有什麼區別?

...cal、LocalLow和Roaming。為什麼有三個不同的子資料夾,它們是用來做什麼的?答案與域連線的Windows計算機有關,就像在商業環境中一樣。 ...

  • 發佈於 2021-03-13 01:49
  • 閲讀 ( 42 )

使用此互動式地圖可以聽到來自世界各地的口音

...色的世界地圖就會佔據你的螢幕。這裡沒有提到這張地圖到底是用來做什麼的,但是讓你的滑鼠在地圖上來回移動,並加快你的揚聲器。去世界上任何一個國家旅行,聽聽那個國家獨特的口音! ...

  • 發佈於 2021-03-16 07:04
  • 閲讀 ( 37 )

法醫分析員是做什麼的?這份工作適合你嗎?

...的技能。他們需要深入瞭解罪犯是如何工作的,以及他們用來進入系統的方法。 ...

  • 發佈於 2021-03-18 10:49
  • 閲讀 ( 44 )

tiktok在android手機上收集裝置資料時被捕獲

...經使用者同意就收集了Android裝置的MAC(媒體訪問控制)地址。儘管谷歌此前禁止了這種做法,但TikTok一年多來一直在祕密竊取裝置資料。 ...

  • 發佈於 2021-03-30 15:12
  • 閲讀 ( 50 )

如何瞭解蘋果為什麼要向你的信用卡收費

...卡公司 如果你仍然無法確定你的卡上與蘋果有關的費用是用來做什麼的,也許只是因為購買記錄介面太混亂了。也許你家裡有人買了東西忘了告訴你,或者這是欺詐性的指控。 如果您在Apple購買或訂閱記錄中找不到費用,請考...

  • 發佈於 2021-04-01 21:59
  • 閲讀 ( 46 )

選單鍵是用來做什麼的?(以及如何重新對映)

...的選單-一個正方形或矩形,裡面有一些水平線。 選單鍵是用來做什麼的? 選單鍵開啟當前應用程式的上下文選單。基本上就像在應用程式中右鍵單擊所選內容。 在檢視此網頁時按“功能表”鍵,您將看到web瀏覽器的上下文選...

  • 發佈於 2021-04-03 11:02
  • 閲讀 ( 58 )

景深預覽按鈕在相機上的作用是什麼?

你有沒有想過單反相機鏡頭旁邊的按鈕是用來做什麼的?不是你用來拆開鏡頭的那個,而是另一個?這是景深預覽按鈕。我們挖吧。 景深重演 一幅影象的景深就是它的焦距。像這樣景深較淺的影象,除了聚焦的物件外,幾乎...

  • 發佈於 2021-04-05 05:01
  • 閲讀 ( 39 )

如何查詢任何裝置的ip地址、mac地址和其他網路連線詳細資訊

...算機、智慧**、平板電腦、智慧家居小工具等都有一個IP地址和一個唯一的MAC地址,可以在您的網路上識別它。以下是如何在你可能擁有的所有裝置上找到這些資訊。 在本教程中,我們將討論如何在本地網路上查詢裝置的IP地址...

  • 發佈於 2021-04-07 20:34
  • 閲讀 ( 46 )

電腦機箱側面的彈性彈簧片是用來做什麼的?

...題 超級使用者讀者VAN想知道電腦機箱側面的彈性彈簧片是用來做什麼的: Many computer cases have these holes/cut-outs/tabs on the outer edge of the frame. What are they for? 電腦機箱側面的彈性彈簧片是用來做什麼的? 答案 超級使用者貢獻者VAN為...

  • 發佈於 2021-04-08 16:57
  • 閲讀 ( 44 )
qnirhuxztc
qnirhuxztc

0 篇文章

作家榜

  1. admin 0 文章
  2. 孫小欽 0 文章
  3. JVhby0 0 文章
  4. fvpvzrr 0 文章
  5. 0sus8kksc 0 文章
  6. zsfn1903 0 文章
  7. w91395898 0 文章
  8. SuperQueen123 0 文章

相關推薦