I'm spinning out on this one...! Someone please help!
I followed this fab tutorial below to make my own Ubuntu based router:
How to build a simple router Ubuntu Server 18.04
Which works great using only two ports of the four ports available on my hardware which is:
- old lenovo desktop with an old 4 port HP Gigabit Adaptor NC364T
- interface 1 (WAN): DHCP conn to BT HomeHub router (192.168.1.?/24)
- interface 2 (LAN): static 10.1.0.1 with DHCP server setup over subnet 10.1.0.0/24
- interface 2 then connects to a new Cisco SG220-26 switch and hey presto I'm up with all my LAN devices!
However.... as I have some storage in the box as well and both switch/net card support link aggregation. I thought I could create a bond in netplan and increase the bandwidth (e.g. use 1 port for WAN, 3 other for LAN aggregated link to the switch) plus its a learning exercise right....?!
I can't seem to get this to work..either as a bond or adding static/dhcp interfaces to my netplan yaml
Here is the working netplan yaml for the two port version:
network:
ethernets:
enp3s0f0:
dhcp4: true
enp3s0f1:
addresses:
- 10.1.0.1/24
dhcp4: false
nameservers:
addresses:
- 8.8.8.8
- 8.8.4.4
search: []
version: 2
And the working /etc/rc.local iptables configuration:
#!/bin/bash
# /etc/rc.local
# Default policy to drop all incoming packets.
iptables -P INPUT DROP
iptables -P FORWARD DROP
# Accept incoming packets from localhost and the LAN interface.
iptables -A INPUT -i lo -j ACCEPT
iptables -A INPUT -i enp3s0f1 -j ACCEPT
# Accept incoming packets from the WAN if the router initiated the connection.
iptables -A INPUT -i enp3s0f0 -m conntrack \
--ctstate ESTABLISHED,RELATED -j ACCEPT
# Forward LAN packets to the WAN.
iptables -A FORWARD -i enp3s0f1 -o enp3s0f0 -j ACCEPT
# Forward WAN packets to the LAN if the LAN initiated the connection.
iptables -A FORWARD -i enp3s0f0 -o enp3s0f1 -m conntrack \
--ctstate ESTABLISHED,RELATED -j ACCEPT
# NAT traffic going out the WAN interface.
iptables -t nat -A POSTROUTING -o enp3s0f0 -j MASQUERADE
# rc.local needs to exit with 0
exit 0
Using the netplan example for a bonded router as a starting point, my not working bonded netplan yaml looks like:
network:
version: 2
ethernets:
enp3s0f0:
dhcp4: yes
enp3s0f1:
dhcp4: false
enp4s0f0:
dhcp4: false
optional: true
enp4s0f1:
dhcp4: false
optional: true
bonds:
pigeon-lan:
interfaces: [enp3s0f1, enp4s0f0, enp4s0f1]
addresses: [10.1.0.1/24]
nameservers:
addresses: [8.8.8.8, 8.8.4.4]
search: []
parameters:
mode: 802.3ad
mii-monitor-interval: 1
With my not working bonded /etc/rc.local iptables configuration identical, except I have switched the LAN interface (enp3s0f1) for the bond interface (pigeon-lan):
#!/bin/bash
# /etc/rc.local
# Default policy to drop all incoming packets.
iptables -P INPUT DROP
iptables -P FORWARD DROP
# Accept incoming packets from localhost and the LAN interface.
#iptables -A INPUT -i lo -j ACCEPT
iptables -A INPUT -i pigeon-lan -j ACCEPT
# Accept incoming packets from the WAN if the router initiated the connection.
iptables -A INPUT -i enp3s0f0 -m conntrack \
--ctstate ESTABLISHED,RELATED -j ACCEPT
# Forward LAN packets to the WAN.
iptables -A FORWARD -i pigeon-lan -o enp3s0f0 -j ACCEPT
# Forward WAN packets to the LAN if the LAN initiated the connection.
iptables -A FORWARD -i enp3s0f0 -o pigeon-lan -m conntrack \
--ctstate ESTABLISHED,RELATED -j ACCEPT
# NAT traffic going out the WAN interface.
iptables -t nat -A POSTROUTING -o enp3s0f0 -j MASQUERADE
# rc.local needs to exit with 0
exit 0
Also, I have changed the DHCP interface in /etc/default/dhcpd.conf to hit the bond as well.
As soon as this is applied (netplan/dhcp/reboot etc.) I can't hit the WAN/LAN via the switch at all, but can ping out from the box to google etc so the WAN looks ok.
scratching my head on this one as to where to go so any help would be appreciated!!
FYI - my ifconfig shows:
docker0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 172.17.0.1 netmask 255.255.0.0 broadcast 172.17.255.255
inet6 fe80::42:7eff:feab:7e59 prefixlen 64 scopeid 0x20<link>
ether 02:42:7e:ab:7e:59 txqueuelen 0 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 72 bytes 11027 (11.0 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
enp3s0f0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.117 netmask 255.255.255.0 broadcast 192.168.1.255
inet6 fe80::224:81ff:fe81:8d4d prefixlen 64 scopeid 0x20<link>
ether 00:24:81:81:8d:4d txqueuelen 1000 (Ethernet)
RX packets 1563 bytes 521441 (521.4 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 921 bytes 137509 (137.5 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 39 memory 0xfe720000-fe740000
enp3s0f1: flags=6211<UP,BROADCAST,RUNNING,SLAVE,MULTICAST> mtu 1500
ether d6:a1:38:bd:13:bc txqueuelen 1000 (Ethernet)
RX packets 2306 bytes 171452 (171.4 KB)
RX errors 0 dropped 3 overruns 0 frame 0
TX packets 128 bytes 16384 (16.3 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 26 memory 0xfe700000-fe720000
enp4s0f0: flags=6211<UP,BROADCAST,RUNNING,SLAVE,MULTICAST> mtu 1500
ether d6:a1:38:bd:13:bc txqueuelen 1000 (Ethernet)
RX packets 245 bytes 23278 (23.2 KB)
RX errors 0 dropped 3 overruns 0 frame 0
TX packets 133 bytes 16830 (16.8 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 44 memory 0xfe520000-fe540000
enp4s0f1: flags=6211<UP,BROADCAST,RUNNING,SLAVE,MULTICAST> mtu 1500
ether d6:a1:38:bd:13:bc txqueuelen 1000 (Ethernet)
RX packets 177 bytes 15554 (15.5 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 128 bytes 16384 (16.3 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 24 memory 0xfe500000-fe520000
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 46 bytes 3032 (3.0 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 46 bytes 3032 (3.0 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
pigeon-lan: flags=5187<UP,BROADCAST,RUNNING,MASTER,MULTICAST> mtu 1500
inet 10.1.0.1 netmask 255.255.255.0 broadcast 10.1.0.255
inet6 fe80::d4a1:38ff:febd:13bc prefixlen 64 scopeid 0x20<link>
ether d6:a1:38:bd:13:bc txqueuelen 1000 (Ethernet)
RX packets 2728 bytes 210284 (210.2 KB)
RX errors 0 dropped 6 overruns 0 frame 0
TX packets 389 bytes 49598 (49.5 KB)
TX errors 0 dropped 69 overruns 0 carrier 0 collisions 0
veth0b52c2b: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet6 fe80::bc0d:62ff:fe4c:8c7b prefixlen 64 scopeid 0x20<link>
ether be:0d:62:4c:8c:7b txqueuelen 0 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 8 bytes 656 (656.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
veth6ab4d9d: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet6 fe80::ccbe:f5ff:fed8:ae7a prefixlen 64 scopeid 0x20<link>
ether ce:be:f5:d8:ae:7a txqueuelen 0 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 87 bytes 12173 (12.1 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0