0

I have a Raspberry Pi Zero W V1.1, SD Ultra 32GB card with 2018-04-18-raspbian-stretch.img installed. A USB powered hub (with its own 5V 2A power supply) is connected to the Pi Zero W via an OTG USB cable.

I connected a Huawei E3272 USB modem to the USB hub and through it I am able to connect the Pi Zero W to the Internet. The Pi Zero W wireless is OFF.

I then connected an RD9700 (a.k.a DM9601) type USB 2.0 Ethernet adapter to the USB hub. Using an Ethernet cable, I connected a DD-WRT wireless router to the Pi0w via the Ethernet adapter. This was done using one of the LAN Ethernet ports (not the WLAN port) on the router. I was then able to access the router's HTML GUI on the Pi Zero W.

I had previously checked that the router's WLAN port was working by trying it with another modem.

With the USB modem, Ethernet adapter, and router all communicating with the Pi Zero W, I then switched the Ethernet cable from the router's LAN port to the router's WLAN (Internet) port, hoping the Pi Zero W would feed its Internet connection to the router.

Alas, no Internet from the Pi Zero W to the router.

In effect, I want to set up the Pi Zero W as a WiFi hot-spot that also allows Ethernet connection to the Internet. How do I get the Pi Zero W to feed its Internet access to the router via the Ethernet cable?

  • I have made an answer. Tell me if there are some trouble. – Ingo Jun 11 '18 at 17:02
0

This suggestion is deprecated!

Please use Setting up a Raspberry Pi as an access point - the easy way section Setting up an access point with a bridge.


You can use a bridge between the access point and the ethernet interface. I assume you have an interface eth0 from the ethernet port to your internet router and an interface wlan0 from your USB wifi adapter for the access point and you can get into the internet and that there is a DHCP server. To create an access point you need the software package hostapd. Here is a solution with systemd-networkd. With this we also need a special virtual interface that I call uap0. For reference I use Raspian Stretch Lite 2018-04-18.

First install hostapd with helper and stop it:

rpi ~$ sudo -Es
rpi ~# apt update
rpi ~# apt full-upgrade
rpi ~# apt install rng-tools hostapd
rpi ~# systemctl stop hostapd

Then configure it with this file and your settings for ssid=and wpa_passphrase=:

rpi ~# cat > /etc/hostapd/hostapd.conf <<EOF
interface=uap0
driver=nl80211
ssid=RPiNet
hw_mode=g
channel=7
wmm_enabled=0
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=verySecretPassword
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
EOF

rpi ~# chmod 600 /etc/hostapd/hostapd.conf

Edit /etc/default/hostapd, uncomment and change this:

DAEMON_CONF="/etc/hostapd/hostapd.conf"

Disable classic networking and setup systemd-networkd. For more detailed information look at (1), (2). Here only in short.

In /etc/resolvconf.conf insert these lines.

# Set to NO to disable resolvconf from running any subscribers. Defaults to YES.
resolvconf=NO

Then setup this:

rpi ~# mkdir -p /var/log/journal
rpi ~# systemd-tmpfiles --create --prefix /var/log/journal

rpi ~# systemctl disable networking
rpi ~# systemctl disable dhcpcd

rpi ~# systemctl enable systemd-networkd
rpi ~# systemctl enable systemd-resolved
rpi ~# ln -sf /run/systemd/resolve/resolv.conf /etc/resolv.conf

Create these files for the bridge br0 and interfaces eth0 and uap0:

rpi ~# cat > /etc/systemd/network/02-br0.netdev <<EOF
[NetDev]
Name=br0
Kind=bridge
EOF

rpi ~# cat > /etc/systemd/network/04-br0_add-eth0.network <<EOF
[Match]
Name=eth0
[Network]
Bridge=br0
EOF

rpi ~# cat > /etc/systemd/network/08-br0_add-uap0.network <<EOF
[Match]
Name=uap0
[Network]
Bridge=br0
EOF

rpi ~# cat > /etc/systemd/network/16-br0_up.network <<EOF
[Match]
Name=br0
[Network]
DHCP=ipv4
EOF

Create the virtual interface uap0 for the access point. We will do it with the hostapd unit but it must be present before hostapd starts, of course. We do it with a drop in file (3) so we do not have to touch the hostapd unit. Open the drop in file with:

rpi ~# systemctl edit hostapd.service

In the empty editor insert these statements, save it and quit the editor:

[Service]
ExecStartPre=/sbin/iw phy phy0 interface add uap0 type __ap

Check with systemctl cat hostapd.service and/or systemctl status hostapd.service.

Reboot.

The interface wlan0 is used for a client connection to an access point. But here we do not have a client. So wlan0 is not used and should have state DOWN. Check with ip addr.

Now your devices connected to the access point are also transparent connected to your internet router. They will get an ip address from the dhcp server (if there is one) and they can get into the internet.


references:
[1] Howto migrate from networking to systemd-networkd with dynamic failover
[2] RPI Station+AP with ap0 bridged to eth0
[3] man systemd.unit

  • Ingo, thank you for your answer. I am now overseas and will be back home in late June. I will then try what you have suggested. – rbscebu Jun 15 '18 at 2:47

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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