Turn a Raspberry Pi into a router
Required: You must have a Raspberry Pi with a minimum of 2 physical network ports.
- These scripts are tested work on a Raspberry Pi 4 and Raspberry Pi 3 with a canakit WiFi dongle.
- These scripts are tested with Raspberry Pi OS Lite (32 Bit) - see Raspberry Pi OS Setup for more
- These scripts will will only setup the router to use
eth0as the shared interface andwlan0as the router interface.- you can change this in the
/etc/hostapd/hostapd.conffile. - plans to make the interface configurable are a work in progress
- you can change this in the
- These scripts will use:
- Router IPv4
192.168.1.1 - Router NAT Subnet
192.168.1.0/24 - Router IPv6 lab network
2001:db8::/64 - SSID "Spectrum Mobile"
- WPA2 passphase "spectrum"
- Router IPv4
There is a scripts/install.sh script that will install all the needed tools, once you have a fresh install of Raspberry Pi OS
- install
gitonto the Raspberry Pi
sudo apt-get update
sudo apt-get install git -y
- clone this repository
git clone https://github.com/popmedic/pi-router.git
- change into the
pi-routerdirectory
cd pi-router
- run the install
sh scripts/install.sh
To start your Raspberry Pi as a router, you can run the start.sh script
- make sure you are in the directory you cloned the project into
- run the start script
sh scripts/start.sh
To stop using the Raspberry Pi as a router
- make sure you are in the directory you cloned the project into
- run the stop script
sh scripts/stop.sh
NOTE: the stop will tear down all the network interfaces, including your
eth0interface. To start it back up you can use:
sudo ifup eth0
To restart using the Raspberry Pi as a router (when the pi is a router)
- make sure you are in the directory you cloned the project into
- run the restart script
sh scripts/restart.sh
There are plenty of great tutorials on this. Here is how I am setting up my Raspberry Pi OS Lite (32-bit)
- Download Raspberry Pi Imager
- Install the Imager
- Run the Imager
- Select Raspberry Pi OS Lite (32-bit) for the Operating System
- Choose the media you would like to burn onto
- Click WRITE button
NOTE: The default username is
pithe default password israspberry
NOTE: you might want to select the correct keyboard for the US.