Sample Header Ad - 728x90

How to set up Multiple networks and routing using new Ubuntu Netplan?

1 vote
2 answers
9485 views
I have a requirement and this was working (up to 2020) without issue. As my installs were outdated and I didn't care to actually UPGRADE, I decided to blitz the lot and begin with fresh installs using Ubuntu 23.04 for servers and 24.04 for my desktop. I am creating this via Virtualbox setup and have two host-only networks: 192.168.110.x and 192.168.120.x. Any server installs will be in either 110 or 120. The desktop has 3 NICs: * enp0s3=NAT (10.0.2.15) * enp0s8=192.168.110.3 * enp0s9=192.168.120.3. I have set IP forwarding on the desktop to route 110 and 120 through enp0s3 using IP tables. All this was working when gateway was a valid declaration in netplan. However, now the setup is different, I have been looking at the netplan examples provided via a different question and can find nothing which might match MY needs. I am finding it a bit confusing to work out the routing declarations for each network. As an aside, rather than declaring nameservers twice, can I somehow just specify it once for all ethernets? 1 # Let NetworkManager manage all devices on this system 2 network: 3 version: 2 4 renderer: NetworkManager 5 ethernets: 6 enp0s8: #Edit this line according to your network interface name. 7 dhcp4: no 8 addresses: 9 - 192.168.110.3/24 10 routes: 11 - to: default 12 via: 192.168.110.1 13 nameservers: 14 addresses: 15 - 8.8.8.8 16 - 8.8.4.4 17 enp0s9: #Edit this line according to your network interface name. 18 dhcp4: no 19 addresses: 20 - 192.168.120.3/24 21 routes: 22 - to: default 23 via: 192.168.120.1 24 nameservers: 25 addresses: 26 - 8.8.8.8 27 - 8.8.4.4 28 The error I am getting is: > Problem encountered while validating default route consistency.Please > set up multiple routing tables and use routing-policy instead. > > Error: Conflicting default route declarations for IPv4 (table: main, > metric: default), first declared in enp0s8 but also in enp0s9
Asked by Hpoonis (11 rep)
Mar 7, 2024, 11:01 AM
Last activity: Nov 13, 2024, 07:58 PM