Skip to content

Instantly share code, notes, and snippets.

@karmatr0n
Created August 19, 2014 16:34
Show Gist options
  • Save karmatr0n/e72ad82943c9cd1d56e7 to your computer and use it in GitHub Desktop.
Save karmatr0n/e72ad82943c9cd1d56e7 to your computer and use it in GitHub Desktop.
Enable Internet access in your WiFi Pineapple through a network bridge and NAT with pf in Mac OS
#!/bin/sh
# You must execute this script with sudo: sudo sh bridge.sh
# Setting the ip address for en0 (ethernet interface) to enable access for pineapple default address: 172.16.42.1
ifconfig en0 172.16.42.2 netmask 255.255.255.0 broadcast 172.16.42.255 up
# Setting the bridge
ifconfig bridge0 create
ifconfig bridge0 up
ifconfig bridge0 addm en0
ifconfig bridge0 172.16.42.42
route add default -interface bridge0 -ifscope bridge0 -cloning
# Enabling forwarding
sysctl -w net.inet.ip.forwarding=1
# /etc/pf.conf
cat >/etc/pf.conf <<EOL
# PF Configuration File
ext_if = "en1"
int_if = "bridge0"
localnet = \$int_if:network
nat on \$ext_if from \$localnet to any -> (\$ext_if)
pass from { lo0, \$localnet } to any keep state
EOL
# Enabling NAT with Packet Filter
pfctl -f /etc/pf.conf -e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment