Last active
May 12, 2025 04:43
-
-
Save factorin-j/90a015827dc2086a3df8fcec082e7054 to your computer and use it in GitHub Desktop.
RaspberryPi Zero W Bridge usb0 to wlan0 (access point)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ## /home/pi/bridge.sh | |
| #!/usr/bin/env bash | |
| service hostapd stop | |
| service dnsmasq stop | |
| service dhcpcd restart | |
| ifdown wlan0 | |
| ifup wlan0 | |
| sh -c "echo 1 > /proc/sys/net/ipv4/ip_forward" | |
| iptables --flush | |
| iptables --table nat --flush | |
| iptables --delete-chain | |
| iptables --table nat --delete-chain | |
| iptables --table nat --append POSTROUTING --out-interface usb0 -j MASQUERADE | |
| iptables --append FORWARD --in-interface wlan0 -j ACCEPT | |
| service dnsmasq start | |
| service hostapd start |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ## /etc/dhcpcd.conf | |
| denyinterfaces wlan0 | |
| interface usb0 | |
| static ip_address=192.168.2.50/24 | |
| static routers=192.168.2.1 | |
| static domain_name_servers=192.168.2.1 8.8.8.8 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ## /etc/dnsmasq.conf | |
| interface=wlan0 | |
| listen-address=192.168.220.1 | |
| bind-interfaces | |
| server=8.8.8.8 | |
| domain-needed | |
| bogus-priv | |
| dhcp-range=192.168.220.50,192.168.220.150,12h |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ## /etc/default/hostapd | |
| DAEMON_CONF="/etc/hostapd/hostapd.conf" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ## /etc/hostapd/hostapd.conf | |
| interface=wlan0 | |
| driver=nl80211 | |
| ssid=WiFiNameHere | |
| hw_mode=g | |
| channel=6 | |
| macaddr_acl=0 | |
| auth_algs=1 | |
| ignore_broadcast_ssid=0 | |
| wpa=3 | |
| wpa_passphrase=anyPasswordHere | |
| wpa_key_mgmt=WPA-PSK | |
| wpa_pairwise=TKIP | |
| rsn_pairwise=CCMP |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ## /etc/rc.local | |
| /bin/bash /home/pi/bridge.sh |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ## /etc/network/interfaces.d/wlan0 | |
| allow-hotplug wlan0 | |
| iface wlan0 inet static | |
| address 192.168.220.1 | |
| netmask 255.255.255.0 | |
| network 192.168.220.0 | |
| broadcast 192.168.220.255 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi John Marlo,
Did you get a raspberry zero connected by usb to wifi?
I followed your files but it doesn't work, the error in hostapd is:
Any ideas???
Thanks a lot