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,那么这台机器发出来的包都会被当成广播包,被丢弃。

相关连接

传送门

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值