2

I have recently installed Kubuntu 18.04 which uses netplan instead of the old networking subsystems. In the past I have set up a few extra loopback addresses for a variety of reasons using /etc/network/interfaces, however that doesn't work in 18.04 anymore. For my work development environment, I also need 172.16.123.1 added to a loopback interface.

What I noticed is that the current netplan configuration file just diverts all network management to NetworkManager, however from what I can tell NetworkManager has no ability to manage loopback devices or add loopback addresses.

So what is the correct way with netplan to configure some additional loopback addresses but still primarily use NetworkManager for interface configuration?

Update 2021-12-10 In newer versions of netplan, the format of the file in this answer has changed from the accepted answer, as has the default file location in later revisions of Ubuntu 20.04 as well as newer Ubuntu releases.

The file is now /etc/netplan/01-netcfg.yml and the format needs to look like

network:
version: 2
renderer: networkd
ethernets:
  lo:
    match:
      name: lo
    addresses: [ 172.16.123.1/32 ]

Netplan seems to be extremely fussy about the layout and format of this file, and I've taken down a few VMs trying to set them up the old way.

4
  • I am allowed to set the addresses, but how do I actually configure them? Netplan is configured with NetworkManager as the renderer. How do I tell it to add another address to the loopback adapter in addition to that?
    – cardonator
    May 8, 2018 at 6:43
  • Oh I misread your comment. I actually need 172.16.123.1 to loopback for my work development environment.
    – cardonator
    May 8, 2018 at 13:03
  • You should look at man systemd.network. Not sure about that but you may be able to set up interface by using systemd-networkd. I failed in a quick test but Id on't know your setup requirement
    – solsTiCe
    May 8, 2018 at 20:52
  • 1
    One way I've been setting up the loopback address, that still works is: sudo ifconfig lo:1 172.16.123.1 netmask 255.255.255.0 up and I basically need this equivalent functionality at system boot.
    – cardonator
    May 8, 2018 at 22:07

3 Answers 3

4

I'm not sure this is the "correct way" but it indeed works like you want it to.

You can set which renderer to be used for the loopback interface like below, edit the file /etc/netplan/01-network-manager-all.yaml (or your *.yaml file):

# Let NetworkManager manage all devices on this system
network:
  version: 2
  renderer: NetworkManager
  ethernets:
    lo:
      renderer: networkd
      match:
        name: lo
      addresses:
        - 172.16.123.1/32

Tested and works as expected on Ubuntu 18.04 Desktop.

Hope this helps.

3
  • I don't care if it's the "proper" way. Before I was editing the interfaces file :) This works magnificently, thanks!!
    – cardonator
    May 9, 2018 at 16:24
  • It's the right way ;) May 10, 2018 at 20:40
  • Nice to hear that it works :) And to have confirmed it is the right way ;)
    – user822833
    May 11, 2018 at 13:26
1

You can either add an IP address with

lo:
   addresses: [192.168.1.1/24]

or

lo:
    addresses:
    - 192.168.1.1/24

To view all the IP's assigned to the loopback use the command ip address

0

I found after the latest update to ubuntu 18.4.1 i had to use the syntax:

lo:
  addresses: [IPADDRESS]

The YAML file is very fussy about spaces and indents. Note the square brackets are required.

1
  • Can you explain what you had to change? I am currently using the format in the accepted answer and it is working...
    – cardonator
    Aug 8, 2018 at 15:55

You must log in to answer this question.

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