Skip to content

Instantly share code, notes, and snippets.

@vicente-gonzalez-ruiz
Last active May 15, 2020 10:58
Show Gist options
  • Save vicente-gonzalez-ruiz/65cab6c689fdd84f92f621acdd41d495 to your computer and use it in GitHub Desktop.
Save vicente-gonzalez-ruiz/65cab6c689fdd84f92f621acdd41d495 to your computer and use it in GitHub Desktop.
# Setting up a Raspberry Pi as a bridged wireless access point
# https://www.raspberrypi.org/documentation/configuration/wireless/access-point-bridged.md
# Update
sudo apt-get update
sudo apt-get upgrade
# Disable bluetooth
https://gist.github.com/vicente-gonzalez-ruiz/a330f19fda79d8e4b818204d5224c8f0
# Install the access point software
sudo apt install hostapd
# Enable the wireless access point service
sudo systemctl unmask hostapd
sudo systemctl enable hostapd
# Create a bridge device and populate the bridge
sudo -- sh -c 'cat > /etc/systemd/network/bridge-br0.netdev << EOF
[NetDev]
Name=br0
Kind=bridge
EOF'
# Add the built-in Ethernet interface (eth0) as a bridge member (create file)
sudo -- sh -c 'cat > /etc/systemd/network/br0-member-eth0.network << EOF
[Match]
Name=eth0
[Network]
Bridge=br0
EOF'
# Enable the systemd-networkd service to create and populate the bridge when your Raspberry Pi boots
sudo systemctl enable systemd-networkd
# We need to block the eth0 and wlan0 interfaces from being processed, and let dhcpcd configure only br0 via DHCP (modify file). We also configure a static IP address.
sudo -- sh -c 'cat >> /etc/dhcpcd.conf << EOF
denyinterfaces wlan0 eth0
interface br0
static ip_address=192.168.1.4/24
static routers=192.168.1.1
static domain_name_servers=192.168.1.1
EOF'
# Ensure wireless operation
sudo rfkill unblock wlan
# Configure the access point (create file)
sudo -- sh -c 'cat > /etc/hostapd/hostapd.conf << EOF
country_code=ES
interface=wlan0
bridge=br0
ssid=bridge-casa2
hw_mode=g
channel=9
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=montemonte
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
EOF'
# End. Reboot:
sudo systemctl reboot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment