Nixos VM 没有通过 dhcpcd 分配 IPv4 地址

Nixos VM 没有通过 dhcpcd 分配 IPv4 地址

我正在使用具有以下选项的虚拟机设置:

    qemu.networkingOptions = [
                               "-device e1000,netdev=abc,mac=52:55:00:d1:55:02"
                               "-netdev tap,id=abc,ifname=tapB,script=no,downscript=no"
                             ];

但是,没有分配 IPv4。检查dhcpcd服务并手动运行它,我看到以下输出:

dhcpcd -w --config /nix/store/vvcrfgj2ni09gqc9l4rin9aq8asp73k9-dhcpcd.conf
dev: loaded udev
DUID 00:01:00:01:25:dc:a1:45:52:54:00:12:34:56
eth0: IAID 00:d1:55:02
eth0: adding address fe80::5055:ff:fed1:5502
eth0: soliciting a DHCP lease
eth0: soliciting an IPv6 router
eth0: no IPv6 Routers available
timed out
forked to background, child pid 752

如果我在没有任何参数的情况下运行它,我会看到:

dhcpcd
read_config: fopen `/etc/dhcpcd.conf': No such file or directory
dev: loaded udev
read_config: fopen `/etc/dhcpcd.conf': No such file or directory
DUID 00:01:00:01:25:dc:a1:45:52:54:00:12:34:56
eth0: IAID 00:d1:55:02
eth0: adding address fe80::5055:ff:fed1:5502
eth0: soliciting a DHCP lease
eth0: soliciting an IPv6 router
eth0: probing for an IPv4LL address
eth0: using IPv4LL address 169.254.228.140
eth0: adding route to 169.254.0.0/16
eth0: adding default route
forked to background, child pid 705

如何配置 Nixos/nix 来分配 IPv4?


有问题的配置文件:

cat /nix/store/vvcrfgj2ni09gqc9l4rin9aq8asp73k9-dhcpcd.conf
# Inform the DHCP server of our hostname for DDNS.
hostname

# A list of options to request from the DHCP server.
option domain_name_servers, domain_name, domain_search, host_name
option classless_static_routes, ntp_servers, interface_mtu

# A ServerID is required by RFC2131.
# Commented out because of many non-compliant DHCP servers in the wild :(
#require dhcp_server_identifier

# A hook script is provided to lookup the hostname if not set by
# the DHCP server, but it should not be run by default.
nohook lookup-hostname

# Ignore peth* devices; on Xen, they're renamed physical
# Ethernet cards used for bridging.  Likewise for vif* and tap*
# (Xen) and virbr* and vnet* (libvirt).
denyinterfaces ve-* vb-* lo peth* vif* tap* tun* virbr* vnet* vboxnet* sit*

# Use the list of allowed interfaces if specified



noarp

答案1

您需要定义一个 VLAN 或虚拟网络。使用 virt-manager GUI 创建一个工作虚拟机,然后将 Qemu 配置与您的配置进行比较。如果您希望虚拟机位于真实网络上,而不是仅主机 NAT,请使用网桥来支持您的网络设备。

相关内容