Use Raspberry Pi 3 As Router




Introduction: Use Raspberry Pi 3 As Router

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.



    • Creative Misuse Contest

      Creative Misuse Contest
    • Fix It! Contest

      Fix It! Contest
    • Tiny Home Contest

      Tiny Home Contest

    6 Discussions

    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 ?

    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!

    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


    How do I keep unwanted users from hacking into this router network?

    1 reply

    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.

    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.