Because our Smart-TV had only LAN built in I wanted to use the RPi 3 to bridge WiFi to LAN.
This tutorial worked for me before I updated to a later raspbian version:
https://www.raspberrypi.org/forums/viewtopic.php?f=36&t=132674
I adapted it a bit until it worked for me on raspbian stretch 2017-07-09
The configuration file of the DHCP Client (dhcpcd5) /etc/dhcpcd.conf is used instead of /etc/network/interfaces.
Preparation
Upgrade everything. Install rpi-update and dnsmasq. Run rpi-update => reboot.
sudo apt-get update && sudo apt-get upgrade -y && sudo apt-get install rpi-update dnsmasq -y sudo rpi-update sudo reboot
Connect to WiFi
Edit wpa_supplicant.conf
sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
Add your network credentials
network={ ssid="mynetwork" psk="secret" }
Static DHCPCD Configuration
Edit dhcpcd.conf
sudo nano /etc/dhcpcd.conf
Add this OR uncomment the example and modify
interface eth0 static ip_address=172.24.1.1/24 static routers=172.24.1.0 static domain_name_servers=172.24.1.0 8.8.8.8
DHCP Server
Backup dnsmasq.conf and create new
sudo mv /etc/dnsmasq.conf /etc/dnsmasq.conf.orig sudo nano /etc/dnsmasq.conf
Add configuration for DNS & DHCP-Server (dnsmasq)
interface=eth0 # Use interface eth0 listen-address=172.24.1.1 # Explicitly specify the address to listen on server=8.8.8.8 # Forward DNS requests to Google DNS domain-needed # Don't forward short names bogus-priv # Never forward addresses in the non-routed address spaces. dhcp-range=172.24.1.50,172.24.1.150,12h # Assign IP addresses between 172.24.1.50 and 172.24.1.150 with a 12 hour lease time
Enable IPv4 forwarding
Edit sysctl.conf
sudo nano /etc/sysctl.conf
Uncomment this line
net.ipv4.ip_forward=1
IP Tables
sudo iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE
sudo sh -c "iptables-save > /etc/iptables.ipv4.nat"
sudo nano /lib/dhcpcd/dhcpcd-hooks/70-ipv4-nat
iptables-restore < /etc/iptables.ipv4.nat
Ran through this guide and everything seemed to work well, but I lose internet connection on the pi whenever I connect the ethernet device to the pi. Can’t tell if device is getting internet(it’s an IP camera), got any ideas?
What do you mean by “the raspberry loses internet connection”?
Does the IP Camera use DHCP and can you maybe reset it?
Have you tried a different device on the ethernet port (a laptop,…)?
Thank you very much!!