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.
1 Answer
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.