I would like to set up a Raspberry PI as a router between two subnets on the same network using the standard built in ethernet interface.

The aim is to be able to use this to monitor network usage (with tshark) in a network where it isn't possible to physically bridge the external internet connection and the local area network and where ethernet switches are in use so it is not possible to simply monitor all network traffic at any one point. This setup will rely on the cooperation of all users who will have to reassign their machines to the new subnet so that their traffic is routed through the PI.

I recognise that the Raspberry PI with it's USB based ethernet will introduce latency issues and that this isn't not an ideal scenario, but this is small scale experimental and it seems to be the least disruptive way of making this work. However, I'm open to alternative suggestions.

So far:

  • I have successfully installed tshark which works fine.

  • I have successfully set up the device multi-homing by adding an additional iface definition for eth0:0 in /etc/network/interfaces defined with an address on the additional subnet.

  • I have successfully installed brctl (part of the bridge-utils package).


It appears that brctl will only bridge between physical interfaces and doesn't want to know the additional virtual interface eth0:0.

Is there a way of configuring brctl to do this, or is there some alternative way of going about this?

  • 1
    I think you are confusing several thinks. First I point you to the OSI Model (en.wikipedia.org/wiki/OSI_model). In networks, bridges are used to connect networks at layer 2 and routing is done at layer 3. In fact, to only monitor network, you don't even need to put the RP in the middle, you just need to configure ethernet port in promiscuous mode. In promiscuous mode the ethernet card will capture all packets and not only the packets for it and you can use tshark ou tcpdump to 'see' whats going on in network. In fact, when you use tcpdump, it put the ethernet in promiscuous mode. – Pipe Mar 8 '13 at 19:47
  • Your are more than likely correct about the layer issue. However, in a network with switches the traffic to the Raspberry Pi is limited to those packets addressed to it regardless of promiscuous mode because the switch (rather than hub) isolates the traffic to optimise flow. – sroebuck Mar 8 '13 at 21:37
  • There are several solutions depending your network topology. If your switch don not allow port mirroring than Mulaz answer is a simple solution. – Pipe Mar 9 '13 at 11:54

You do not need bridges to do that.

After setting up the interfaces, you have two options:

  • You can set up forwarding directly ("routing"), just by enabling it:


echo 1 > /proc/sys/net/ipv4/ip_forward

(you can do the same for ipv6 if you need it)

You need interfaces and a default gw configured.

You also need to add a route on your upstream routers, for the subnet behind the rPI:

route add -net your.subnet.behind.rPI netmask your.net.mask.there gw rpi.ip.add.ress


route add -net netmask gw

If your rPI has and the network behind it is

  • If you cannot access the upstream routers, you can set up NAT:

Configure the interfaces, enable ip fowarding, and then enable nat on the upstream interface (eth0 in example):

iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
| improve this answer | |
  • I've tried the second option (I can't access the upstream routers). I have enabled IP forwarding okay and applied the iptables command (and some variants of it found elsewhere) but it doesn't appear to be passing messages between the subnets. Is there something I need to do to enable nat - other than the iptables command itself? Is there any reasonably straightforward way of debugging what's happening? Many thanks. – sroebuck Mar 9 '13 at 13:17
  • Can you ping both subnets from the rPi? Set the rPi as the default gateway on the subnet behind it? – mulaz Mar 9 '13 at 14:42
  • Many thanks - I had failed to change the gateway from the original setting. – sroebuck Mar 11 '13 at 12:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.