1

Can I enable DHCP4on all interfaces globally without knowing the interface names with netplan? I might add any USB connected ethernet NIC, and I just want any of them to get the network config via DHCP4. I know it works with NetworkManager. But I would rather use the networkd renderer.

4
  • 1
    Are you running a Ubuntu Desktop or Ubuntu Server? Is there a reason to choose netplan?
    – heynnema
    Sep 5, 2020 at 18:58
  • I am running a minimal installation of Ubuntu Desktop. No GUI for networking is needed. There's no specific reason to use netplan. However I don't want to run the NetworkManager service and use networkd instead.
    – user643011
    Sep 6, 2020 at 0:00
  • I'm not aware of any way to enable dhcp4 without knowing device names... unless you can find where the default of dhcp4=false is set, and then change it to =true.
    – heynnema
    Sep 6, 2020 at 0:06
  • 1
    you may want to have a look at my solution to this problem, askubuntu.com/questions/1069033/… Dec 25, 2020 at 9:45

1 Answer 1

3

It is possible to enable wifi on an interface without knowing the exact interface name by using the match syntax:

network:
  version: 2
  renderer: networkd
  ethernets:
    alleths:
      match:
        name: en*
      dhcp4: true

Be sure to avoid any settings that would collide between multiple interfaces (and do not use set-name).

2
  • Thank you very much! Is it possible to do an inverse match, so I can match all interfaces except lo?
    – user643011
    Sep 16, 2020 at 16:15
  • 1
    an inverse match is not supported, but since all ethernet devices will be named either en* or eth* by default, you can either duplicate the section with two different match rules, or generalize the match to name: e*, to ensure it covers all ethernet devices.
    – slangasek
    Sep 18, 2020 at 21:31

You must log in to answer this question.

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