-
1Prerequisites
Prerequisites
For flashing the image onto the SD card I have used BalenaEtcher
- Download the raspbian lite
iso
file from the Raspberry Pi website - Once downloaded, open BalenaEtcher, select the
.iso
file, select the SD card and click the flash button and wait for the process to finish. - Then, open the boot partition and inside it, create a blank text file named
ssh
with no extension. - Finally, create another text file called
wpa_supplicant.conf
in the sameboot
partition and paste the following content.ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev update_config=1 country=IN network={ ssid="mywifissid" psk="mywifipassword" key_mgmt=WPA-PSK }
Replace the mywifissid with the name of the WiFi and mywifipassword with the wifi password.
- Power on the Raspberry pi. To find its IP, you can use a tool like Angry IP Scanner and scan the subnet,
- Once you find the IP, SSH to your Pi using a tool like PuTTY or just
ssh pi@raspberrypi.local
, enter the passwordraspberry
and you are good to go. - Finally, update the package list and upgrade the packages and reboot Pi.
sudo apt update -y sudo apt upgrade -y sudo reboot
- Download the raspbian lite
-
2Setting up systemd-networkd
From ArchWiki
systemd-networkd is a system daemon that manages network configurations. It detects and configures network devices as they appear; it can also create virtual network devices.
To minimize the need for additional packages,
networkd
is used since it is already built into theinit
system, therefore, no need fordhcpcd
.- Prevent the use of dhcpd
sudo systemctl mask networking.service dhcpcd.service sudo mv /etc/network/interfaces /etc/network/interfaces~ sed -i '1i resolvconf=NO' /etc/resolvconf.conf
- Use the inbuilt systemd-networkd
sudo systemctl enable systemd-networkd.service systemd-resolved.service sudo ln -sf /run/systemd/resolve/resolv.conf /etc/resolv.conf
-
3Configuring wpa-supplicant
wlan0 as AP
- Create a new file using the command.
sudo nano /etc/wpa_supplicant/wpa_supplicant-wlan0.conf
- Add the following content and save the file by pressing CtrlX, Y and Enter
country=IN ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev update_config=1 network={ ssid="TestAP-plus" mode=2 key_mgmt=WPA-PSK psk="12345678" frequency=2412 }
Replace the TestAP-plus and 12345678 with your desired values.
This configuration file is to be used for the onboard wifi Adapter
wlan0
which will be used to create a wireless access point.- Give the user read, write permissions to the file
sudo chmod 600 /etc/wpa_supplicant/wpa_supplicant-wlan0.conf
- Restart
wpa_supplicant
service
sudo systemctl disable wpa_supplicant.service sudo systemctl enable wpa_supplicant@wlan0.service
-
4Step 4
wlan1 as client
- Create a new file using the command.
sudo nano /etc/wpa_supplicant/wpa_supplicant-wlan1.conf
- Add the following content and save the file by pressing CtrlX, Yand Enter
country=IN ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev update_config=1 network={ ssid="Asus RT-AC5300" psk="12345678" }
Replace the Asus RT-AC5300 and 12345678 with your Router SSID and password.
This configuration file is to be used for the USB WiFi Adapter
wlan01
which will be used to connect to a Wireless Router.- Give the user read, write permissions to the file
sudo chmod 600 /etc/wpa_supplicant/wpa_supplicant-wlan1.conf
- Restart
wpa_supplicant
service
sudo systemctl disable wpa_supplicant.service sudo systemctl enable wpa_supplicant@wlan1.service
-
5Configuring Interfaces
- Create a new file using the command.
sudo nano /etc/systemd/network/08-wlan0.network
- Add the following content and save the file by pressing CtrlX, Yand Enter
[Match] Name=wlan0 [Network] Address=192.168.7.1/24 IPMasquerade=yes IPForward=yes DHCPServer=yes [DHCPServer] DNS=1.1.1.1
- Create a new file using the command.
sudo nano /etc/systemd/network/12-wlan1.network
- Add the following content and save the file by pressing CtrlX, Yand Enter
[Match] Name=wlan1 [Network] DHCP=yes
- Reboot the Raspberry Pi using
sudo reboot
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.
Hey, thanks for the great tutorial! It works perfectly with Wifi to Wifi on my Rpi 3 too!
I need your help though, when I connected an ethernet cable to the Pi in order to use it as a regular TV box, it doesn't seem to have a connection after this setup. How should I set up the eth0 to be isolated from the Bridge/AP pair and just act like a normal internet connection where I can stream/ssh into the pi etc?
Thank you!
Are you sure? yes | no
Thanks Tejas worked out of the box on a Raspberry Pi Zero W. Zero has the builtin wifi and using a USB wifi adapter bought from ThePIHut. So it works fine as such but the speed drops to less than a fifth of what the router that it's connected to can do. Is this due to performance of Raspberi PI Zero W or something else?
Are you sure? yes | no
I got it running on an old rpi2 using dietPi on a 2gb sd card. using 2 usb-wlan interfaces. just made some slight modifications to get it pointing at the right interface.
Found this guide simpler that what I used previously including hostapd and stuff.
The signal improvement was great but the speed dropped quite a bit, but considering quite old hardware both the rpi and the interfaces it's still a success i think.
Thx!
Are you sure? yes | no
I attempted this project on a RPi Model 3B+ and did not get the wlan0 access point to function. It appears that a DHCP server is required but not installed in the project. Any suggestions?
Are you sure? yes | no
I added a couple of videos today on youtube(links in this post too), please check them out
Are you sure? yes | no
This works great on my Raspberry Pi 3. Thanks so much! I've tried it per your instructions, and also reversed it with my external wifi dongle acting as the AP. Both ways worked fine. I may try with 2 external dongles as the built-in wifi on my Pi3 isn't that great.
Is there a way to have it use WPA2 rather than WPA security?
Are you sure? yes | no
you might need to have a look at their man page. They have couple of examples listed.
Are you sure? yes | no
Well, it didn't. I don't have exactly the same hardware, and to be fair, I don't really understand networking details. But this is good inspiration and a starting point to turn my old wireless router into a wifi extender. Thanks.
Are you sure? yes | no
That is nice :)
Are you sure? yes | no
Thanks for the inspiration. I have a spare Z and now need a wifi extender. Giving it a shot.
By the way, you probably want to change your country=IN to be your country code unless you happen to live in india.
We'll see if this works...
Are you sure? yes | no
Yes. You would have to change it according to your location.
Are you sure? yes | no