RTNETLINK answers: Cannot assign requested address 手動設置MAC地址出現的錯誤

問題描述

在開啓qeme虛擬機的時候,手動填寫了內部網卡的MAC地址,但是啓動虛擬機之後,從其他同網段的機器並不能ssh到這臺虛擬機上面。

解決步驟

  1. 直接把qemu前臺運行,直接登陸到qemu裏面。
  2. 看到網卡的狀態是down的,MAC地址就是啓動虛擬機時候傳入的參數。
  3. 使用命令去啓動這塊網卡:
ip link set ens3 up 
ifup ens3
  1. 出現了報錯信息:
RTNETLINK answers: Cannot assign requested address

解決辦法

這個是因爲MAC地址有規定造成的,由於我之前的MAC地址是瞎填的,沒有遵照這個規則,所以網卡啓動不起來。

MAC addresses have two special bits in the first byte:
Bit 0 is the “multicast” bit, noting that the address is a multicast or broadcast address
Bit 1 is the “local” bit, indicating that the MAC address was not assigned by the vendor and might not be entirely unique.
You are trying to set an address that has the multicast bit set, which does not work because any reply to your host would be interpreted as a multicast packet.
Also, when you change a MAC address and do not have an OUI assigned to you, please set the local assignment bit.

大致意思就是:
在MAC地址的第一個byte裏面,第一個bit代表的是這個MAC是否是一個廣播或者多播地址,第二個bit代表的是這個MAC地址是不是供應商提供給你的,如果爲0的話,那麼這個MAC地址有可能會重複。

所以在設置MAC地址的時候需要把這兩個bit都設置成0:代表這個MAC不是一個廣播或者多播地址,這個MAC也有可能重複(因爲是自己瞎填的)
對照之前之後的兩個MAC

之前:a7:ff:23:a1:8c:1d
之後:aa:ff:23:a1:8c:1d

看到只是改了第一個byte

10100111 --> 10101010

因爲之前我把第一個bit設置成了1,那麼這臺機器發出來的包都會被當成廣播包,被丟棄。

相關連接

傳送門

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章