10

I have a machine running Ubuntu Server 18.04. The network is configured using Netplan, so I have this config in /etc/netplan/01-netcfg.yaml:

network:
  version: 2
  renderer: networkd
  ethernets:
    enp1s0f0:
      optional: false
      addresses:
        - 10.0.0.1/24    
  wifis:
    wlp2s0:
      optional: true
      dhcp4: yes
      access-points:
        [...]

enp1s0f0 is connected to a device that may or may not be on (at boot or any other time). I want to run a DHCP server on this interface.

The trouble is, when I boot there's a delay of a few minutes and I see this message:

A start job is running for Wait for Network to be Configured

Eventually it times out, the boot continues, but enp1s0f0 is never configured or brought up. ip link show enp1s0f0 gives:

2: enp1s0f0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN mode DEFAULT group default qlen 1000
    link/ether 10:dd:b1:ef:65:21 brd ff:ff:ff:ff:ff:ff

I have no idea what the significance of NO-CARRIER is, but in case it's relevant, here's the output of sudo lspci -v:

01:00.0 Ethernet controller: Broadcom Limited NetXtreme BCM57766 Gigabit Ethernet PCIe (rev 01)
    Subsystem: Broadcom Limited NetXtreme BCM57766 Gigabit Ethernet PCIe
    Flags: bus master, fast devsel, latency 0, IRQ 16
    Memory at a0400000 (64-bit, prefetchable) [size=64K]
    Memory at a0410000 (64-bit, prefetchable) [size=64K]
    Capabilities: [48] Power Management version 3
    Capabilities: [50] Vital Product Data
    Capabilities: [58] MSI: Enable- Count=1/8 Maskable- 64bit+
    Capabilities: [a0] MSI-X: Enable+ Count=6 Masked-
    Capabilities: [ac] Express Endpoint, MSI 00
    Capabilities: [100] Advanced Error Reporting
    Capabilities: [13c] Device Serial Number 00-00-10-dd-b1-ef-65-21
    Capabilities: [150] Power Budgeting <?>
    Capabilities: [160] Virtual Channel
    Capabilities: [1b0] Latency Tolerance Reporting
    Kernel driver in use: tg3
    Kernel modules: tg3

Now if I turn the attached device on, sure enough enp1s0f0 comes up:

2: enp1s0f0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT group default qlen 1000
    link/ether 10:dd:b1:ef:65:21 brd ff:ff:ff:ff:ff:ff

But it's of no use at this point — the DHCP server won't work, because it couldn't start with enp1s0f0 no up at boot time. I need enp1s0f0 up and configured during boot, which I thought was the whole point of a static IP configuration. Even stranger is that it always has an IPv6 address, even when it's down:

2: enp1s0f0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN group default qlen 1000
    link/ether 10:dd:b1:ef:65:21 brd ff:ff:ff:ff:ff:ff
    inet6 fe80::12dd:b1ff:feef:6521/64 scope link 
       valid_lft forever preferred_lft forever

If I check Netplan's debug output, I see:

$ sudo netplan --debug apply
** (generate:1555): DEBUG: 20:39:27.253: Processing input file //etc/netplan/01-netcfg.yaml..
** (generate:1555): DEBUG: 20:39:27.254: starting new processing pass
** (generate:1555): DEBUG: 20:39:27.254: wlp2s0: adding wifi AP 'Jeff Winger's Wireless Hairbrush'
** (generate:1555): DEBUG: 20:39:27.254: wlp2s0: setting default backend to 1
** (generate:1555): DEBUG: 20:39:27.254: enp1s0f0: setting default backend to 1
** (generate:1555): DEBUG: 20:39:27.254: Generating output files..
** (generate:1555): DEBUG: 20:39:27.254: wlp2s0: Creating wpa_supplicant configuration file run/netplan/wpa-wlp2s0.conf
** (generate:1555): DEBUG: 20:39:27.254: Creating wpa_supplicant service enablement link /run/systemd/system/multi-user.target.wants/[email protected]
** (generate:1555): DEBUG: 20:39:27.254: NetworkManager: definition wlp2s0 is not for us (backend 1)
** (generate:1555): DEBUG: 20:39:27.254: NetworkManager: definition enp1s0f0 is not for us (backend 1)
DEBUG:netplan generated networkd configuration exists, restarting networkd
DEBUG:no netplan generated NM configuration exists
DEBUG:replug enp1s0f0: unbinding 0000:01:00.0 from /sys/bus/pci/drivers/tg3
DEBUG:replug enp1s0f0: rebinding 0000:01:00.0 to /sys/bus/pci/drivers/tg3
DEBUG:device wlp2s0 operstate is up, not replugging
DEBUG:netplan triggering .link rules for wlp2s0
DEBUG:device lo operstate is unknown, not replugging
DEBUG:netplan triggering .link rules for lo

My configuration for isc-dhcp-server is to have /etc/default/isc-dhcp-server contain:

INTERFACESv4="enp1s0f0"

...and /etc/dhcp/dhcpd.conf contain (amongst other things):

subnet 10.0.0.0 netmask 255.255.255.0 {
...
}

In theory, this should serve DHCP over enp1s0f0. However, since enp1s0f0 is never brought up, the DHCP server fails to start:

No subnet declaration for enp1s0f0 (no IPv4 addresses).
** Ignoring requests on enp1s0f0.  If this is not what
   you want, please write a subnet declaration
   in your dhcpd.conf file for the network segment
   to which interface enp1s0f0 is attached. **


Not configured to listen on any interfaces!

This wasn't an issue under ifupdown (I have no idea why enp1s0f0 doesn't just come up during boot, whether or not anything is at the other end of the cable; I thought that was the whole point of having a static IP). Is it possible to get it working in Netplan? Or is it possible to have the DHCP server start when enp1s0f0 is up?

0

3 Answers 3

12

It looks like you're hitting the bug that will be solved by https://github.com/CanonicalLtd/netplan/pull/34 - currently devices will only be configured if they have a carrier, but that requirement is going away.

In the mean time, you can probably fix this by configuring the device with systemd-networkd directly. Remove the enp1s0f0 stanza from the netplan config and add something like this (untested) systemd config in /etc/systemd/network/10-enp1s0f0.network:

[Match]
Name=enp1s0f0

[Link]
RequiredForOnline=no

[Network]
ConfigureWithoutCarrier=true
Address=10.0.0.1/24

The key bit is the ConfigureWithoutCarrier which I have pulled directly from the pull request.

(You can see what netplan generates and go from there - the file will be in /run/systemd/network.)

Alternatively, you can make use of the fact that netplan and ifupdown can coexist, apt install ifupdown and configure enp1s0f0 with ifupdown.

6
  • Good find! I searched these issues but just didn't have the right terms. I can't wait to see the back of ifupdown, so I'll try this workaround and subscribe to the bug. I'll let you know in a few hours.
    – detly
    Jun 19, 2018 at 23:10
  • 1
    FYI I copied Netplan's rendered config from /run/systemd/network/10-netplan-enp1s0f0.network and didn't add the RequiredForOnline=no; THEN I removed the enp1s0f0 stanza and reapplied the Netplan config.
    – detly
    Jun 20, 2018 at 10:34
  • 1
    @detly, it would be down if the cable is not plugged in, right? Oct 21, 2019 at 1:24
  • 1
    @AlexisWilke Yep, that's correct.
    – detly
    Oct 21, 2019 at 21:30
  • 1
    Re "that requirement is going away" - shouldn't it be gone by now? I seem to be hitting the same problem with a new server set up with Ubuntu 20.04 LTS.
    – Tilman
    May 3, 2021 at 17:12
1

It looks like Netplan has a smart system of figuring out when the iface has a link or not and assign addresses only when the link is up, automatically.

When that interface has no link (carrier signal), it remains unconfigured, however, if I turn on the other device in the other end of the cable, the interface automatically brings itself up with IP address and everything it needs.

For DHCP, a solution would be not to bind it to a specific interface...

0

Another possibility of running into this issue is the use of multiple nics with same priorities, like in my case: I have two USB nics directly integrated into my Ubuntu 20.04 virtual machine. At every startup one of them would work fine, but the other has no TX and RX packets displayed in ifconfig. The command ip a reveals NO-CARRIER and state DOWN, and the connected network cannot be accessed via this nic. I had to disconnect and reconnect it in the VM settings for months now until I came up with the solution. Just in case someone is facing the same issue:

The solution is to open the GUI 'Advanced Network Configuration' and ensure that for both nics "connect automatically with priority" is enabled but not with the same priority value, otherwise it would cause a conflict and one nic would always end up yelling NO CARRIER and no TX/RX packets after every boot. Setting one to '0' and the other to '1' avoids this conflict and after reboot both nics work just fine.

1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .