Use Raspberry pi as router. - Page 1
Forum section: electronics / beginners

author: sam1275
author_rank: Frequent Contributor
timestamp: May 01, 2015, 02:40:38 pm
content: Hello everyone.I just bought a Raspberry Pi A+, I want to use it as a router, I searched a lot and I found it can use Openwrt as OS, but in trunk state, now I have a few questions:1. Are there any better solutions than flash a openwrt OS?2. Is Netgear wna1000m v1 compatible?3. I want to attach a LCD or OLED for information display. Such as CPU/RAM usage, links status/speed, etc... Which is the best solution? Should I use the SPI(does it even work?), or serial port(Can I customizing the serial output)?At last... I cannot programming myself... So is these possible for me?Thank you.

author: Ed.Kloonk
author_rank: Super Contributor
timestamp: May 01, 2015, 02:54:26 pm
content: Quote from: sam1275 on May 01, 2015, 02:40:38 pmTo answer #1, short answer is yes. With a little work, you can setup up Linux which can provide a firewall and just about any routing you could dream of.Have to ask though, why not just use a off the shelf router?

author: Monkeh
author_rank: Super Contributor
timestamp: May 01, 2015, 03:05:37 pm
content: Why would you want to use a device with one slow, unreliable, USB connected ethernet interface as a router? It's about the worst possible choice.

author: sam1275
author_rank: Frequent Contributor
timestamp: May 01, 2015, 03:15:22 pm
content: Quote from: Ed.Kloonk on May 01, 2015, 02:54:26 pmThank you, are there any ready to use routing software? Most of the off-the-shelf in the country I current in are rubbish, I need a powerful one.

author: sam1275
author_rank: Frequent Contributor
timestamp: May 01, 2015, 03:17:04 pm
content: Quote from: Monkeh on May 01, 2015, 03:05:37 pmThe speed is enough for me, the internet is 30MBPS, and I don't think it's unreliable. Thx.

author: Monkeh
author_rank: Super Contributor
timestamp: May 01, 2015, 03:23:22 pm
content: Quote from: sam1275 on May 01, 2015, 03:17:04 pmSo you want to get 30Mbps in, and 30Mbps out, on a known-buggy USB ethernet interface with a slow CPU behind it? They're known to have problems achieving this sort of throughput, especially if you ask other things of the CPU.You are aware you'll need a VLAN capable switch to do this, as well? Or a second USB interface which will make matters even worse.

author: sam1275
author_rank: Frequent Contributor
timestamp: May 01, 2015, 03:29:49 pm
content: Quote from: Monkeh on May 01, 2015, 03:23:22 pmCould you explain more about it? How the USB is buggy? And are you really sure it's worse than routers that are far less CPU/RAM than it? (you may don't know routers most sold in this country is 2MB memory)BTW, I want to use only one WIFI adapter, no wired connection.Thx.

author: smjcuk
author_rank: Frequent Contributor
timestamp: May 01, 2015, 03:32:58 pm
content: You're not going to get 30Mbits/sec out of a Pi. The CPU hasn't got enough wumph and you're limited to crappy USB Ethernet/WiFi. As said before they're bloody unreliable as well. Slightest power spike causes a reset, they eat flash cards like nobody's business and there are so many bugs its unbelievable. Thats hardware and software bugs. Plug a USB stick in and out a few times and wait for the reset and then the fsck that screws your SD. Boom hours of work out of the window.Also I had one and posted on their forum a number of problems and the thread was deleted and my account terminated after a few hours. I was polite, courteous and offered to test any patches they might offer. I won't deal with people who work like that.If you want a router, buy a router. Microtik make good ones. Failing that an old thinkpad booted off USB works well as an AP.The pi is an awful piece of junk.

author: Monkeh
author_rank: Super Contributor
timestamp: May 01, 2015, 03:35:06 pm
content: Quote from: sam1275 on May 01, 2015, 03:29:49 pmThere are (potentially fixed?) issues with the USB controller dropping out during extended operation. Plus the CPU load is excessive, making it slow to use one interface, let alone several (what are you routing between with one interface?).And yes, I am very, very sure it's substantially worse than devices actually designed for the purpose.No, I don't know most routers sold in the USA are crippled, perhaps you should tell us where you really are?All this being beside the point when you can buy better equipment forless than the cost of a Raspivia, for example, Aliexpress, no matter where you are.

author: smjcuk
author_rank: Frequent Contributor
timestamp: May 01, 2015, 03:44:19 pm
content: These are nice. $22!http://routerboard.com/RB941-2nD

author: sam1275
author_rank: Frequent Contributor
timestamp: May 01, 2015, 03:47:33 pm
content: Quote from: Monkeh on May 01, 2015, 03:35:06 pmOk, thank you, but since I bought RPI, I'll try the project for my best.Of course not USA, I'm current living in China, not a good one at all.

author: Monkeh
author_rank: Super Contributor
timestamp: May 01, 2015, 03:49:34 pm
content: Quote from: smjcuk on May 01, 2015, 03:44:19 pmSadly internal antennas, but an excellent competitor (basically the same hardware, actually, just a little faster) to TP-Link's WR740N and WR841N (and detachable antennas versions thereof).Quote from: sam1275 on May 01, 2015, 03:47:33 pmAnd what exactly is the project? What are you routing between with a single interface?And why can't you go buy a WR720N which are made by the millions right there in China?

author: smjcuk
author_rank: Frequent Contributor
timestamp: May 01, 2015, 03:54:12 pm
content: They do slightly more expensive ones with SMA connectors on them or you can add your own as the internal antenna is socketed. Mine cost $45 and has all the bells and whistles including external antennas. Most reliable router I've ever had (and that includes Cisco, Juniper ones). Also kicks out a watt of power meaning it reaches half way down the road.

author: nixfu
author_rank: Unknown
timestamp: May 01, 2015, 04:01:59 pm
content: Ethernet performance on the Pi is terrible because it's designed like this:CPU ---> single slow USB 2.0 bus(shared with all other USB devices) ----> Ethernet

author: sam1275
author_rank: Frequent Contributor
timestamp: May 01, 2015, 04:04:20 pm
content: Quote from: Monkeh on May 01, 2015, 03:49:34 pmThanks.Can't I use the interface as both WAN and LAN?Do you know that TP-link use completely different hardware in China even the same model?

author: Monkeh
author_rank: Super Contributor
timestamp: May 01, 2015, 04:04:39 pm
content: Quote from: nixfu on May 01, 2015, 04:01:59 pmAll performance on the Pi is terrible because of the first component. The rest is just insult to injury.

author: bitwelder
author_rank: Super Contributor
timestamp: May 01, 2015, 05:25:23 pm
content: Quote from: sam1275 on May 01, 2015, 03:29:49 pmA router with only *one* interface? Are you sure, or do you plan to make a so-called 'router on a stick' ?I agree with others that the RasPi is one of the worst platforms to make a router.

author: Monkeh
author_rank: Super Contributor
timestamp: May 01, 2015, 05:29:42 pm
content: Quote from: sam1275 on May 01, 2015, 04:04:20 pm.. not so much.QuoteI think I know their range far better than you, which is why I suggested a very specific Chinese model. Also the WR703N.

author: Cliff Matthews
author_rank: Unknown
timestamp: May 01, 2015, 05:59:36 pm
content: This fanless 2ghz quad-core mini ITX comes with cpu, consumes 10watts, uses cheap laptop DDR-3, has 2 NIC's, USB-3, and costs $97No need for hdd or CD's with Smoothwall Express 3.1 (it can install from USB to USB and boot its hard-as-nails firewall/squid from that).http://www.gigabyte.com/products/product-page.aspx?pid=4918http://sourceforge.net/projects/smoothwall/files/SmoothWall/http://www.newegg.com/Product/Product.aspx?Item=N82E16813128698Note: For really good security, flexibility and performance, always separate the router function from the wifi AP. Dime-box router/AP's usually get less than 36 months of firmware support from the manufacturer.

author: ConKbot
author_rank: Super Contributor
timestamp: May 01, 2015, 06:14:21 pm
content: I'd have to ask what your end goal was? Do you want something functional for cheap? Learn about programming? learn about networking? Jumping right to execution aka "I want to do x with y, and I have no other details figured out" isnt the right way to problem solve, and will give you tunnel vision blocking you from seeing other possible solutions.

author: sam1275
author_rank: Frequent Contributor
timestamp: May 02, 2015, 03:02:19 am
content: Thank you everyone, seems like you all don't like the idea to have a PI router... Maybe I'll think another solution...One last question... Can I bridge two network on a single interface?

author: Monkeh
author_rank: Super Contributor
timestamp: May 02, 2015, 03:17:09 am
content: Quote from: sam1275 on May 02, 2015, 03:02:19 amWith VLANs, yes. Without VLANs, no. If you don't know if you have VLAN capability, you don't.

author: sam1275
author_rank: Frequent Contributor
timestamp: May 02, 2015, 04:12:35 am
content: Quote from: Monkeh on May 02, 2015, 03:17:09 amThank you.

author: amyk
author_rank: Super Contributor
timestamp: May 02, 2015, 04:48:02 am
content: Do you even know what a router is? Otherwise your question is sort of like "I bought a multimeter, can I use it as a pipe wrench?"Read more about what routers are, before deciding to make one.

author: Howardlong
author_rank: Super Contributor
timestamp: May 02, 2015, 05:45:40 am
content: Quote from: Monkeh on May 02, 2015, 03:17:09 amTo be a pedant about this, technically you can route wirhout VLANs over a single interface, but probably wouldn't want to, as you're in danger of ending up with two DHCP servers present on a single LAN segment assuming the OP is trying to use it as an internet router connecting to a cable or DSL modem. I used to use this method extensively to simulate WAN latency using FreeBSD and Dummynet for perf testing those crappy applications some high-level software-only guys often write without considering such things as application turning.

author: yash101
author_rank: Contributor
timestamp: May 02, 2015, 06:11:17 am
content: Routers are designed to, well, route. They have really powerful DSPs, something that is just absent on the Pi. Being a long time low-level programmer, I know that it is a BAD idea to perform continuous loads such as signal processing on the applications processor. In an ideal condition, you would have some sort of FPGA or similar device controlling the network. The CPU would really just be a front end.This is the main reason why every computer has a GPU. Surely, you can render on your CPU but it is horribly inefficient, unreliable and just a bad idea.I'm sure that some microcontrollers with built-in DSP hardware might be able to beat the RasPi in performance in continuous signal processing loads, like voice recognition. Of course, I've never used one of these chips so I'm no expert.Basically, avoid the CPU whenever possible. It's so general purpose that it's slow. While an FPGA can be similar, the way how it works makes it ideal for the workload. FPGAs can typically take a continuous load with a high efficiency and high stability. A 10MHz FPGA would probably beat a RasPi for a router.

author: Howardlong
author_rank: Super Contributor
timestamp: May 02, 2015, 06:35:18 am
content: Quote from: yash101 on May 02, 2015, 06:11:17 amNot sure how a DSP would particularly help in routing? DSPs are for signal processing close to the analogue domain, not for shifting around and filtering packets of data.

author: rolfe
author_rank: Newbie
timestamp: May 02, 2015, 06:49:47 am
content: If you want to roll your own home firewall/router on a Pi-like device, you might consider using a Banana Pi:http://www.bananapi.com/index.php/component/content/article?layout=edit&id=59It's got 4 LAN + 1 WAN port, driven by a dedicated BCM53125 ethernet switch, plus support for WiFi. It runs a variation of Raspbian (naturally called Bananian), so if you are familiar with a Pi there'll be no surprises.I prefer to use iptables directly for setting up a firewall, so this was a good match for me.Rolfe

author: smjcuk
author_rank: Frequent Contributor
timestamp: May 02, 2015, 09:52:22 am
content: Quote from: Howardlong on May 02, 2015, 05:45:40 amSounds like you work where I do. Sure we can shift 2mbytes of JavaScript to 50 people on IE8 running on an overloaded Citrix box...ugh.

author: eldon
author_rank: Newbie
timestamp: May 02, 2015, 10:08:40 am
content: Quote from: rolfe on May 02, 2015, 06:49:47 amquite interesting i missed that version of bananapi, still a bit on the higher prices end, but plenty of hardware to play with.i've been using a similar A20 based board (cpu/sata wise only), Pcduino 3 nano :http://www.linksprite.com/?page_id=815Not for routing purposes, mostly nas / nzb / torrent box.- a few comments :the A20 cpu is not very powerful either, compared to RPI's cpu.For example on my pcduino, i use vpn for my torrent client and the cpu load can go pretty high with heavy network loads.At some point it will cap the vpn speed (around 100Mpbs).That board doesn't have a dedicated network chip, only a transceiver chip, and the A20 "Gigabit" ethernet actually only goes up to 400-500Mbps (does it also use an internal usb link?)..I don't know if it's used at all on that Bananapi board but then it would probably face the same speed limitation.I have also had some sata problems on my A20 board, i'm not sure it's a A20 hardware bug or a bad design of the pcduino board but i wouldn't call the sata part "stable"..I must say i'm not a big fan of the A20, there are much more powerful arm chips available now, it will be fine for basic routing and "home" lan services (nas, low speed usenet/torrent).But if you plan on getting the full gigabit out of it, especially to/from its sata hdd, i'm not sure you'll be satisfied with the end result.Well for strictly simple limited network projects, i've used several of those boards Gl.INET (basically an upgraded TL-WR703N) with openwrt and they work fine, of course no cpu power whatsoever, no "out of the box wan" feature but can be implemented with iptables.http://www.dx.com/nl/p/gl-inet-6416a-micro-usb-powered-smart-router-w-16m-rom-white-335418

author: Cliff Matthews
author_rank: Unknown
timestamp: May 02, 2015, 11:53:56 am
content: Quote from: yash101 on May 02, 2015, 06:11:17 amI think you were referring to ASIC's not Digital Signal Processors (eg: used in DSL modems and voice/video devices).ASIC's haven't had much use in entry-level routers for many years.

author: Howardlong
author_rank: Super Contributor
timestamp: May 02, 2015, 01:05:32 pm
content: Quote from: smjcuk on May 02, 2015, 09:52:22 amThat sort of thing was my main work until a few years ago when I switched back into doing electronics mostly.

author: GoneTomorrow
author_rank: Regular Contributor
timestamp: May 02, 2015, 01:42:51 pm
content: A first gen Pi will be a horrid router. There's no way you'll be able to route anywhere close to 30Mbit/s, especially at smaller packet sizes.

author: amyk
author_rank: Super Contributor
timestamp: May 02, 2015, 02:08:49 pm
content: Quote from: eldon on May 02, 2015, 10:08:40 amIt's integrated into the SoC and memory-mapped onto the CPU (AMBA) bus, which means that it is theoretically the best you can get for general-purpose CPU-based routing.

author: codeboy2k
author_rank: Super Contributor
timestamp: May 02, 2015, 02:21:27 pm
content: The answer is yes, it can be done, but NO! the Pi will not make a good router. Just use a dedicated router as a router.. don't buy a fanless $99 motherboard, good God !These days, everyone is throwing away routers, you can have them from your local used-sales board (i.e. craigslist) for about $10.

author: sam1275
author_rank: Frequent Contributor
timestamp: May 02, 2015, 02:31:28 pm
content: Thank you everyone!I just picked up a dedicated router.

author: eas
author_rank: Frequent Contributor
timestamp: May 03, 2015, 01:07:29 am
content: Quote from: yash101 on May 02, 2015, 06:11:17 amPurpose-built network devices these days have ASICs, is that what you mean? DSPs, I doubt, FPGAs, maybe but power consumption will be worse than an ASIC.Many, if not most SOHO routers in the last 10 years have an ASIC for the LAN ports that includes switching functionality. Newer 802.11ac SOHO routers probably have hardware accelerated routing too (unfortunately not supported in open source firmwares, last I checked). Without the routing hardware, a router like the WNDR3700 can do maybe ~350Mbps. Not great, but not bad for a ~700MHz MIPS CPU. Of course, even though it lacks hardware routing acceleration, it does have two gigabit MACs on the chip.

author: eas
author_rank: Frequent Contributor
timestamp: May 03, 2015, 01:32:42 am
content: Quote from: amyk on May 02, 2015, 02:08:49 pmI don't know about the A20, but the designers of the iMX6 made some decisions that limit its GigE throughput to ~470Mbps. So, integration into the SoC using a high-speed interconnect isn't a guarantee.

author: Cliff Matthews
author_rank: Unknown
timestamp: May 03, 2015, 10:06:01 am
content: I wouldn't call the 4+1 port switch chip an ASIC, I'd consider it more like a peripheral device (way back in school we never thought a 6850 or 6821 was an ASIC).

author: matts-uk
author_rank: Contributor
timestamp: May 03, 2015, 03:19:40 pm
content: Quote from: Howardlong on May 02, 2015, 05:45:40 amIf you want to be a pedant, I am not so sure you can. A VLAN is an L2 switching operation. Dummynet is an L7 application. Neither is routing, because 'routing' is an L3 operation.Logically speaking a 'router' operates at L3, forwarding packets from one broadcast domain to another. Electrically speaking at L1, a broadcast domain is synonymous with a coax segment. The advent of UTP saw the broadcast domain collapsed into hubs at L1 and eventually virtualised, with the emergence of L2 and L3 switching.When NAT came along, it convinced me not to be a pedant

author: Howardlong
author_rank: Super Contributor
timestamp: May 03, 2015, 10:46:02 pm
content: Quote from: matts-uk on May 03, 2015, 03:19:40 pmYou absolutelycanroute through a single interface without VLANs. I am not recommending it unless you know what you are doing and know the limitations and what you're trying to achieve. Ten or fifteen years ago it was a fairly common practice.

author: matts-uk
author_rank: Contributor
timestamp: May 04, 2015, 09:16:24 am
content: Quote from: Howardlong on May 03, 2015, 10:46:02 pmNote my use of quote marks and remember, you wanted to be pedantic.What I am saying is, the term 'routing' refers very specifically, to the forwarding of packets between (what were) electrically separated broadcast domains, carried out logically at Layer 3.Retransmission on a single interface may have the appearance of routing but it can not be 'routing.' Because the term 'routing' infers moving packets between multiple interfaces.QuoteI've worked in data networking a little longer than that. The terminology started to get bastardised ~Y2K, when the need to have formal qualifications before being let anywhere near the comms rack, went into decline.

author: Howardlong
author_rank: Super Contributor
timestamp: May 04, 2015, 10:24:02 am
content: This is probably not going to get us very far, to me routing is the movement of traffic between two networks. The broadcast domain is indeed a problem on a single interface, that is why I mentioned the DHCP problem that would typically occur in the OP's use case, but I wouldn't use segregated broadcast domains as a definition for a router function.If those networks happen to be on the same physical interface, then so be it, but you can still move traffic between two networks on that single interface.If your definition is that a router has to have separate broadcast domains on each interface then we'll have to agree to disagree, but this is detail and is not going to help the OP, and neither of us recommend routing (or should I say movement of traffic) over a single interface anyway.Regarding Y2K I agree that there were an awful lot of people jumping on the bandwagon at that time. Management mentality was to throw people at the problem, but I guess they never read about the mythical man month. Some of those people had done only a six week computer course and were contracting on outrageous money. I would regularly get people thrown at me, but to get an individual adding any value would take weeks of my time when I wouldn't be getting on with the job at hand, all very depressing it was too.

author: yash101
author_rank: Contributor
timestamp: May 04, 2015, 02:35:26 pm
content: Quote from: eas on May 03, 2015, 01:07:29 amI'm sure that's correct! The last router I took apart was a really old and really crappy DLink. It had a handful of ASICs as well as some sort of MIPS/ARM processor. I was 7 when I took it apart so I don't remember all the details.

author: madires
author_rank: Super Contributor
timestamp: May 04, 2015, 03:39:57 pm
content: Quote from: yash101 on May 04, 2015, 02:35:26 pmThere are two basic designs regarding the ethernet ports. If the CPU supports just a single ethernet the firmware puts LAN and WAN into two VLANs and the ethernet switch chip provides 4 LAN ports plus 1 WAN port. Since all routed traffic has to pass the single ethernet link between CPU and switch chip twice, it's a bottleneck. The other case is a CPU with two ethernet links, one for WAN and the second one for the LAN ports, i.e. switch chip. If the CPU has any hardware acceleration built in, it's mostly just for NAT. From the numbers I've seen, hardware NAT gives you about 2 times the throughput.

author: Cliff Matthews
author_rank: Unknown
timestamp: May 04, 2015, 04:37:04 pm
content: There's a general rule: if a part can be looked-up, it's not an ASIC it's likely an ASSP. (maybe things have changed... I can't keep up)http://www.eetimes.com/author.asp?section_id=36&doc_id=1322856Here's a good ASSP candidate, a 5-port switch with phy interface:https://www.broadcom.com/products/BCM5385