4

I have an interface I want to bring up at boot but otherwise leave unconfigured. No DHCP, no static IP. Is there a way to do this with Netplan in 18.04?

I tried the following (where enp10s0f1 is the device in question) but it still just leaves the interface down:

# This file describes the network interfaces available on your system
# For more information, see netplan(5).
network:
  version: 2
  renderer: networkd
  ethernets:
    enp10s0f0:
      dhcp4: yes
    enp10s0f1:
      dhcp4: no

The reason this matters is I have LXD containers using that interface via macvlan bridging, so the interface needs to be up, but it doesn't need (and I'd rather not have) an IP address on the host. I'd really prefer not to need to remember ip link set up enp10s0f1 when I reboot.

Update:

I found this bug report in Netplan's Launchpad that looks related, but as best as I can tell, it's for the opposite case: tell Netplan to configure an interface but don't automatically bring it up. However, it does sort of suggest that what I want to do isn't possible yet either. Is that the case? Is there any workaround besides abandoning Netplan?

1

Edit, mid-2019: The bug that caused this has been fixed.

With this bug fix, it is now possible to have an interface brought up without an address by adding it with an empty configuration: {}.

Using the example from the question, doing this with enp10s0f1 would look like this:

# This file describes the network interfaces available on your system
# For more information, see netplan(5).
network:
  version: 2
  renderer: networkd
  ethernets:
    enp10s0f0:
      dhcp4: yes
    enp10s0f1: {}

Original answer:

This is in fact a bug in Netplan: bug #1728134, bug #1763608. One of the netplan devs has acknowledged the latter, but it's not clear whether or not a fix will be provided.

One workaround would be to manually create a systemd unit to bring the interface up. Create a file /etc/systemd/system/manual-iface.service with the following contents:

[Unit]
Description=Service to bring up/down unconfigured nic enp10s0f1
After=network.target

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/sbin/ip link set enp10s0f1 up
ExecStop=/sbin/ip link set enp10s0f1 down

[Install]
WantedBy=multi-user.target

Then, enable it to run at boot:

sudo systemctl enable manual-iface.service

And you're good to go. You should see enp10s0f1 comes up automatically next time you boot.

Alternatively, if you don't want to do that, reverting to ifupdown is still an option, as the question states. Fallback is described here. To summarize, install ifupdown, and then you can do the configuration using the traditional /etc/network/interfaces (which is well-documented across the web).

|improve this answer|||||
0

As a workaround, if only IPv4 address is required, IPv6 can be configured via DHCP which automatically enables the interface:

# cat /etc/netplan/10-eth1.yaml
network:
  version: 2
  renderer: networkd
  ethernets:
    eth1:
      dhcp4: false
      dhcp6: true
      optional: true
|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.