Welcome to the IPFire Wiki

This wiki is a community-maintained resource about everything there is to know about IPFire.

Please join in and help us improving it!

Differences in Revisions: Using extra ports as a network switch

»
Fix headline
#Using extra ports as a network switch
# Using extra ports as a network switch
 
 
## Overview
I ran into this problem with hardware from Soekris, a nice little device designed for network equipment. It comes with 4 NIC's and a PCI slot which you can plug a wireless card into. It is pretty low on memory, and the processor is slower than most smart phones, but it makes a nice IPFire machine.
 
It is those 4 NIC's that bothered me. I never use them. Sometimes, I set up Red/Green/Blue and put Blue on a WAP, but rarely do I need Red/Green/Blue/Orange. So, I wanted to see if I could use the extra ports as a switch, similar to some low end consumer products.
 
Reading some documents, specifically one from Soekris and a wiki article by Arne here at IPFire, I came upon a good, tested solution. With this, you can use as many NIC's as you have.
 
 
## How To
First, determine which ports you will use for your required setup. In most cases, you will want Red/Green/Blue, with Blue being set up on a wireless card. Do the normal install, using only the minimum you need.
 
After you are done with the setup, ssh into the firewall and see what devices are being used, and which ones are available. One way to find all NIC's in a system is:
 
```text
cat /proc/net/dev
```
 
In my case it showed (I've cut off part of the output because it had tons of columns):
 
```text
Inter- | Receive
face | bytes packets
red0: 14654744 19270
tun0: 22539 261
green0: 2132884 12490
lo: 2632 30
eth2: 0 0
eth3: 0 0
```
As you can see, IPFire has set the first two NIC's to red0 and green0, then put the other two NIC's as the standard eth2 & eth3. These are the NIC's we will use to set up our bridge.
 
Create the file `/etc/init.d/bridge` with the following contents:
 
```bash
#!/bin/sh
########################################################################
# Begin $rc_base/init.d/bridge
#
# Description : Skript to use more than one NIC's as green net
#
# Authors : Arne Fitzenreiter - arne_f@ipfire.org
#
# Version : 01.00
#
# Notes : http://wiki.ipfire.org/en/configuration/network/bridge-green-blue
# Modified Rod Rodolico, 20151105
#
# Script is changed from Arne's original to use all ports listed herein as
# extra green ports.
#
########################################################################
 
. /etc/sysconfig/rc
. ${rc_functions}
 
case "${1}" in
start)
boot_mesg "Create bridge for green net..."
# down green0
ip link set green0 down
# rename green0 to eth1
ip link set green0 name eth1
# create new bridge green0
brctl addbr green0
# wait 2 seconds because udev try to rename the nics
# if the real green nic was added to fast...
sleep 2
# Add real green nic and the unused ones
brctl addif green0 eth1
# add all the unused nics here
brctl addif green0 eth2
brctl addif green0 eth3
# Bring nic's up
ip link set eth1 up
ip link set eth2 up
ip link set eth3 up
;;
 
stop)
boot_mesg "Remove bridge for green net......"
# Bring nic's down
ip link set eth1 down
ip link set eth2 down
ip link set eth3 down
# Bring bridge down
ip link set green0 down
# Delete Bridge
brctl delbr green0
# rename eth1 to green0
ip link set eth1 name green0
;;
*)
echo "Usage: ${0} {start|stop}"
exit 1
;;
esac
 
# End $rc_base/init.d/bridge
```
 
Now, you should set permissions on the script, then create links from the appropriate run levels
 
```text
chmod 754 /etc/init.d/bridge
ln -s /etc/init.d/bridge /etc/rc.d/rc3.d/S19bridge
ln -s /etc/init.d/bridge /etc/rc.d/rc0.d/K82bridge
ln -s /etc/init.d/bridge /etc/rc.d/rc6.d/K82bridge
```
 
## Sources
 
* [](https://wiki.ipfire.org/configuration/network/bridge-green-blue)
* <http://wiki.soekris.info/Debian_Switch>