[Bug 2098356] Re: command line netplan set network.ethernets.ens33.routes fails with python errors

Lukas Märdian 2098356 at bugs.launchpad.net
Mon Feb 24 12:01:25 UTC 2025


Yes, you should be able to use environment variables. This seems to work
in bash for me (stopping the single-quotes before the ENV var & re-
starting it right after):

$ ITF=ens33
$ GWY=192.168.17.253
$ netplan set network.ethernets.$ITF.routes='[{"to": "default", "via": "'$GWY'", "metric": 200}]'

Using the commands above I'm also able to reproduce the issue of having
multiple same default routes with different gateways. Trigger:

$ GWY=192.168.17.252
$ netplan set network.ethernets.$ITF.routes='[{"to": "default", "via": "'$GWY'", "metric": 200}]'
** (process:841): WARNING **: 11:51:04.829: Problem encountered while validating default route consistency.Please set up multiple routing tables and use `routing-policy` instead.
Error: Conflicting default route declarations for IPv4 (table: main, metric: 200), first declared in ens33 but also in ens33
$ cat /etc/netplan/70-netplan-set.yaml 
network:
  version: 2
  ethernets:
    ens33:
      routes:
      - metric: 200
        to: "default"
        via: "192.168.17.253"
      - metric: 200
        to: "default"
        via: "192.168.17.252"


Having multipe default routes (of same priority) pointing to different gateways is obviously wrong and there's already an error message displayed. It probably should not be written to disk either, which we can track as a (low-priority) bug.

** Also affects: netplan.io (Ubuntu)
   Importance: Undecided
       Status: New

** Changed in: netplan.io (Ubuntu)
       Status: New => Triaged

** Changed in: netplan.io (Ubuntu)
   Importance: Undecided => Low

-- 
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to netplan.io in Ubuntu.
Matching subscriptions: foundations-bugs
https://bugs.launchpad.net/bugs/2098356

Title:
  command line netplan set network.ethernets.ens33.routes fails with
  python errors

Status in Netplan:
  New
Status in netplan.io package in Ubuntu:
  Triaged

Bug description:
  I'm trying to setup default route fora a statice ip connection witch
  command line

  #netplan set network.ethernets.ens33.routes.{to:default,
  via:192.168.17.254, metric:200}

  command fails with:

  Traceback (most recent call last):
    File "/usr/sbin/netplan", line 23, in <module>
      netplan.main()
    File "/usr/share/netplan/netplan_cli/cli/core.py", line 58, in main
      self.run_command()
    File "/usr/share/netplan/netplan_cli/cli/utils.py", line 332, in run_command
      self.func()
    File "/usr/share/netplan/netplan_cli/cli/commands/set.py", line 50, in run
      self.run_command()
    File "/usr/share/netplan/netplan_cli/cli/utils.py", line 332, in run_command
      self.func()
    File "/usr/share/netplan/netplan_cli/cli/commands/set.py", line 61, in command_set
      raise Exception('Invalid value specified')
  Exception: Invalid value specified

  
  same result with --debug switch.

  
  Ubuntu Server 24.04.1 full patch.
  # netplan get
  network:
    version: 2
    ethernets:
      ens33:
        addresses:
        - "192.168.17.35/24"
        nameservers:
          addresses:
          - 192.168.17.16
          search:
          - lab.local
        dhcp4: false

  
  Regards
  Riccardo

To manage notifications about this bug go to:
https://bugs.launchpad.net/netplan/+bug/2098356/+subscriptions




More information about the foundations-bugs mailing list