I am trying to use Raspberry Pi as hotspot device. I am following this documentation: https://www.raspberrypi.org/documentation/configuration/wireless/access-point.md

I am not using ethernet eth0 to access the internet on the raspberry device. I am using wlan0 to access the internet. I have a USB wifi dongle and I want to use it for this purpose.

What changes I should do in the configuration as described in this documentation to achieve this? The output of my ip addr command is like:

ip addr

1. lo: ....
2. eth0: <NO-CARRIER,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether xx:xx:xx:xx:xx:xx brd ff:ff:ff:ff:ff:ff
3. wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether xx:xx:xx:xx:xx brd ff:ff:ff:ff:ff:ff
    inet xxx.xxx.xx.xxx/20 brd xxx.xxx.xx.xxx scope global wlan0
       valid_lft forever preferred_lft forever
    inet6 xxxx::xxx:xxxx:xxxx:xxxx/64 scope link 
       valid_lft forever preferred_lft forever

I want to add wlan1 where I will use the USB dongle to work as access point. How can I achieve this?

  • You asked what changes you should do in the configuration as described in the documentation. I have an alternative but simpler solution with systemd-networkd. Would this also be a solution?
    – Ingo
    Aug 13, 2019 at 8:31

1 Answer 1


The documentation you are referring to is a nicely written howto, I have used this approach many times and it works well.

If you have wlan0 configured as a WiFi client to access the Internet, and use wlan1 as your access point interface, you basically just replace every wlan0 in the document by wlan1, and every eth0 by wlan0.

Make sure wlan1 gets the static IP in /etc/dhcpcd.conf:

interface wlan1
    static ip_address=
    nohook wpa_supplicant

And the DHCP service in /etc/dnsmasq.conf:


And have hostapd listen on the right interface in /etc/hostapd/hostapd.conf:

... etc ...

You can read on all the hostapd configuration options at kernel.org.

Then, set the masquerading up on your Internet interface:

sudo iptables -t nat -A  POSTROUTING -o wlan0 -j MASQUERADE

Make sure all services are started on boot and the masquerading rule is loaded. You can verify that by running

sudo iptables-save

Check if IP4 forwarding is enabled, you should see a 1 when doing:

sudo cat /proc/sys/net/ipv4/ip_forward

One other helpful thing I learned from a post on the raspberrypi.org forum (Thank you chispitas). Sometimes your USB dongles get renamed to something you don't expect. Adding this to a file /etc/udev/rules.d/72-wlan-geo-dependent.rules gives you predictable naming based on where you plug in your dongle:

# +---------------+
# | wlan1 | wlan2 |
# +-------+-------+
# | wlan3 | wlan4 |
# +---------------+ (RPI USB ports with position dependent device names for up to 4 optional wifi dongles)
# | wlan0 | (onboard wifi)
ACTION=="add", SUBSYSTEM=="net", SUBSYSTEMS=="sdio", KERNELS=="mmc1:0001:1", NAME="wlan0"
ACTION=="add", SUBSYSTEM=="net", SUBSYSTEMS=="usb",  KERNELS=="1-1.2",       NAME="wlan1"
ACTION=="add", SUBSYSTEM=="net", SUBSYSTEMS=="usb",  KERNELS=="1-1.4",       NAME="wlan2"
ACTION=="add", SUBSYSTEM=="net", SUBSYSTEMS=="usb",  KERNELS=="1-1.3",       NAME="wlan3"
ACTION=="add", SUBSYSTEM=="net", SUBSYSTEMS=="usb",  KERNELS=="1-1.5",       NAME="wlan4"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.