1

I'm trying to add a route on an Ubuntu 18.04 machine, but I'm missing something. Traffic to 89.19.153.0/24 needs to go through 10.32.57.142.

This is the config I'm trying in /etc/netplan/99-netcfg-vmware.yaml

enter image description here

After this I run: netplan apply

Nothing happens.

When I check the routes with route -n I get this:

enter image description here

When I run "sudo netplan --debug generate" I get:

imgae of command result

I realize I'm doing something wrong, but since I'm new to netplan I haven't been able to google up the result.

Thank you for reading.

lizlin
  • 43
  • 1
  • 2
  • 7

2 Answers2

3

I also make it a habit to configure the metric. I am not sure if it is necessary!

Remove the gateway4 option and configure them using routes manually if you want to use multiple gateways. (Not needed in this case)

At last. The IP address 10.32.57.142 is not in your subnet. So we need to provide an additional route to it.

Your configuration would become something like:

network:
    version: 2
    renderer: networkd
    ethernets:
        ens192:
            dhcp4: no
            dhcp6: no
            addresses :
                - 10.32.57.8/28
            gateway4: 10.32.57.1
            routes
                - 10.32.57.142/32
                  via 10.32.57.142
                  scope: link
                - to: 84.19.153.0/24
                  via: 10.32.57.142
                  metric: 100
            nameservers:
                addresses:
                    - 8.8.8.8
eKKiM
  • 1,540
  • 9
  • 23
  • _Why_ do you remove the `gateway4` option and configure the route separately? – Michael Hampton Sep 19 '19 at 18:41
  • 1
    Removing the `gateway4` option is indeed not needed. I was thinking about a configuration with multiple gateways. I editted my post because of this. – eKKiM Sep 19 '19 at 19:23
  • I tried this but am still experiencing some issues. Firstly, I had to add : after routes and via + add "to:" before the address, otherwise I was met with a wall of "inconsistent indentations + mapping values not allowed. After this I can run netplan generate/apply, but nothing happens. route -n shows the same thing as above. – lizlin Sep 20 '19 at 06:35
0

I found the answer.

It was the route itself that didn't work between networks - and since it didn't work, netplan never added it.

If I changed it to addresses within range, this config added them and I could see them in route -n.

The issue was that I didn't get any error message that informed me that they wouldn't be added, something in the back checks the added routes and decides if they should be added or not, but without providing any clue to that they're doing it or why. I had no idea about this.

Big thanks to you, @eKKiM - you set me on the right track.

lizlin
  • 43
  • 1
  • 2
  • 7