2

I'm trying to install 2nd and 3rd NICs on a Ubunutu 22 VM running on VMWare. At first setup new VM with 1 NIC - that was successful and able to go out to internet:

network
    ethernets:
       ens160:
           addresses:
           - 192.168.50.231/24
           nameservers:
               addresses:
               - 192.168.50.1
               search:
               - domain.com
            routes:
            - to: default
              via: 192.168.50.254
      Version: 2

Next, added the VM with a 2nd interface in VMware, and configured Netplan accordingly:

network
    ethernets:
       ens160:
           addresses:
           - 192.168.50.231/24
           nameservers:
               addresses:
               - 192.168.50.1
               search:
               - domain.com
            routes:
            - to: default
              via: 192.168.50.254
       ens192:
          addresses:
          - 192.168.252.231/24
          nameservers:
              addresses:
              - 192.168.252.1
              search:
              - domain.com
           routes:
           - to: default
             via: 192.168.252.254    
     Version: 2

Running 'netplan apply' returns this:

'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: default), first declared in ens192 but also in ens160'

I understand I should use 1 default gateway, but can't seem to find the proper way to write this file.

HBruijn
  • 84,206
  • 24
  • 145
  • 224

1 Answers1

1

Here's an example of how you can modify your Netplan configuration to have a single default route:

network:
  version: 2
  ethernets:
    ens160:
      addresses:
        - 192.168.50.231/24
      nameservers:
        addresses:
          - 192.168.50.1
      search:
        - domain.com
      routes:
        - to: default
          via: 192.168.50.254
ens192:
  addresses:
    - 192.168.252.231/24
  nameservers:
    addresses:
      - 192.168.252.1
  search:
    - domain.com

In this example, the default route is specified only for ens160, as having multiple default routes can lead to conflicts

Turdie
  • 2,945