sudo netplan generate
sudo netplan try
sudo netplan apply
sudo netplan --debug apply
Over SSH on a remote machine, change network configuration with
netplan try: if the new config breaks the connection, after 120 seconds
without confirmation netplan restores the previous file and access comes
back. netplan apply gives you no such safety net — a mistake in an
address or gateway can cut off the only channel to the machine.
Several files under /etc/netplan
All the files are applied together, in name order (01-..., 50-...); a
later file can override an earlier one's settings for the same interface.
Keep one interface in one file, so you don't have to hunt for a conflict
across several.
A permanent route to a network behind a neighbour
A route added with ip route add lasts until a reboot. A permanent one goes into
routes: of the interface the neighbour is reachable through: to is the destination
network, via is the neighbour's address on the shared network. The default route
(to: default) stays as it was; the new entry sits next to it:
network:
version: 2
ethernets:
eth0:
addresses: [192.168.50.10/24]
routes:
- to: default
via: 192.168.50.1
- to: 10.99.0.0/24
via: 192.168.50.20
sudo netplan try
ip route get 10.99.0.1
ip route show 10.99.0.0/24
ip route get shows which way the kernel will send a packet to an address: if the
answer has the neighbour as via, the route works. The via address must be on the
interface's own network, or the route will not be installed. More on the routing table
in ip.