9

I am building a little network lab. I want to turn one of my Raspberry Pi 4 into a switch.

I already have a network manufacturer docker image to run on it.

Still, I have only one RJ45 port. How to add more? (at least 3).

I read that it wasn't possible for older RPi versions. Is it still the case?

M. Rostami
  • 4,323
  • 1
  • 17
  • 36
Gane D. Geoffrey
  • 101
  • 1
  • 1
  • 4
  • 5
    Buy a switch - it will be cheaper, more reliable and work better. PS "RJ45" is a telephone jack. – Milliways Feb 28 '20 at 22:07
  • 2
    I do have a switch already. But for knowledge purpose, I want to emulate a small cloud fabric. I need to have a switch with an manufacturer OS running on it. I already have the software, I juste need extra ports.

    Are you suggesting I could use some dumb switch and use the RPi as a controller for it ?

    – Gane D. Geoffrey Feb 28 '20 at 22:21
  • 3
    In other words you DO NOT want to turn one of my Raspberry Pi 4 into a switch. You can add Ethernet ports with USB dongles, there may be Ethernet HATs. – Milliways Feb 28 '20 at 22:25
  • an RJ45 port is not necessarily an ethernet port – jsotola Feb 29 '20 at 03:58
  • 2
    Adding RJ45 ports doesn't help you one bit. You need to add network adapters. – Jörg W Mittag Feb 29 '20 at 10:47

5 Answers5

8

You can add two Ethernet ports to your raspberry pi with EthernetBerry Dual ETHERBERRY. Check this link out:

EtherCAT® Shield for Raspberry PI – EtherBerry

You want to add at least 3 different port. So, one another can be a USB Ethernet port which you would connect to your raspberry pi by one of the USB ports.

You can add more USB Ethernet port but you should take note that they will be work on the USB clock. As an example, if the USB port speed is 50MB (400Mbit) at the high situation and if you plug 3 different USB Ethernet port which are transmitting/receiving data over the port, each one can transmitting/receiving data with the speed of 17MB (133Mbit). I mean, the speed would be divided/shared between ports.

Wisteso
  • 295
  • 1
  • 2
  • 8
M. Rostami
  • 4,323
  • 1
  • 17
  • 36
7

I would comment on @m-rostami's post but I don't have sufficient reputation yet.

The EtherCAT shields are very expensive, but adding USB->Ethernet adapters will work just fine. Yes, the performance will be very poor, but you probably don't care about that because you are running this as a learning experiment.

Remember that the Raspberry Pi model 3 and earlier only supports USB-2 and your network performance will be poor anyway because you will have lots of adapters sharing the same USB bus, so there is no point buying more expensive USB3 or GbE adpaters if you're on a model 3. Just buy the cheapest. I've used lots of different versions for various reasons and they all work fine if you install the drivers. That having been said, the older USB2->100 BaseT adapters are getting harder to find now because people have moved over to USB3->GbE.

Adapters that I can recommend as I personally tried them and found them to work well are:

Manufacturer    Model               Style            Driver
Anker           AK-A7610011         USB3->GbE        r8152
Belkin          B2B048              USB3->GbE        r8152
CableMatters    202023-BLK          USB2->10/100     r8152, smsc95xx
CableMatters    202013-BLK          UBS3->GbE        r8152
Linksys         USB3GIG-EJ          USB3->GbE        r8152
Trendnet        TU3-ETG             USB3->GbE        ax88179_178a

Just remember that they all need power so get a big power supply for your Pi or, better still, use a powered external USB hub. The power supply design in the Pi is very "cost optimised" and doesn't work well if you load it up with lots of power-hungry peripherals, and USB->Ethernet adapters (especially GbE ones) can draw quite a bit of power. Using a powered external USB hub completely solves the power issues.

5

The Raspberry Pi is not a good candidate for such an experiment. Raspbian is a general-purpose OS based on Debian Linux. Instead, buy, perhaps second-hand, a device intended to be a router that has multiple Ethernet ports and probably a wireless access point. Load one of the open-source firmware releases, DD-WRT, OpenWRT, Tomato, or perhaps something else. OpenWRT, in particular, has QoS support and access to some of the low-level functions without modifying source code.

Of course, many of the distributions you could load on such a device are also based on Linux, but the heavy lifting of dealing with the communications fabric has at least mostly already been done. That leaves you free to experiment with the interesting bits.

Bob Brown
  • 1,037
  • 8
  • 12
  • 1
    Raspberry Pi is a supported target in OpenWrt: https://openwrt.org/toh/raspberry_pi_foundation/raspberry_pi – Dominykas Mostauskis Jan 07 '21 at 17:26
  • @DominykasMostauskis I didn't know that. Thank you! I still think buying a device with hardware designed for routing and switching is the best approach, even for experimentation, and certainly for production. – Bob Brown Jul 20 '22 at 14:44
2

FWIW, if you have a Pi CM4 with the IO board (as opposed to a regular Pi 4), you could add a PCI Ethernet NIC (with multiple ports), by using the on-board PCI-E slot, to make a multi-homed device.

The official IO board already has an on-board gigabit Ethernet port, so by simply adding a dual NIC PCI card, you would then have the three Ethernet ports that you want. The main advantage of this approach would be that all of the ports will operate at full speed, when compared to using the slower USB-Ethernet dongles described in some of the other answers.

One such example is shown in Jeff Geerling's video, 5 Gbps Ethernet on the Raspberry Pi Compute Module 4?!, which uses a 4 port, Intel I340-T4 PCIe NIC.

CM4 IO board with 4 port NIC attached

A combined speed of ~3 Gbps was achieved.

Jeff also touches upon using USB-Ethernet dongles - merely to state that the PCI solution is much neater.

Greenonline
  • 2,740
  • 4
  • 23
  • 36
0

The simplest solution is to buy a 4 port switch and connect the rest onto it including the PI.

Getting more RJ45s onto the PI is like turning the PI into a switch itself.

EDIT: For me it sounded like the OP wanted to turn his PI into a network switch.

I already have a network manufacturer docker image to run on it.

this only talks about software not hardware!

Max N
  • 1
  • 3