DHCPOFFER 没有跨越 Linux 上的虚拟桥?

DHCPOFFER 没有跨越 Linux 上的虚拟桥?

我有一台运行 Ubuntu 20.4LTS(已完全修补)的物理主机连接到我的网络,它通过 DHCP 检索其 IP 地址。这有效。

我在该主机上有一个 VirtualBox VM,它连接到桥接接口(物理 NIC 上的 macvlan),正在尝试从同一个 DHCP 服务器获取 IP 地址。

在主机上使用时tcpdump -i ethXXX port 67 or port 68 -e -n -vv,我看到此消息多次重复发出:

15:04:52.845988 66:66:66:66:66:12 > ff:ff:ff:ff:ff:ff, ethertype IPv4 (0x0800), length 342: (tos 0x10, ttl 128, id 0, offset 0, flags [none], proto UDP (17), length 328)
    0.0.0.0.68 > 255.255.255.255.67: [udp sum ok] BOOTP/DHCP, Request from 66:66:66:66:66:12, length 300, xid 0x84ce756d, secs 6, Flags [none] (0x0000)
          Client-Ethernet-Address 66:66:66:66:66:12
          Vendor-rfc1048 Extensions
            Magic Cookie 0x63825363
            DHCP-Message Option 53, length 1: Discover
            Hostname Option 12, length 6: "nodename"
            Parameter-Request Option 55, length 17: 
              Subnet-Mask, BR, Time-Zone, Default-Gateway
              Domain-Name, Domain-Name-Server, Option 119, Hostname
              Netbios-Name-Server, Netbios-Scope, MTU, Classless-Static-Route
              NTP, Classless-Static-Route-Microsoft, Static-Route, Option 252
              RP

在 DHCP 服务器上,我看到它进入,并发送了回复:

15:05:57.193384 66:66:66:66:66:12 > ff:ff:ff:ff:ff:ff, ethertype IPv4 (0x0800), length 342: (tos 0x10, ttl 128, id 0, offset 0, flags [none], proto UDP (17), length 328)
    0.0.0.0.68 > 255.255.255.255.67: [udp sum ok] BOOTP/DHCP, Request from 66:66:66:66:66:12, length 300, xid 0xcede823f, secs 22, Flags [none] (0x0000)
          Client-Ethernet-Address 66:66:66:66:66:12
          Vendor-rfc1048 Extensions
            Magic Cookie 0x63825363
            DHCP-Message Option 53, length 1: Discover
            Hostname Option 12, length 6: "nodename"
            Parameter-Request Option 55, length 17:
              Subnet-Mask, BR, Time-Zone, Default-Gateway
              Domain-Name, Domain-Name-Server, Option 119, Hostname
              Netbios-Name-Server, Netbios-Scope, MTU, Classless-Static-Route
              NTP, Classless-Static-Route-Microsoft, Static-Route, Option 252
              RP
15:05:57.193585 00:0c:29:cc:f8:f6 > 66:66:66:66:66:12, ethertype IPv4 (0x0800), length 342: (tos 0x10, ttl 128, id 0, offset 0, flags [none], proto UDP (17), length 328)
    10.0.0.20.67 > 10.0.0.180.68: [udp sum ok] BOOTP/DHCP, Reply, length 300, xid 0xcede823f, secs 22, Flags [none] (0x0000)
          Your-IP 10.0.0.180
          Client-Ethernet-Address 66:66:66:66:66:12
          Vendor-rfc1048 Extensions
            Magic Cookie 0x63825363
            DHCP-Message Option 53, length 1: Offer
            Server-ID Option 54, length 4: 10.0.0.20
            Lease-Time Option 51, length 4: 14400
            Subnet-Mask Option 1, length 4: 255.255.255.0
            Default-Gateway Option 3, length 4: 10.0.0.20
            Domain-Name Option 15, length 17: "my.domain.for.dhcp"
            Domain-Name-Server Option 6, length 4: 10.0.0.20

别看答复是否到达主机(或显然是到达请求的虚拟机)。

我原本以为这是 VirtualBox 的问题,但现在我认为 Linux 中缺少一些其他设置,无法让第 2 层消息macvlan正确路由到 MAC 地址。

我确实已将ip_forward其设置为 1 英寸/proc/sys/net/ipv4/ip_forward

编辑:用于建立macvlan连接的命令是:

ip link add mvlan_bn_bld2 link eth_int type macvlan mode bridge
ip link set mvlan_bn_bld2 up
ip link set mvlan_bn_bld2 address 66:66:66:66:66:12 up

并且虚拟机网卡的MAC设置为与mvlan_bn_bld2匹配。

编辑:结果发现是驱动程序/NIC 故障导致的。 看这个帖子进行更广泛的讨论。

相关内容