Add a persistent static route on Ubuntu 22.04 "Jammy"

Hello,

I want to configure a persistent static route on a Ubuntu host (Jammy)

I found this article

On my system, the file:
/etc/network/interfaces

doesn’t exist.

The article is dated 2012, and I wanted to check whether it still applies to Jammy.

Or whether the fact that I don’t have an /etc/network/interfaces file means that my networking is being configured in some other way?

Thanks

VW

I thin you need to edit files in the /etc/netplan/ directory. No /etc/network/interfaces any more. There is also a netplan command line tool to drive some operations. Check Canonical Netplan and Netplan/Design - Ubuntu Wiki I will try to update the page. If you still need help reply back.

Example - /etc/netplan/01-eth0.yaml

# This file describes the network interfaces available on your system
# For more information, see netplan(5).
network:
  version: 2
  renderer: networkd
  ethernets:
    eth0:
      dhcp4: no
      dhcp6: no
      addresses:
        - 192.168.2.25/24                         # Your IPv4 address.
        - 192.168.2.26/24                          # Another IPv4 address.
        - "2001:xxx:xxx:xxx::2/64"              # IPv6 SLAAC address.
      gateway4: 192.168.2.254                      # Primary IPv4 gateway.
      gateway6: "fe80::1"                         # Primary IPv6 gateway.
      nameservers:
        search: [203-0-113-0.ip.linodeusercontent.com] # Search domain.
        addresses: [192.168.2.236,192.168.2.237]    # DNS Server IP addresses.

Here is another example for multiple gateways

network:
  version: 2
  renderer: networkd
  ethernets:
    enp3s0:
      addresses:
        - 10.0.0.10/24
        - 11.0.0.11/24
        routes:
        - to: default
          via: 10.0.0.1
          metric: 200
        - to: default
          via: 11.0.0.1
          metric: 300
1 Like