I have an ubuntu 18.04 router with several LAN interfaces:
1st interface: 2 port 10G NIC (the interfaces are bonded/teamed) bond1: interfaces: [enp5s0f0, enp5s0f1]
2nd interface: 4 port NIC enp8s0f0, enp8s0f1, enp9s0f0, enp9s0f1
The router functions as a gateway and DHCP server. Currently the 1st and 2nd interfaces are bridged together to 192.168.0.1 (the LAN interface). My current netplan configuration is the following:
# This file describes the network interfaces available on your system
# For more information, see netplan(5).
network:
version: 2
renderer: networkd
ethernets:
enp0s8:
dhcp4: no
dhcp6: no
addresses: [69.59.34.150/24]
gateway4: 69.59.34.1
nameservers:
addresses: [69.60.173.84, 8.8.8.8]
optional: true
enp0s9:
dhcp4: no
dhcp6: no
enp2s0f0:
dhcp4: no
dhcp6: no
enp2s0f1:
dhcp4: no
dhcp6: no
enp5s0f0:
dhcp4: no
dhcp6: no
enp5s0f1:
dhcp4: no
dhcp6: no
enp8s0f0:
dhcp4: no
dhcp6: no
enp8s0f1:
dhcp4: no
dhcp6: no
enp9s0f0:
dhcp4: no
dhcp6: no
enp9s0f1:
dhcp4: no
dhcp6: no
bonds:
bond0:
interfaces: [enp2s0f0, enp2s0f1]
parameters:
mode: 802.3ad
lacp-rate: fast
mii-monitor-interval: 100
bond1:
interfaces: [enp5s0f0, enp5s0f1]
parameters:
mode: 802.3ad
lacp-rate: fast
mii-monitor-interval: 100
bridges:
br0:
addresses: [192.168.0.1/24]
gateway4: 192.168.0.254
routes:
- to: 10.10.10.0/24
via: 192.168.0.254
- to: 20.20.20.0/24
via: 192.168.0.254
interfaces: [enp8s0f0, enp8s0f1, enp9s0f0, enp9s0f1, bond1]
parameters:
stp: false
forward-delay: 0
Note that there are several other interfaces, but my question relates to br0 which bridges the 4 port NIC and the 2 port 10G NIC - they are all on the same subnet 192.168.0.x. I have specified a gateway (a switch at 192.168.0.254) for static routing of VLANs.
I would like to break up the 4 port NIC and the 2 port 10G NIC into different subnets (i.e 2 different bridges). The new schema:
2 port 10G NIC on subnet 192.168.0.x 4 port NIC on subnet 192.168.1.x
I would need to retain the DHCP functionality as well on both subnets (supplied by the same box).
My dhcpd.conf is as follows:
subnet 192.168.0.0 netmask 255.255.255.0 {
range 192.168.0.10 192.168.0.240;
option routers 192.168.0.1;
option domain-name "xxxxxx.org yyyyyyy.com";
option domain-name-servers 192.168.0.1;
option broadcast-address 192.168.0.255;
}
host DELL_PowerConnect_6248P {
hardware ethernet aa:bb:cc:dd:ee:ff;
fixed-address 192.168.0.254;
option host-name "DELL_Powerconnect_6248P";
}
My question is specifically this: Can I separate the two NICs by creating another bridge with just the 4 port NIC on subnet 192.168.1.x and then just add another subnet in the DHCP configuration file and have everything work?
My reasoning for doing this is simple. The 10G NIC is connected to a Layer 3 switch (dedicated), and I would like to use the other 4 ports to function just like a home router. In theory this seems like it would work, but my concern is retaining the DHCP functionality across both subnets. Thank you in advance for any assistance you can provide.
After much toil trouble and a six pack I have figured out the answer to my query.
First to re-iterate: I have a home built 18.04 UBUNTU router with 3 NICS - I am posting this because 18.04 uses netplan and I did not find a suitable answer on the message boards for netplan.
NIC 1: built in gigagbit ethernet - WAN
NIC 2: 2 port 10G NIC - Bonded and connected to a layer 3 switch (located at 192.168.0.254) - subnet 192.168.0.x
NIC 3: 4 port gigabit NIC used for local internet access (separate from the switch) - subnet 192.168.1.x
As you can see, I wished to create 2 subnets - 192.168.0.x for the switch and 192.168.1.x for the 4 port NIC (to use even when the switch was disconnected).
As this machine is a router, it needs to both route, assign IP addresses (DHCP), and provide DNS. Below, you will find my configuration for netplan and DHCP. DHCP occurs on both subnets, and NIC 3 has internet access even if the switch is disconnected from NIC 2 (ie it bypasses the switch and uses the router as a gateway)
As you look at the configuration, you will notice 2 bridges:
This is the /etc/netplan/01-netcfg.yaml file:
Note: a bridge was formed for bond 0 because I needed subnet 192.168.0.x on this NIC.
The br0 bridge allows the br1 bridge which is on subnet 192.168.1.x to connect to the internet via the router (192.168.0.1)
Next we need to configure DHCP on BOTH subnets. Here is are the iptables:
The most important thing to note here is that whatever I have listed for br0, I have duplicated for br1
Lastly we need to setup the DHCP and ensure it works on both subnets. This is the /etc/default/isc-dhcp-server file:
Lastly we need to modify the /etc/dhcp/dhcpd.conf file:
This worked for me. Now I can use the router like a home router even with the switch disconnected. PLEASE NOTE: This is by no means a list of what needs to be done to create your own ubuntu router. There are many other steps involved. This can easily be googled on the internet. Hopefully, this small tutorial helps someone in the future. Netplan is a pain, but rather straightforward. If an idiot like me can do it, anyone can. Happy Ubuntu-ing.
Status update. After about one hour, the WAN interface went down on the router. After some reading, it seems my above configuration was not quite correct. See the correction below. I have included comments (both for myself and others) in the code.
As you can see, I tweaked the config to prove a point. Even with ALL subnets being routed to 192.168.0.254 by default, the 192.168.1.x is an exception and is specifically routed to 192.168.0.1. This way I can still access the internet on the 4 port nic even if the switch is disconnected.
Now the router works and has not gone down for several hours. On to configuring bind, OpenVPN, and all the other good stuff.
I was able to learn all of this by looking at netplan examples specified at https://netplan.io/examples
Hopefully, this will prove of use with configuring netplan.