Use Raspberry Pi 3 As Router




About: Check out my YouTube channel, for similar projects.

According to Wikipedia, a router is a networking device that forwards data packets between computer networks. If we tear-down a wireless router, we will probably find an application specific processor that handles data packets and an RF segment that handles wireless connectivity.

You know what else has a processor and an RF segment.

THAT'S RIGHT a raspberry pi model 3. So in this miniProject, we will convert a raspberry pi to act as a router.

Step 1: Video

Take a look at video for quick comprehensive guide in 3 mins.

Step 2: Boot-up Raspberry Pi.

First step is to get your raspberry pi up and running. Official getting started guide on Raspberry pi website is best resource for this.

Here is the link.

Go to next step once you have your raspberry pi up and running.

Step 3: Upgrading Raspberry Pi

First we will update package list available from repositories using

sudo apt-get update 

Once done, we can install these latest packages using

sudo apt-get upgrade

This might take a while depending on your internet connection speed.

Step 4: Installing Hostadp and Bridge-utils

Once raspberry pi is upgraded.

we need to install a user space background process called hostapd, used for wireless access points and authentication servers. We will also need a package called bridge-utils to manage bridge devices.

sudo apt-get install hostapd bridge-utils

We need to turn off some of the new services that we just installed do it using

sudo systemctl stop hostapd

Debug- Some times raspbian will display message saying hostapd and bridge-utils not found for install command. Do not worry. Run 'sudo apt-get update' once more and it should get resolved.

Step 5: Disable DHCP Config for Wlan0 and Eth0

Now, we set dhcp background process not to automatically configure wlan0 and eth0 interfaces. We do this by putting following two lines

denyinterfaces wlan0
denyinterfaces eth0

at the end of /etc/dhcpcd.conf file, open it using.

sudo nano /etc/dhcpcd.conf

Step 6: Creating Bridge Br0

Next, we create a bridge br0 using brctl command which is an Ethernet bridge administrator

sudo brctl addbr br0

and using

sudo brctl addif br0 eth0

command we add eth0 as one of the ports for bridge br0.

Step 7: Edit /etc/network/interfaces

Now open up a file called interfaces in /etc/network directory

sudo nano /etc/network/interfaces

and add these five lines.

allow-hotplug wlan0
iface wlan0 inet manual

auto br0
iface br0 inet dhcp
bridge_ports eth0 wlan0

First line starts wlan0 interface on a hotplug event. Second line creates a network interface without an IP address which is normally done for bridge elements. Third line starts br0 interface on boot up. Forth line helps in automatic assignment of IP address to br0 interface using DHCP server and finally fifth line connects eth0 interface with wlan0. Save this file and close it.

Step 8: Edit /etc/hostapd/hostapd.conf

Next, we will configure our wireless access point, we can do this using a file called hostapd.conf in /etc/hostapd folder. Open it up

sudo nano /etc/hostapd/hostapd.conf

and paste these lines.


Value assigned to ssid is the name that access point will use to broadcast its existence. Last five lines are focused on authentication and security of access point. Value of wpa_passsphrase is used as login password which is subscribe in our case. This is a link to document, where you can find definition of each variable that we have used here.

Step 9: Final Edit /etc/default/hostapd

Finally, open up hostapd file in /etc/default directory

sudo nano /etc/default/hostapd

uncomment DAEMON_CONF line and provide path to file we just created.


This completes setup for raspberry pi to act as router.

Step 10: Done

Now, power-on your raspberry pi with Ethernet cable connected.

You should see raspberry pi broadcasting ssid and access internet.

Thanks for reading.

Let me know if you face any issue while creating your own router.

Please vote for this instructable, if you liked it.



    • First Time Author

      First Time Author
    • Big and Small Contest

      Big and Small Contest
    • PCB Contest

      PCB Contest

    18 Discussions


    Answer 4 days ago

    On the device (router, server, etc) you plug in to eth0.

    (This is *bridge*, not router, setup tutorial regardless what the article's title says).


    Question 10 days ago on Step 10

    Can this Instructable work with 1 dongle instead of an ethernet cable? I'm trying to make a Pi Laptop by using a tablet with VNC and connect the tablet to the Pi and use it as a display (I got the tablet for $40).


    Question 23 days ago on Step 10

    Cool instructable, I set everything up and triple checked in case I had any mistakes. It does not work for me, and I was hoping you could point out if I did anything wrong. I put the ethernet cable in and every thing, reset the pi. It shows up on my phone as a connection point, but it tells me I put in the wrong password. I know I'm putting in the right password, I've tried many times. Is there any way to fix this?


    5 weeks ago

    This is awesome, but I was wondering about things: 1.What is the boot up time 2. Instead of re-reouting the data packets, could the input data into audio output? Application would be to stream audio, specially airplay. No single device exist to accomplish this, aside from expensive head units.

    I have been hitting a brick wall wall for the past 2 years in finding a device I can airplay to without using a wifi network or using my phone as a hotspot (kills my battery especially when streaming music). Another huge plus is that there exist quite a few high quality raz pi audio components to get high quality sound.

    I would think the hardest part would just be redirecting input into the open source software, Shairport Sync. If your interested a posted a tutorial for creating ras-pi airplay receiver.

    I'm not sure if one raspberry pi could handle both processes, but if two were needed I suppose I would want to port the wifi pi output via eithernet to the audio processor pi.

    1 reply

    Reply 5 weeks ago

    Hello MatthewD250,
    Bootup time is extremely short. This is part of the basic Linux-settings after all, so it should boot about as fast as linux itself does.

    As far as streaming audio goes - these would still be data packets, right? It would still use TCP/IP to transfer those packets using this setup...

    I'd check if Shairport Sync has some kind of listener you can direct the input towards - that might encode the output in the correct way somehow.

    Let me know if you find something, it sounds really cool if you could pull it off!

    R G L Goldberg

    Question 8 weeks ago on Step 10

    This looks interesting but I have 3 questions. First, will this work with a Raspberry Pi 2? Second, what sort of load does this place on the CPU in the Raspberry Pi (I currently use it as an ancestry database for my wife)? Third, can I specify the source for the DNS?

    The last question is because my ISP force-feeds their DNS to their customers though the routers they provide & I currently have all the computers in the house set to use OpenDNS so my ISP is not always looking over our shoulder.

    1 more answer
    ThomasdudeR G L Goldberg

    Answer 5 weeks ago

    Hello R G L,

    1. If you have a wifi-adapter for your RPi2, it should. Setup might be a bit more complicated though.
    2. Near nothing - or at least very little, unless you connect a bunch of devices on it at the same time (in the order of tens of devices).
    3. No. Your DNS-requests would be forwarded to your current router. There might be a linux-package you could install to avoid this (such as OpenDNS), but I'm not sure on that.

    Hope that helps!


    4 months ago

    Does this setup implies that I could connect Ethernet cable from my PC direct to RPi?

    Bypassing my current router.

    If so how would I get to Internet from either "client" ?

    Utilising my current router wireless hardware ?

    Or is this "bridge" really connecting RPi eth0 to RPi wlan0 keeping current Ethernet connection from Rpi to my router ? Hopefully not messing access to RPi via ssh.

    Since there is only one Ethernet connector on RPI - is this router primary intended to route wireless traffic? ( I do not fancy USB dongles overloading the RPi USB power bus )

    Would network bonding accomplish same ?

    2 replies

    Reply 5 weeks ago

    Hello julyjim!
    Unfortunately, that's not how this type of wireless router *should* work (more on that below).
    If you were to plug in your PC's ethernet cord, you'd simply "input" your current router's wired internet connection. And you'd "output" a wireless network which you could give it's own name and IP adresses and so on.

    At no point would you bypass or workaround your ISP's router.
    All traffic would simply pass this way:
    End device -> RPi router -> current router -> internet
    and the same would happen the other way around.
    This type of setup basically gives you a more sophisticated wireless access point, which allows you to do a bit more technical stuff than an access point would normally allow you to do (creating your own NATted network, for example - which hides the identities of the devices behind it.).

    Now, if you were to plug your current router's "input" into the RPi, it would be a different story.
    I do not advise this, as this will be a very unsafe network, unless you know your way around linux firewalling. You'd also need to know what public IP your provider assigned to your router and so on. Your RPi would replace your current router and connect end devices to the internet directly. Again, I do not recommend this unless you know *exactly* what you're doing.
    Also, your ISP might not like it either...

    As for your other questions: you'd still be able to SSH to your RPi. This setup is intended to be used as wireless only (as Ethernet-port will be your input), and network bonding would not accomplish the same result - as in this setup, both interfaces are still completely seperate, and can be adjusted as seperate entities (which, for example for NATting, is required!).

    I hope this answers your questions somewhat.

    R G L Goldbergjulyjim

    Reply 8 weeks ago

    When the gateway from my ISP died I cobbled together things to get Internet access until a replacement gateway arrived. I was using a DSL modem & a Windows 10 PC (there is a "hotspot" function in Windows.) As you can imagine using a PC to provide Wi-Fi to the house (especially when Windows only allows 8 connections & the PC draws a lot more power than either the gateway or a Raspberry Pi.)

    As it sounds like you have an existing router with multiple Ethernet ports I am a bit curious why you would try to get a Raspberry Pi to function as a router. In my case it is because the LOUSY gateways my ISP provides seem to fail frequently.

    I live in a rural location so I do not have much to worry about with someone trying to hack into my Wi-Fi (that does not mean that I do not monitor the logs for that however.) If you have a fairly secure environment I would recommend considering adding Wi-Fi NIC or dongle to your PCs.

    In my house all the computers have Wi-Fi capability so I am looking at running an Ethernet cable from the DSL modem I have to my Raspberry Pi & connect the computers via the Wi-Fi side of the Raspberry Pi.

    My Raspberry Pi is connected to an HDMI port on the TV in the living room. I use either TeamViewer or a wireless keyboard/mouse to access it. It does SSH (tried it -- did not like it.) I have looked at using Chrome Remote Desktop on my Raspberry Pi but have not been able to get that to work. There are folks in various forums saying it does so I am assuming I have not gotten the correct combination of software parts & pieces at this point.

    R G L Goldbergdug1000

    Reply 8 weeks ago

    There was a flaw discovered in WPA security about a year ago. I do not have any information one way or the other about this design as to whether the code that is being downloaded has a patch for that flaw or not. I live in a rural area so a neighbor hacking in is not an issue as the signals from the the ISP supplied device barely reach the street & I suspect the transmitter in a Raspberry Pi would be even weaker.

    In any event I will be observing the normal basic protections by creating a "burner" email address & having the Raspberry Pi email the logs to me. I will also pull the micro-SD card from time to time & mount it on a Linux desktop so I can check for changes to objects in the file system.

    While I do not expect to find issues I still test for them as I have spent 40 years tying to stay 1 step ahead of students trying to hack into things & have seen some of the strangest attempts by people to get into things they should not.


    Reply 7 months ago

    It has standard WPA authentication to allow make sure that only users with passphrase can access it. Besides this we can use macaddr_acl variable for MAC address based access.


    Tip 3 months ago

    I had a problem with the command
    - sudo brctl addbr br0

    It returned the error

    - sudo brctl addbr br0 add bridge failed: package not installed

    To avoid fix this issue I reinstalled raspian and I did a reboot after step 4

    Hopefully this helps somebody avoid the issue I faced :)


    6 months ago

    I really appreciate your post.. I haven't attempted others, but this seems like a more straightforward approach.

    I have been trying to use my ALFA Wireless 7dB antenna to setup as my broadcasting antenna, but following these instructions (and also following your instructions changing wlan0 to wlan1) does not seem to setup a network to connect to.

    I'm not sure where to start, can you help me please?

    EDIT: am using raspberry pi 2 B+

    EDITEDIT: I got it working!! It seemed hostapd.conf itself did not like to save the first time around!! Unfortunately though, after a restart is has decided to stop broadcasting, and I can no longer connect to the network setup through this tutorial, as in it's no longer visible on any wireless device.

    Running IFCONFIG in terminal, it states br0 is up, broadcast, running, multicast, eth0 up, broadcast, running, multicast, and lo, up,loopback,running, and also wlan0 up,broadcast,multicast.

    I was also having trouble getting it to interface with the modem/router, so that it would grant me internet access. Any help is appreciated!


    7 months ago

    Excellent and well presented. Great start for those wanting to experiment with networking and learn about the need for network security like runnning your own VPN



    7 months ago

    It has standard WPA authentication to allow make sure that only users with passphrase can access it. Besides this we can use macaddr_acl variable for MAC address based access.