Purpose of this configuration
Configuring multiple gateways on Ubuntu using Netplan provides essential network redundancy and failover capabilities, crucial for maintaining connectivity in diverse networking environments. This guide explores how to set up and manage primary and backup gateways within the same network using Netplan, ensuring reliable network access and seamless failover when encountering connectivity issues.
More about netplan
you can find at the link.
Steps to be Done to Add Backup Gateway
Configuration file is located under the folder: /etc/netplan
# List files in the folder
ls /etc/netplan
# Edit the file
sudo nano 00-installer-config.yaml
Content of the file:
network:
renderer: networkd
version: 2
ethernets:
eth0:
dhcp4: false
addresses: [192.168.19.189/24]
gateway4: 192.168.19.252
optional: true
nameservers:
addresses: [192.168.19.11, 8.8.8.8]
#routes:
- to: 0.0.0.0/0
via: 192.168.19.252 # Primary gateway IP
metric: 100 # Lower metric means higher priority
on-link: yes
- to: 0.0.0.0/0
via: 192.168.19.1 # Backup gateway IP
metric: 1000 # Higher metric means lower priority
on-link: yes
This configuration directs all traffic (0.0.0.0/0
) through the primary gateway 192.168.19.252
with a lower metric (higher priority).
Test and Apply configuration:
# Try the configuration before applying netplan try -timeout 120 # Apply network configuration netplan apply
Other topics related to the netplan
:
- Linux Networking: Add VLAN on Ubuntu with netplan
- Linux Networking: netplan DHCP Configuration on Ubuntu
- Linux Networking: netplan Network Configuration on Ubuntu