1

I'm using a vm setup with the following options:

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

However, no IPv4 is assigned. Inspecting the dhcpcd service and running it manually I see the following output:

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

While if I run it without any parameters I see:

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

How can I configure Nixos/nix to have a IPv4 assigned?


The config file in question:

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

3
  • Maybe there's nothing wrong in the VM, but the problem is on the host side. Look about -netdev tap (or even -netdev bridge) in the man pages Commented Feb 20, 2020 at 20:10
  • Seems to be a bug that is mentioned here also: github.com/NixOS/nixops/issues/500 Commented Feb 20, 2020 at 20:17
  • Good your link explains how to troubleshoot: check host networking, how is running the DHCP server on host, verify that with a static IP it works, use tcpdump etc. Commented Feb 20, 2020 at 20:23

1 Answer 1

0

You need a vlan or virtual network defined. Create a working VM with virt-manager GUI and then compare the Qemu config to yours. If you want your VM on your real network rather than a host only NAT, use a bridge to back your network device.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.