Score:1

How to configure netplan so enp9s0 goes to internet and enp5s0 goes to lan?

in flag

I must build a replacement server using Ubuntu 20.04.5 LTS, and I'm trying to migrate from NetworkManager to netplan. My new server can connect to the internet, but complains that it has no route to my 192.168.0.0 lan network. All pings to lan hosts result in Destination Host Unreachable

I have an old Centos7 server that uses NetworkManager that works the way I want. On that older host, galactica, nic enp6s0 has ipv4 192.168.1.5, and is connected to the internet, and nic enp3s0 has ipv4 192.168.0.5, and is connected to my lan. On this the old server galactica, ip addr shows this:

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: enp3s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 60:a4:4c:59:1e:17 brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.5/24 brd 192.168.0.255 scope global noprefixroute enp3s0
       valid_lft forever preferred_lft forever
    inet6 fe80::62a4:4cff:fe59:1e17/64 scope link
       valid_lft forever preferred_lft forever
3: enp6s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 68:05:ca:40:ac:5a brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.5/24 brd 192.168.1.255 scope global noprefixroute enp6s0
       valid_lft forever preferred_lft forever
    inet6 2600:1700:8fd4:80:6a05:caff:fe40:ac5a/64 scope global mngtmpaddr dynamic
       valid_lft 3226sec preferred_lft 3226sec
    inet6 fe80::6a05:caff:fe40:ac5a/64 scope link
       valid_lft forever preferred_lft forever
4: wlp2s0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default qlen 1000
    link/ether 5e:bc:ba:f9:24:a9 brd ff:ff:ff:ff:ff:ff

and ip route shows this:

default via 192.168.1.254 dev enp6s0 proto static
default via 192.168.0.5 dev enp3s0 proto static metric 100
192.168.0.0/24 dev enp3s0 proto kernel scope link src 192.168.0.5 metric 100
192.168.1.0/24 dev enp6s0 proto kernel scope link src 192.168.1.5
192.168.1.0/24 via 192.168.1.254 dev enp6s0 proto static

I note that it shows two default routes.

On the new server, executor, nic enp9s0 has ipv4 192.168.1.8, and is connected to the internet, and nic enp5s0 has ipv4 192.168.0.5, but has no route to anywhere. I want it to connect to my lan. I have two files in /etc/netplan, 01_wan_00.yaml and 02_lan_00.yaml:

network:
  version: 2
  renderer: networkd
  ethernets:
    enp9s0:
    addresses:
        - 192.168.1.8/24
    gateway4: 192.168.1.254
    nameservers:
        addresses: [68.94.156.1, 68.94.157.1, 1.1.1.1]
network:
  version: 2
  renderer: networkd
  ethernets:
    enp5s0:
    addresses:
        - 192.168.0.8/24
    nameservers:
        addresses: [68.94.157.1, 1.1.1.1]
    routes:
        - to: 192.168.0.0/24
        via: 192.168.0.8

On this new host, ip addr shows this:

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
   link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
   inet 127.0.0.1/8 scope host lo
      valid_lft forever preferred_lft forever
   inet6 ::1/128 scope host  
      valid_lft forever preferred_lft forever
2: enp9s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
   link/ether 88:c9:b3:b0:66:21 brd ff:ff:ff:ff:ff:ff
   inet 192.168.1.8/24 brd 192.168.1.255 scope global enp9s0
      valid_lft forever preferred_lft forever
   inet6 fe80::8ac9:b3ff:feb0:6621/64 scope link  
      valid_lft forever preferred_lft forever
3: enp5s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
   link/ether 00:0a:cd:24:bd:08 brd ff:ff:ff:ff:ff:ff
   inet 192.168.0.8/24 brd 192.168.0.255 scope global enp5s0
      valid_lft forever preferred_lft forever
   inet6 2600:1700:8fd4:80:20a:cdff:fe24:bd08/64 scope global dynamic mngtmpaddr noprefixroute  
      valid_lft 3585sec preferred_lft 3585sec
   inet6 fe80::20a:cdff:fe24:bd08/64 scope link  
      valid_lft forever preferred_lft forever

I see that enp5s0 does not have the word noprefixroute. The command ip route shows this:

default via 192.168.1.254 dev enp9s0 proto static  
192.168.0.0/24 dev enp5s0 proto kernel scope link src 192.168.0.8  
192.168.0.0/24 via 192.168.0.8 dev enp5s0 proto static  
192.168.1.0/24 dev enp9s0 proto kernel scope link src 192.168.1.8

I note there is only one default route, but when I included a route section in 01_wan.yaml, netplan apply complained that I should only have one default route, and my route did not work anyway.

So what is the correct way to configure executor?

in flag
Sorry, I've edited to show Ubuntu 20.04.5 LTS
in flag
I removed the deprecated 'gateway4' line from 01_wan_00, and replaced it with a routes: `default 192.168.1.254` line. Still no connection. Tomorrow I will explore if this might be an issue with ipv6.
Score:0
us flag
    routes:
    - to: 192.168.0.0/24
      via: 192.168.0.8

This is incorrect. You are telling your system that 192.168.0.8 is a router, and that traffic to the 192.168.0.0/24 network should be sent to this router. But 192.168.0.8 is not a router, it is your host. The "route" to this network is to send the traffic out your network interface.

Remove this route and things should look better.

in flag
Actually, executor (192.168.0.8) IS a router. That's its main job.
us flag
Your config is still wrong.
Score:0
in flag

Double check the device names/cable connections of your nics.

In this case, the device names were reversed, so enp5s0 was physically connected to the internet and SHOULD have had ipv4 192.168.1.8, and vice-versa for enp90s.

It is worse than odd that traffic from the lan made it to the internet and back, and the results from the ip command are still not completely consistent with the NetworkManager on the older host. So we know we have a firewall issue, but it seems that we have resolved the base connectivity issues.

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.