> For the complete documentation index, see [llms.txt](https://prime-stake-pool.gitbook.io/node-setup-guide/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://prime-stake-pool.gitbook.io/node-setup-guide/server-settings/dual-nic-wan-failover-setup/netplan-configuration.md).

# Netplan Configuration

Netplan can be used to configure failover for a WAN connection using two network interface cards (NICs) on a system. By defining two NICs in your Netplan configuration and using routing policies, you can create a primary connection and a backup connection. When the primary connection fails, traffic can be automatically switched to the backup NIC.

**Here's a breakdown of how to set up a failover network with Netplan:**

1. **Identify Your NICs:**                                                                                                                                                  Determine the names of your network interface cards (e.g., `eth0`, `eth1`, `wlan0`). You can use `ip addr` or `nmcli` to list active interfaces.&#x20;
2. **Configure Netplan (YAML):**&#x20;
   * Create a Netplan configuration file (usually in `/etc/netplan/`).&#x20;
   * Define two ethernet interfaces in the `netplan` file, one for the primary WAN connection and one for the backup WAN connection.
   * Set up static IP addresses or utilize DHCP as needed for each interface.&#x20;
   * Use the `routing-policy` section to define the order in which routes are applied. This will determine which NIC is used for traffic when both are available.&#x20;
   * Set the primary NIC as the primary route with a higher priority, and the backup NIC as a lower priority route.&#x20;
3. **Apply Netplan Changes:**                                                                                                                                            Run `netplan apply` in your terminal to apply the new configuration and restart the network services.&#x20;
4. **Test Failover:**                                                                                                                                                         Simulate a failure of the primary NIC (e.g., unplug the cable or manually disable the interface) to verify that traffic automatically switches to the backup connection.

&#x20;      **Example Netplan YAML Configuration (Simplified):**

```
network:
  version: 2
  renderer: networkd
  ethernets:
    enp0s3:
      dhcp4: yes
      routes:
        - to: default
          via: 192.168.1.1  # Replace with your gateway
          metric: 100
    enp0s8:
      dhcp4: yes
      routes:
        - to: default
          via: 192.168.2.1  # Replace with your gateway
          metric: 200
```

Explanation:

* `network:`: Top-level Netplan configuration.
* `version: 2`: Specifies the Netplan version.
* `renderer: networkd`: Uses `systemd-networkd` as the backend.
* `ethernets:`: Defines configurations for Ethernet interfaces.
* `enp0s3:` and `enp0s8:`: Replace with your actual interface names.
* `dhcp4: yes`: Enables DHCP on both interfaces.
* `routes:`: Defines routing rules.
  * `to: default`: Specifies the default route (0.0.0.0/0).
  * `via:`: Specifies the gateway IP address. Important: Replace the example gateway IPs with your actual gateway addresses.
  * `metric:`: Sets the routing metric (lower is better). Lower metric has high priority.&#x20;

**Example Netplan YAML Configuration (no gateway):**

```
network:
  version: 2
  renderer: networkd
  ethernets:
    enp0s3:
      dhcp4: yes
      dhcp4-overrides:
        route-metric: 100
    enp0s8:
      dhcp4: yes
      dhcp4-overrides:
        route-metric: 200

```
