How about connecting your Raspberry Pi using a LAN (Ethernet) cable to your Laptop and using the Laptop’s internet access? This would for example allow you to install stuff on your Pi without having an internet dongle for the Pi.
Following post shows you how to configure Raspberry Pi and Laptop, so both share the Laptop’s WiFi.
There are several possibilities to have Laptop and Raspberry Pi communicate directly with each other using an Ethernet (LAN) cable and have the Raspberry Pi share the Internet connection of the Laptop.
To accomplish this, you need to first do some preparations on your Raspberry Pi.
Preparing the Raspberry Pi
Static IP Address
For the first preparation on your Raspberry Pi you can follow the instructions in the post Raspberry Pi Zero Setup with no Monitor.
To have a safe copy to come back to make a copy of your interfaces file with:
sudo cp /etc/network/interfaces /etc/network/interfaces.orig
Before going headless with the Raspberry Pi use a Monitor, keyboard and mouse or the method described in Raspberry Pi Zero Setup with no Monitor using your router to change on the Raspberry Pi the content of the file /etc/network/interfaces to the following:
auto lo eth0 wlan0 iface lo inet loopback iface eth0 inet static address 192.168.1.123 netmask 255.255.255.0 allow-hotplug wlan0 Iface wlan0 inet manual # Put your router name and password in the following file: wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
To connect to your Raspberry using an Ethernet tether make sure you note the eth0 address that you set in /etc/network/interfaces (here e.g 192.168.1.123).
Now doing a
sudo reboot
will activate the new settings. After boot-up you can check with
ifconfig
that eth0 has now the address you chose (here 192.168.1.123).
Installing Samba for Internet Access
To be able to access the Internet from the Pi using the Laptop’s WiFi you need to install Samba on the Pi. To do this please follow the post Share your Raspberry Pi’s files and folders across a network or just the following:
sudo apt-get update sudo apt-get install samba samba-common-bin
Edit the Samba configuration file with
sudo nano /etc/samba/smb.conf
Find the entries for workgroup and wins support, and set them up as follows:
workgroup = WORKGROUPS wins support = yes
If you did not change your workgroup name it is most likely WORKGROUPS and you won’t have to change that. Otherwise replace that with then workgroup name you have.
In the same file scroll down until you find the section Share Definitions and add at the end of that section following code:
[pihome] comment= Pi Home path=/home/pi browseable=Yes writeable=Yes only guest=no create mask=0777 directory mask=0777 public=no
This allows you to share files and folders between Raspberry Pi and Laptop by just using your standard Windows Explorer on the Laptop. To get to the Pi you just have to type in the address of the raspberry Pi as \192.168.1.123
Now type this command in a terminal, and enter pi’s password twice:
sudo smbpasswd -a pi
A reboot of the Pi at this point is a good idea:
sudo reboot
Preparing the Laptop
“Pinging” between Laptop and Pi
Moving to your Laptop note that the first three number blocks of the IP address (here 192.168.1.) must be same between Pi and the Local Area Network (LAN) IPv4 value on the Laptop. This setting is detailed in the post Raspberry Pi and Laptop LAN (Ethernet) Connection.
When this is set right, you can open up a Command Prompt (e.g. by typing in Start->”Search Programs and Files”, type there “Command Prompt”) and check if the Laptop can communicate with the Pi by typing
ping 192.168.1.123
The result should be similar to what is shown in below image:
You should also be able to “ping” your Laptop from the Pi. You can find the Laptop’s IP address by typing ipconfig in the Command Prompt as shown in below image:
This tells you that you can “ping” the laptop from the Pi, typing in a Pi terminal
ping 192.168.1.130
using the address I have set on my Laptop for LAN (Ethernet connection) – you are free to choose another number in the fourth block, making sure it does not conflict with another LAN address in your network.
Settings in Network Connections
For the final step to connect the Pi over the Laptop’s WiFi to the internet, open up Network Connections e.g. by typing the name into the Windows search: as in below image:
which opens the Network Connections window. In this window – if you have the Ethernet (LAN) cable to the Pi connected to the Laptop – you will see the Local Area Network symbol not grayed out.
This final step is pretty simple:
Left click in the Network Connections window on the Local Area Connection symbol. While holding the Ctrrl button left click the Wireless Network Connection (which I called in below image wifi wan). Then right click on one of them as shown in below image:
The menu leaves only one choice: Bridge Connections
When you click that choice Windows attempts to establish a bridge connection between your LAN cable (which is connected to the Pi) and the WiFi connection (which has access to the internet).
A Network Bridge symbol appears which has for about 30 sec a red cross until the connection is established and the cross disappears, as shown in below image:
You will notice that as long as you have the bridge connection established your WiFi symbol in the right lower Windows corner will be different than usual as shown here:
You might even get this icon in the right lower corner:
In this configuration you can ignore this.
You should still check if you have internet access on the Laptop. If any issues, run the standard “Troubleshoot problems” option, which you get when right clicking on the WiFi symbol in the lower right windows corner.
Checking Internet access on the Pi
Once the bridge connection is established you can either use Putty to communicate over the LAN with the Pi or use a Monitor.
A simple check on the Pi if internet access is given is either to open a browser or to type at the terminal prompt
ping www.google.com
This should show following result:
If you have troubles getting this, you might have to reboot the Pi and/or do the WiFi “Troubleshoot Problems” option in Windows as described above.
As usual, please let me know your thoughts and comments. Hope to see you soon back…
Recent Comments