Notes on Ubuntu 22.04
Server
Published: 2022-04-28

Upon upgrading to Ubuntu 22.04, it seems that the way to specify gateway4 and gateway6 in netplan has been deprecated.

  • Error Messages
`gateway4` has been deprecated, use default routes instead.
See the 'Default routes' section of the documentation for more details.
`gateway6` has been deprecated, use default routes instead.
See the 'Default routes' section of the documentation for more details.
  • Before Fix
network:
    ethernets:
        ens3:
            addresses:
            - 192.168.0.2/24
            gateway4: 192.168.0.1
            nameservers:
                addresses:
                - 8.8.8.8
                - 8.8.4.4
                search: []
            optional: true
    version: 2
  • After Fix
network:
    ethernets:
        ens3:
            addresses:
            - 192.168.0.2/24
            routes:
              - to: default
                via: 192.168.0.1
            nameservers:
                addresses:
                - 8.8.8.8
                - 8.8.4.4
                search: []
            optional: true
    version: 2

The same method applies for IPv6.