Has anyone used their Pi as a routing device? Mainly I want to use it to monitor my network and it would be great if it had an input and output for ethernet, but it doesn't so I am wondering if it is very effective to monitor the network by having the ethernet input and then using a USB dongle as a wifi router. Has anyone done anything like this? Does it slow the internet down by much?
I've been using my model B as a router with traffic shaping, using just the one Ethernet port it comes with. Here's a quick-and-dirty on how:
When your devices next reconnect to the network, they will be told your Pi is their gateway to the internet, and all they internet-bound traffic will be sent to it. Your Pi will in turn relay all that traffic to your usual router. You might need to disconnect and then reconnect your devices for these changes to take effect.
Now you can create or install a tool to do your monitoring for you, such as vnstat.
As for traffic shaping, here's another quick-and-dirty guide which will make use of my own personal variant of wondershaper.
For this to be useful you need to know how fast your internet connection is. You can usually find this from your (original) router's web interface, but failing that you can get an estimate using a speedtest.
Your outbound network traffic is now being shaped by your Pi, and your inbound traffic is being throttled slightly to ensure that the Pi, and not your original routing box, has control of traffic.
To disable shaping, just run
Update: You also need to disable the transmission of ICMP redirects, since we need all traffic to go through the Pi for shaping to happen. It turns out that the Linux kernel is smart enough to figure out that the clients on your home network could talk directly to the ADSL box, rather than bounce traffic through the Pi, and it tells them this at every opportunity. The clients then send their traffic directly to your ADSL box, and the Pi doesn't get a chance to shape it. Disable it on the fly like so (lost when you next reboot):
Update the following to set this during boot:
(Thanks to http://unix.stackexchange.com/a/58081/22537 for this tip)
You may also be interested in my personal notes on configuring a Linux gateway: http://www.robmeerman.co.uk/unix/gateway
Having a little network background, the first thing that comes to mind is use it as a Snort box, and then you don't have to worry about only having one interface. You would setup your switch/router to forward all traffic to the Pi, but also pass it onto the end device. This is known as a switchport monitor, but your device may not support it. You may need a managed switch to do this. Snort would then analyze the traffic and report on it. More information on Snort http://www.snort.org/
The nice thing about this kind of setup is your Pi is sitting off to the side watching everything that is being run through the switch, rather than sitting inline with the data. If you have a software glitch this way, traffic can still flow, just not be monitored. With what you are describing with two interfaces, your program crashes, your network crashes.
This does not use the pi as a router, but does allow you to monitor and report on traffic that is moving across your network.
I have used the Pi for routing, it worked well. As you say, you need at least one more network interface, as the Pi has only one ethernet port. You can add another interface connected to the USB port. I have used a GSM modem and a Wifi stick.
Things to note:
Here is my blog post about routing, and another about setting up a WiFi access point. This guide helped me with the routing setup. The routing stuff is not very specific to the Pi, anything that works on Linux in general should be possible. The details depend a bit on which distribution you use.
I have been using the Pi as a router for about a month now, without any problems. I have an actual commercial WiFi Access Port, not a home WiFi router, so I used that. I also have a USB to Ethernet converter that was "borrowed" from the Wii. That goes to the home LAN, and the Pi's built-in Ethernet goes to the WAN/Internet.
Go get a copy of IPFire for the Pi. You want the ARM version, without a serial console. http://download.ipfire.org/ . Latest stable version. Click on the ARM tab. Download the "Image for the armv5tel architecture".
Boot off of it. Hook up a HDMI TV and keyboard. Answer the first few questions. The rest of the configuration can be done from a browser on the home network, so you won't need the TV or keyboard after that.
Not too hard, and worked like a champ!. Here are the formal instructions:
One last thing. If you are going to use a USB powered WiFi dongle, check your Pi's power supply. A 700mA USB power supply may be enough to power the Pi, but it doesn't leave much to power the WiFi. Either use a powered USB hub, or power the Pi with a 1 to 2 amp USB power supply.
(This addendum follows my previous answer, which was a guide on how to configure your Pi as your LAN's internet gateway)
Not content with monitoring my overall internet usage, I've written a tool that monitors the internet usage of each device on my LAN. This allows me to see the instantaneous usage in a console window, and to generate charts of historical usage so I can see what happened overnight.
Rhodes, a tool for monitoring real-time and historical network usage of LAN devices (based on MAC address): https://github.com/meermanr/adsl/tree/master/rhodes
Sample of console output:
The first column shows how much devices are transmitting, which usually means uploading to the internet. The exception to this it the ADSL router itself (home.gateway in the sample above) which transmits data received from the ISP the device which requested it (i.e. downloads). Of course it also transmits uploads to the internet, but it does that using its ADSL modem, which is not on the LAN and so not visible to this tool.
The other exception would be the Raspberry Pi ("Flux" in the above) itself, which of course transmits all the data it manages, in both directions.
But apart from those exceptions, the TX (transmit) numbers refer to upload, and the RX (receive) numbers to download. The third column is the device's MAC address (without the usual ":" or "-" separators). The forth column shows the human-readable name of the device, if it is known.
Charts are generated by running
Then open index.html in your preferred browser.
Installation requirements (all can be installed with
Usage note: The 'tcpdump' tool used by this script requires root privileges to access raw network traffic. This is achieved by launching