Configure Netplan on Ubuntu with two network interfaces and two subnets, prioritizing one for web traffic.
Configure Netplan on Ubuntu with two network interfaces and two subnets, prioritizing one for web traffic.
Hello, I need to configure two Ubuntu 20.04 servers with NICs on LAN1 and LAN2 using NetPlan. They should have static IPs for their subnets. No DHCP needed—traffic between LAN1 and LAN2 shouldn't be routed, and they should appear invisible. I want to set interfaces or route metrics so that WAN traffic favors the NIC connected to ISP2 (NIC2), making ISP1 unavailable during outages. IPv6 can be disabled or handled with IPv4 weights as needed. I'm looking for guidance since existing examples seem to route traffic between LANs, and I need separate access for each network while prioritizing the desired path.
You can combine the two interfaces in your Netplan configuration for NIC1 and NIC2. Assign IP addresses to both, configure NIC2 as the default gateway and route, and set NIC1 as neither a default gateway nor a default route. Ensure a route exists for NIC1's network so traffic destined there can pass through it. The default route should remain on NIC2 to direct all other and WAN traffic accordingly. This setup typically looks like this (with eth0 as NIC1 and eth1 as NIC2): network: version: 2 renderer: NetworkManager ethernets: eth0: addresses: - 172.16.10.5/24 routes: - to: 172.16.10.0/24 via: 172.16.10.1 eth1: addresses: - 172.16.11.5/24 routes: - to: default via: 172.16.11.1
Ensure a dedicated path exists for NIC1's network to allow data to move through that specific interface. The standard route to 0.0.0.0/0 should remain exclusive to NIC2, directing all additional traffic and WAN connections there.