Raspberry Pi – WLAN Bridge
Table of Contents
Intro
Create a WLan Bridge with a Raspberry Pi for you only EthernetPort devices. I use it to get Internet to my Router from a Wireless Internet
Instructions
Add reconnect file
Edit network-monitor.sh file
sudo nano /usr/local/bin/network-monitor.sh
Add this to network-monitor.sh file
#!/bin/bash
##################################################################
# Settings
# Which Interface do you want to check/fix
wlan='wlan0'
# Which address do you want to ping to see if the network interface is alive?
pingip='192.168.2.1' # 8.8.8.8 1.1.1.1 192.168.1.1 192.168.4.1
##################################################################
echo "Performing Network check for $wlan"
/bin/ping -c 1 -I $wlan $pingip > /dev/null 2> /dev/null
if [ $? -ge 1 ] ; then
echo "Network connection down! Attempting reconnection."
ip link set wlan0 down
sleep 5
ip link set wlan0 up
else
echo "Network is Okay"
fi
Give permissen to network-monitor.sh
sudo chmod +x /usr/local/bin/network-monitor.sh
Make it run by crontab
sudo crontab -e
Execution time for the file
*/5 * * * * /usr/local/bin/network-monitor.sh # every 5 minutes
WLan Setup
Edit wpa_supplicant.conf
sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
Add this to wpa_supplicant.conf
# Edit the WLAN settings to your likings!
network={
ssid="WLAN1"
psk="passwordOne"
priority=1
}
network={
ssid="WLAN2"
psk="passwordTwo"
priority=2
}
If you want to check SSID
ifconfig wlan0
iwgetid
WLan Bridge
Install dnsmasq
sudo apt-get install dnsmasq
Edit dhcpcd.conf
sudo nano /etc/dhcpcd.conf
Search and edit
interface eth0
static ip_address=192.168.4.1/24
BackUp dnsmasq.conf
sudo mv /etc/dnsmasq.conf /etc/dnsmasq.conf.orig
Edit dnsmasq.conf
sudo nano /etc/dnsmasq.conf
Search and edit
interface=eth0
dhcp-range=192.168.4.8,192.168.4.250,255.255.255.0,12h
Edit sysctl.conf
sudo nano /etc/sysctl.conf
Edit to
net.ipv4.ip_forward=1
Edit rc.local
sudo nano /etc/rc.local
add this
iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE
Restart
sudo reboot
Check Status
sudo service dnsmasq status