1

I have begun experimenting with Ubuntu Server 18.04 and I ran into a problem with configuring the network. I have a PC with two network ports and one of those two ports has to get an IPv4 link-local address. In the desktop version I can achieve this by going into NetworkManager and then choose the link-local option. But with Server I have to use that new netplan program. However, the manual and other online resources make it not at all clear to me on how to achieve this. There's stuff to be found on setting up DHCP and static address but nothing on using Avahi (which Desktop uses) or other means of obtaining a 169.254.x.y address.

So: how can I write a yaml configuration that instructs netplan to set up link-local addressing on an interface?

Nathilion
  • 153

2 Answers2

5

You would use the netplan common property for the interface:

link-local: [ ipv4 ]

However, this property doesn't exist in your version of netplan.io (0.36), it's been added to netplan.io 0.39. I get this error on ubuntu 18.04 currently:

unknown key link-local

Documentation here: https://git.launchpad.net/netplan/tree/doc/netplan.md

You would need to obtain a more recent build of netplan.io to use this.

Mercury00
  • 164
0

Setting up a link-local address on the latest Ubuntu Server, since 18.04, using Netplan.

  1. Create a Netplan file: It's located in /etc/netplan/. It’s a good idea to create a file with a .yaml extension, like 01-netcfg.yaml.

  2. Add new configuration: Now, let’s set up your network interface. Here’s a friendly example to get you started:

    network:
      renderer: networkd
      version: 2
      ethernets:
        enp0s3:
          dhcp4: true
          dhcp6: false
          link-local: [ ipv4, ipv6 ]
    
    • version: 2 just tells Netplan which version you’re using.
    • ethernets is where you define your Ethernet interfaces.
    • Make sure to swap enp0s3 with the actual name of your network interface.
      • You can find the name of NIC using ip -br a s
    • Setting dhcp4: true means you want to use DHCP for this interface and conversely, setting dhcp6: false means disabling DHCP for IPv6.
    • Finally, the link-local: [ ipv4, ipv6 ] line enables IPv4 link-local addressing, and removing one of them disables the link-local addressing for it.
  3. Applying our changes: Once we’ve saved our configuration, just run this command to make everything take effect:

    sudo netplan apply
    

And that’s it! Your network interface should now be using a link-local IPv4 address (usually starting with 169.254.x.y). Enjoy your networking!