Score:0

netplan default routes confusion

cl flag

I am new to Netplan... I thought I had everything working ok and on the surface it seems to be, however I am setting up microk8s and getting some weird results on the load balancer and someone somewhere mentioned routing issues, so I looked at my default route and I don't understand. My netplan is:

network:
  version: 2
  renderer: networkd
  ethernets:
    eth0: #Edit this line according to your network interface name.
      dhcp4: false
      addresses:
        - 10.0.0.203/24
      routes:
        - to: default
          via: 10.0.0.1
      nameservers:
        search: [phoenix.local]
        addresses: [10.0.0.253]

I am not using dhcp one interface it is static I am using a local dns server for connecting to other nodes on my local net.

But when I do an ip route I see

default via 10.0.0.1 dev eth0 proto static 
default via 10.0.0.1 dev eth0 proto dhcp src 10.0.0.151 metric 100 

what is the second default route? is that possibly causing me problems and if so how do I get rid of it? Sorry, I am kind of old school and haven't worked with linux for a while so trying to catch up with netplan. thanks

as requested:

/run/systemd/networks/10-netplan-eth0.network contains

[Match]
Name=eth0

[Link]
RequiredForOnline=no

[Network]
DHCP=ipv4
LinkLocalAddressing=ipv6
Address=10.0.0.202/24
DNS=10.0.0.253
Domains=phoenix.local

[Route]
Destination=0.0.0.0/0
Gateway=10.0.0.1

[DHCP]
RouteMetric=100
UseMTU=true

Bill

Marco avatar
br flag
netplan generates the files for your "renderer" in `/run` check in `/run/systemd/networkd` what was generated. Best update your question with the information found. See https://netplan.io/
Score:2
cl flag

I feel a little silly, but slightly miffed as well ;-). My /etc/netplan folder had a file in it called 50-cloud-init.yaml containing:

# This file is generated from information provided by the datasource.  Changes
# to it will not persist across an instance reboot.  To disable cloud-init's
# network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}
network:
    ethernets:
        eth0:
            dhcp4: true
            optional: true
    version: 2

So I did what it said and created the 99-disable-network-config.cfg. I thought that was all there was to it. Seeing as it said it was automatically generated and would persist through reboots and as I had configured to disable cloud-init, I thought it wouldn't matter if I left it there. Apparently this is not the case. This morning on a whim, I moved the file out of that directory and now ip route reports what I would expect:

root@uk8s02:/etc/netplan# ip route
default via 10.0.0.1 dev eth0 proto static 
10.0.0.0/24 dev eth0 proto kernel scope link src 10.0.0.202 
blackhole 10.1.125.128/26 proto 80 

It would seem to me that perhaps text in 50-cloud-init.yaml might also mention to remove the file if disabling cloud-init? Or so it would seem to me. (or maybe my disable file isn't completely working? but then again I moved the 50-could-init.yaml out and it didn't get regenerated.)

/etc/run/network/10-netplan-eth0.network now contains

root@uk8s02:/run/systemd/network# cat 10-netplan-eth0.network 
[Match]
Name=eth0

[Network]
LinkLocalAddressing=ipv6
Address=10.0.0.202/24
DNS=10.0.0.253
Domains=phoenix.local

[Route]
Destination=0.0.0.0/0
Gateway=10.0.0.1

which also looks correct.

Thank you for pointing me to that folder Marco!

Bill

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.