# Making a server into a switch



## crazychip (Aug 3, 2012)

Hi, I am planning a little project where I will add two(or more) network cards to my FreeBSD gateway to make a switch. The reason behind this is to be able to enable/disable one of the "ports" using cron.

How do I go about "linking" these cards together to make it into a switch?


----------



## SirDice (Aug 3, 2012)

You can bridge(4) them all together.


----------



## crazychip (Aug 4, 2012)

Okey, having read some on bridging in the handbook I tried to create a bridge and that seams to work fine. But when I attach cables to the bridged cards, I loose my SSH connection to the server.

My scenario:
I have four network adapters in my server, em0 em1 re0 and xl0.
My home network is attached to xl0(10.47.0.1) and the external connection(DHCP) is on em1.

I want to use re0 and em0 to connect to my fiber mode and a television decoder.
So I create a bridge and up the connections like this: (no cables are attached to em0 or re0)

```
# ifconfig bridge create
bridge0
# ifconfig bridge0 addm re0 addm em0 up
# ifconfig re0 up
# ifconfig em0 up
```
All seams good. But then I attache cables to re0 and em0. The server stops responding. I remove the cables, server still not responding.


----------



## crazychip (Aug 6, 2012)

I have no idea where to even start looking. Non of the log files I have checked show any messages indicating what might happen when I attache the cables.

Any tips would be much appreciated.


----------



## SirDice (Aug 6, 2012)

I think you need to rethink your strategy.


----------



## crazychip (Aug 6, 2012)

It would seem so. But I did get it to work(somewhat). I attached all the cables first and then made the bridge. Picture started up on the TV again, and everything looked good. However after a few hours I get a lag in the signal and all other channels are dead besides the one it was originally on. My ISP(also the TV provider) says that I can attach multiple decoders to the modem by using a 100Mbps switch. So in my mind the FreeBSD bridge should not be any different. Both connections list the speed as 100.


----------



## crazychip (Aug 6, 2012)

I have found a possible reason for the loss of signals.
The TV network is separated in the modem from the data network by the use of VLANs.
Data is on 102 and TV is on 101. I am thinking that FreeBSD might be stripping the VLAN tag of the traffic.


----------



## phoenix (Aug 9, 2012)

vlan(4)


----------



## anomie (Aug 16, 2012)

@crazychip: What made you select a layer 2 switch implementation for this purpose? You said you want to "enable/disable one of the 'ports' using cron", but how is a switch uniquely suited for that? 

Would this not be a reasonable candidate for a FreeBSD gateway that provides NAT?


----------



## crazychip (Aug 18, 2012)

@anomie: I have no idea why. It seamed like a good option to me at the time.
In my attic there is a fiber optic modem that bridges the internet connection to a port marked _Internet_. There I have connected my FreeBSD gateway that uses NAT to my home network. Then it also has two port marked _Phone_ and another three marked _TV_.
The _TV_ ports are used to connect decoders. I thought that if I connect one of these to my FreeBSD gateway as a part of a bridge to a decoder in my daughters room, I could turn of here signal at bed time.  If you have a better idea that I have not thought of please share. (because the bridge didn't work)


----------



## toddnni (Aug 18, 2012)

Try bridging the virtual vlan interfaces too, and use different bridges for distinct vlans and real interfaces.


----------

