0

I am using netplan to configure the interfaces on Ubuntu 18.04, but there are a few issues. First, the metric does not seem to be working as it is set to 0. Second, once I use networkd the whole network seems to be down!

The set up is like:

                                  Internet                     Internet 
     (local-link)                    /                         /           
 Dev1               |-----|        |-----|      |-----|                   - Dev11 (192.168.0.5)
    ----------------| eno |        | tun |      | usb | ---- (AP) -------|
 Dev2               |_____|        |_____|      |_____|     192.168.0.1   - Dev12 (192.168.0.6)
 (172.168.0.6)      172.168.0.2               192.168.0.2 
                 
                |------------------PC ------------------|

The YAML file is:

network:
  version: 2
  renderer: networkd
  ethernets:
    enp60s1:
      match:
        macaddress: 3b:2d:x:x:x
      addresses: [192.168.0.2/24]
      dhcp4: no
      optional: true
      gateway4: 192.168.0.1
      set-name: usb
      nameservers:
        addresses: [192.168.0.1,8.8.8.8]
      mtu: 8192  
      routes:
       - to: 0.0.0.0/0
         via: 192.168.0.1
         metric: 50
         table: 101
      routing-policy:
       - from: 192.168.0.0/24
         table: 101

I was hoping to use NetworkManager but it does seem that non-default routes are not supported. I then run

sudo netplan generate
sudo netplan apply
sudo service systemd-networkd restart

but route -n gives:

Destination   Gateway      Genmask         Flags     Metric  Ref   Use   Iface  
0.0.0.0      192.168.0.1   0.0.0.0          UG        0       0    0      usb
0.0.0.0      10.100.80.1   0.0.0.0          UG       20000    0    0      wlan
10.8.0.0     0.0.0.0       255.255.255.0    U         0       0    0      tun
10.100.80.0  0.0.0.0       255.255.248.0    U         600     0    0      wlan  
172.168.0.0  0.0.0.0       255.255.255.0    U         0       0    0      eno
192.168.0.0  0.0.0.0       255.255.255.0    U         0       0    0      usb

and then the host (PC) becomes unreachable (remotely connected via ssh).

Why the metric is not set, since it is defined in YAML file? I want the Devs connected to the AP to have access to internet via the AP, hence I try ping -w 1 8.8.8.8 -I usb which results to 100% packet loss.

  • Looks like you're trying to set a static IP address to enp60s1. In the usual case you don't need to set all these fields. Have you tried the usual minimal configuration? netplan.io/examples – Stephen Boston Jun 15 at 17:59
  • @StephenBoston I tried to have it as minimal as possible. First, with networkd the metric is not shown, as it does when NetworkManager is applied (up to mtu line). Also, I have two interfaces with two gateways, where packets from subnet 192.168 should reach the internet through the 192.168.0.1, and all others through a different interface. Now, it seems that 192.168.0.1 forwards packets to tun interface (lower metric), which is not desirable. – lainos88 Jun 16 at 12:59
1

You are setting both:

  gateway4: 192.168.0.1

and:

  routes:
   - to: 0.0.0.0/0
     via: 192.168.0.1
     metric: 50
     table: 101

gateway4 is shorthand for a default route. You should not combine the two. This is almost certainly why your metric is being clobbered, because the gateway4 setting is overriding. A metric of 0 is not actually a problem since a metric of 0 has an even higher priority than one of 50, but all of your routing table settings would also be clobbered which is likely more the issue.

| improve this answer | |
  • Ok, the gateway4 has been removed. But still the usb interface has no internet access. The traffic from the Dev11, Dev12 should be forwarded to internet only through the AP. Shouldn't the routing-policy: be responsible for this (or should I update the route rules)? – lainos88 Jun 16 at 9:38
  • I have managed somehow to replicate it locally. I have connected two routers on diff interf (i.e. eno1 and usb1), both connected to internet. I tried with renderer: NetworkManager up to the mtu line, and from route -n and ip r I could see that there were two default gateways with 100 and 101 metric. ping Google worked through the interfaces, but when I traceroute it seems that the traffic from the usb1 goes though the gateway in eno1 and reaches the final dest. traceroute on eno1 goes up to 1 hop and then no information. With networkd the metric isnt shown. – lainos88 Jun 16 at 12:05
  • 101 as a metric? The yaml in your question doesn't show a metric of 101 anywhere, only a routing table id of 101. Please make sure you're showing the full config that corresponds to the output you're describing. – slangasek Jun 17 at 16:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.