Connect your Raspberry Pi to your router using WiFi, or share your laptop's internet with your Raspberry Pi.
Configurring WiFi on the Raspberry Pi 3B
To connect your Raspberry Pi to your router using WiFi, start by scanning the WiFi networks on your Raspberry Pi:
sudo iwlist wlan0 scan
If your WiFi network shows up, we can continue by editing the wpa configuration file:
sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
Add the folowing lines:
network={
ssid="YourWiFiName"
psk="YourWiFiPassWord"
}
Close the file with CTRL+X
, Y
to confirm.
Now wait a few seconds, then check if your Raspberry Pi is connected by looking if it has an ip address: sudo ifconfig wlan0
(you should see entries such as inet addr
and inet6 addr
). If your Raspberry Pi isn't connected immediately, try sudo wpa_cli reconfigure
and check again after a few seconds.
Sharing internet with the Raspberry Pi 3B
This won't work with certain WiFi Access Points (some reject devices/addresses that didn't authenticate to the WiFi AP themselves).
If you can't connect to your WiFi, or you just prefer to share your laptop's internet with your Raspberry Pi, consider doing the following:
On your Raspberry Pi, edit /etc/network/interfaces
and set a static IP address:
sudo nano /etc/network/interfaces
Look for the line iface eth0 inet dhcp
and make it iface eth0 inet manual
. Close the file with CTRL+X
, Y
to confirm.
Then edit the file /etc/dhcpcd.conf
:
sudo nano /etc/dhcpcd.conf
Add the following lines: (replace x.x with your desired IP address and x.y with your router IP address).
interface eth0
static ip_address=192.168.x.x
static routers=192.168.x.y
static domain_name_servers=8.8.8.8 8.8.4.4
Close the file with CTRL+X
, Y
to confirm.
Then, on your Debian laptop, install the package bridge-utils
to bridge network connections:
sudo apt-get install bridge-utils
Create the new network interface:
sudo brctl addbr br0
Link the connections (if necessary, replace wlan0 with the network port your laptop uses to connect to the internet, and replace eth0 with the network port your laptop uses to connect to the Raspberry Pi):
sudo brctl addif br0 wlan0 eth0
sudo ifup br0
Then (still on your Debian laptop), edit /etc/network/interfaces
:
sudo nano /etc/network/interfaces
Look for the bridge entry. Make it look like this (again, replace wlan0, eth0, x, x.x and x.y where necessary):
# Bridge setup
iface br0 inet static
bridge_ports wlan0 eth0
address 192.168.x.x
broadcast 192.168.x.255
netmask 255.255.255.0
gateway 192.168.x.y
Close the file with CTRL+X
, Y
to confirm, and (hopefully) enjoy your bridged internet connection.