Score:0

Invalid YAML: inconsistent indentation: addresses: [192.168.1.120/24]

mx flag

In my host Ubuntu 22.04 Desktop, I'm creating 2 bridges for eth0-br0 and eth1-br1. br1 needs LAN access from the host machine 192.168.1.120/24 to the guest machine 192.168.1.1/24. I haven't been able to find any info on a static IP address for a bridge, so I tried this:

ubuntu@ubuntu:/etc/netplan$ cat 01-network-manager-all.yaml
# Let NetworkManager manage all devices on this system
network:
  version: 2
  renderer: NetworkManager
  ethernets:
    enp2s0:
      dhcp4: no
      addresses: [192.168.1.120/24]
      gateway4: 192.168.1.1
      nameservers:
        addresses: [8.8.8.8,8.8.8.4]
    enp3s0:
      dhcp4: no
  bridges:
    br0:
      dhcp4: yes
      interfaces:
        - enp3s0
    br1:
      dhcp4: no
        addresses: [192.168.1.120/24]
        gateway4: 192.168.1.1
        nameservers:
          addresses: [8.8.8.8,8.8.8.4]
      interfaces:
        - enp2s0

However running netplan shows error:

ubuntu@ubuntu:/etc/netplan$ sudo netplan try
/etc/netplan/01-network-manager-all.yaml:21:18: Invalid YAML: inconsistent indentation:
        addresses: [192.168.1.120/24]
                 ^
uz flag
Jos
I'm no YAML expert but could it be that you mix tab characters and spaces?
hr flag
Shouldn't' `addresses`, `gateway4` and `nameservers` be indented at the same level as `dhcp4`?
chili555 avatar
cn flag
Please see the example templates at /usr/share/doc/netplan/examples. I believe that the details and indentation in your file are not correct.
user1416486 avatar
mx flag
Comment1: I have only used Tabs for indentation. Comment2: My indentation is exactly as per https://www.freecodecamp.org/news/setting-a-static-ip-in-ubuntu-linux-ip-address-tutorial/ Comment3: I see no share directory in my Ubuntu 22.04 desktop?
chili555 avatar
cn flag
What does this tell you? `ls /usr/share/doc/netplan/examples` Tabs are not permitted.
user1416486 avatar
mx flag
Ok, examples loaded. I don't see a bridge static ip example. bridge_vlan example is there but I'm not sure if that would be for me?
Score:1
ky flag

This is a fixed yaml output. The main problem was your br1 indentation.

#Let NetworkManager manage all devices on this system
network:
  version: 2
  renderer: NetworkManager
  ethernets:
    enp2s0:
      dhcp4: no
      addresses: [192.168.1.120/24]
      gateway4: 192.168.1.1
      nameservers:
        addresses: [8.8.8.8,8.8.8.4]
    enp3s0:
      dhcp4: no
  bridges:
    br0:
      dhcp4: yes
      interfaces:
        - enp3s0
    br1:
      dhcp4: no
      addresses: [192.168.1.120/24]
      gateway4: 192.168.1.1
      nameservers:
          addresses: [8.8.8.8,8.8.8.4]
      interfaces:
        - enp2s0
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.