Score:1

Ubuntu 20.04 - Static and default routes via netplan

ca flag

I am brand new to Linux. I only started 'playing' yesterday, so please forgive my lack of knowledge. I have built a linux server with 2 network cards. Outside interface (ens192) for all Internet traffic and an INSIDE interface (ens160) for all internal traffic. All interfaces are STATIC. I would like a single default route to be on the OUTSIDE (ens192) I would like to route all other networks INSIDE (ens160)

Please see below what I have attempted to build so far.

network:
version: 2
renderer: networkd
ethernets:
  ens160:
      dhcp4: no
      dhcp6: no
      addresses: [172.24.0.50/23]
      gateway4: 172.24.0.5
      routes:
      - to: 10.0.0.0/8
        via: 172.24.0.5
      - to: 172.23.0.0/19
        via: 172.24.0.5
      - to: 172.17.10.0/24
        via: 172.24.0.5

I am currently receiving this error - /etc/netplan/50-cloud-init.yaml:15:1: Invalid YAML: tabs are not allowed for indent: - to: 172.17.10.0/24

I have received this error with a previous configuration.

** (generate:5240): WARNING **: 10:16:53.463: 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 am at a complete loss on what to do here.

Please help.

dummyuser avatar
uy flag
Welcome, please edit your post and add the current configuration of ens192.
PonJar avatar
in flag
Do you have a tab between : and 172 by any chance? The error suggests there is a tab where there shouldn’t be one. Try using spaces to indent by 2.
Score:0
cn flag

There is most likely an error in your yaml-code, probably a tab instead of a space at the last route.

If you edit the file in vim you can use the :set list -command to see what characters that hides there. To get back use the :set nolist -command.

Wannabe_Golfer avatar
ca flag
Thank you. Thats great. I will give that a go. Do you know how I can remove the 2 default routes?
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.