Creating Wireless Router using Raspberry Pi Zero W

This post shows steps to set up Raspberry Pi Zero W as a wireless router.
I tested it with Raspbian Stretch Lite (November 2017 version) and this USB WiFi adapter.

The figure above shows overview of the idea. Here are some assumptions for this post.

  • Raspberry Pi Zero W (the router) connects to an existing WiFi network (i.e. hotspot/access point) for Internet access via the on-board WiFi adapter.
  • The router creates a private WiFi network ( using a USB WiFi adapter.
  • The IP address of the interface for the private network is set to
  • The IP address range for the private network is from to
  • A device connected to the private network can access the Internet through the router.

Here is the list of contents of this post.

– Prerequisites
– Steps
1. Package installation
2. Wireless interface names
3. Assigning a static IP address for USB WiFi adapter (wlan1)
4. DHCP server setting
5. Access point setting
6. Enabling traffic forwarding
7. Forwarding rule configuration
8. Connecting to existing WiFi network (If it’s not connected yet)
9. Test
– Reference




1. Package installation

1-1. As always, update the package list and upgrade the installed software first.

1-2. Install ‘hostapd’ and ‘dnsmasq’.


2. Wireless interface names
Before starting work on the configurations, check the interface names for the on-board WiFi and WiFi adapter. Those names will be used later.

2-1. Run ‘ifconfig’ command without connecting the WiFi adapter.

You should be able to see “wlan0”. It’s the interface name for the on-board WiFi adapter.

2-2. Then, connect the WiFi adapter and run the same command. This time you’ll notice that “wlan1” is added. It’s the name for newly connected USB WiFi adapter.  So, now we know the interface names:

wlan0 : on-board WiFi
wlan1 : WiFi adapter


3. Assigning a static IP address for USB WiFi adapter (wlan1)
3-1. Open /etc/dhcpcd.conf

3-2. Copy below at the end of the file.

after reboot, wlan1 should look like this:


4. DHCP server setting
As suggested in [1], rename the original configuration file and create a new file from the scratch.

4-1. Rename the original file.

4-2. Create a new file.

4-3. Copy lines below, save and close the file.


5. Access point setting
5-1. Create the configuration file.

5-2. Copy the lines below, save and close the file. Replace <NETWORK_NAME> and <PASSWORD> with whatever you want.

5-3. Specify the location of the configuration file. To do that, first open /etc/default/hostapd

5-4. Then, add the line below, save and close the file.


6. Enabling traffic forwarding
6-1. Open the configuration file.

6-2. Look for the line below.

6-3. Uncomment the line. Now, it should be like:


7. Forwarding rule configuration
7-1. Run these command:

7-2. Backup the configuration.

7-3. In order to load the rules on boot, open /etc/rc.local,

7-4. Then add the line below above “exit 0”.


8. Connecting to existing WiFi network (If it’s not connected yet)
8-1. Open /etc/wpa_supplicant/wpa_supplicant.conf

8-2. Add lines below at the end of the file. Replace <NETWORK_NAME> and <PASSWORD> to appropriate strings for your WiFi network for Internet access.


9. Test
9-1. Reboot the board.

9-2. Search the WiFi network configured in step 5-2 from a WiFi enabled device (e.g. PC, phone) and connect to it. After connected, you should be able to access the Internet from the device.


[1] How to use your Raspberry Pi as a, says “” wireless access point
[2] Internet sharing – Arch Linux
[3] How-To: Turn a Raspberry Pi into a WiFi router
[4] What is the difference between -m conntrack –ctstate and -m state –state



Sponsor Link


  1. I purchased this Wifi adapter for a Dell 17R laptop that we purchased in late 2011. The built in Intel adapter was working fine but typically attached at 72 Mbps at best. Since I was in the process of also updating our router to one capable of 802.11ac I was looking for some way to upgrade our laptop. Even though there is an internal option in an Intel upgraded card I checked the process to get to the card and i decided to hold on off on that option. When I installed this EDUP adapter along with the driver shipped on a mini CD it did not work well and was unstable. Before sending it back I contacted EDUP support via email and they were very helpful and quick to reply. They sent me the link to the updated driver and gave me some other excellent recommendations on improving the performance. After installing the driver and implementing the other changes the EDUP connected at 150 Mbps on my old router and was very stable. Then I received my new ac capable router and installed it and wow what a difference. Now the EDUP is consistently running at 433 Mbps. Thanks to EDUP for an affordable well made adapter and excellent customer service.

Leave a Reply

Your email address will not be published. Required fields are marked *