Created
September 5, 2010 22:04
-
-
Save zimbatm/566369 to your computer and use it in GitHub Desktop.
Wifi bridge
This file contains 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
#!/bin/sh | |
# | |
# eth0-eth1 Bridge | |
# | |
###### Config | |
WIFI_SSID="your ssid" | |
WIFI_PASS="your pass" | |
###### | |
# Strict mode | |
set -e | |
set -u | |
# Force root | |
if [ `id -u` -ne 0 ]; then | |
echo "Please run the script as root" | |
exit 1 | |
fi | |
# Install dependencies | |
if ! which brctl >/dev/null 2>&1; then | |
apt-get update | |
apt-get install bridge-utils | |
fi | |
# Stop network manager | |
/etc/init.d/NetworkManager stop | |
/etc/init.d/wpa-ifupdown stop | |
## Kernel settings | |
sysctl -w net.ipv4.ip_forward=1 | |
# disable reverse-path filtering | |
sysctl -w net.ipv4.conf.eth0.rp_filter=0 | |
sysctl -w net.ipv4.conf.eth1.rp_filter=0 | |
#sysctl -w net.ipv4.conf.all.log_martians=1 | |
## Network settings | |
ifconfig eth0 down | |
ifconfig eth0 0.0.0.0 promisc up | |
ifconfig eth1 down | |
ifconfig eth1 0.0.0.0 promisc up | |
brctl addbr br0 | |
brctl addif br0 eth0 | |
brctl addif br0 eth1 | |
## Wifi setup | |
cat <<WPA_CONF > /tmp/wpa_supplicant.conf | |
network { | |
ssid="${WIFI_SSID}" | |
psk="${WIFI_PASS}" | |
} | |
WPA_CONF | |
wpa_supplicant -Dipw -ieth1 -c/tmp/wpa_supplicant.conf & | |
dhclient -d br0 & | |
wait |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment