I have not found examples of how to configure Netplan in Ubuntu Bionic 18.04 with global blackhole/unreachable routes. So I'll put it here in case someone else runs into the same problem, has an example.

network:
  version: 2
  renderer: networkd
  ethernets:
    lo:
      match:
        name: lo
      addresses: [ 127.0.0.2/32 ]
      routes:
        - to: 10.0.0.0/8
          via: 0.0.0.0
          metric: 240
          type: unreachable
        - to: 192.168.0.0/16
          via: 0.0.0.0
          metric: 240
          type: unreachable
        - to: 172.16.0.0/12
          via: 0.0.0.0
          metric: 240
          type: unreachable
        - to: 169.254.0.0/16
          via: 0.0.0.0
          metric: 240
          type: blackhole
  • Tip: without "address 127.0.0.2" or without "via 0.0.0.0" netplan silently ignores the configuration.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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