Updated 5th April, 2016 with Striner’s method
This post will allow you to share WiFi Internet connection of the PC/Laptop with the Raspberry Pi which are connected to each other through a simple LAN/Ethernet cable connection at each end.
What you want to do:
- Share PC/Laptop’s WiFi Internet connection with Raspberry Pi through LAN/Ethernet connected to Raspberry Pi
What you have:
- Raspberry Pi B/B+/Pi 2/Pi 3 (If you’ve a Pi Zero, please try and let us know if this works on a Zero. I haven’t got a Pi Zero yet) running the latest Raspbian Wheezy. (I’ve not yet tried it with recently released Raspbian Jessie based off Debian 8. If you’ve been successful with this latest release, please post in the comment and I’ll update it here. Thanks.)
- PC/Laptop with WiFi Internet connection and a Ethernet Jack (LAN Connector / RJ45)
A working SSH connection with Raspberry Pi (direct access, explained here)Not required if using Striner’s or Bridge.
What you don’t have:
- Display Device for the Raspberry Pi (HDMI enabled display unit / Old TV)
- Direct Internet connection for the Raspberry Pi (LAN or WiFi)
Extra Stuff you need:
- Standard Network Cable (Cat 5, Standard or Crossover)
- PutTTY Software (will be used to SSH into the Pi)
- SD Card Writer
The easiest way to go around Sharing WiFi with Raspberry Pi is to follow Striner’s method of Sharing WiFi with the Raspberry Pi.
I’ve tested it with Raspberry Pi 3 and Windows 10 and he’s tested it on Win 8.1 and an earlier Pi and should work will Raspberry Pi B/B+/Pi 2/Pi 3. This hasn’t been tested with Win 7, though it mostly should work. Please give a shoutout and let us know if you’ve tried on Win 7 and it works.
Tested On: Windows 10 & Raspberry Pi 3 & Pi B (the Yellowish RCA model😉 )
Known to work on: Windows 8/8.1 & Raspberry Pi B/B+/Pi 2
Not tested (yet) on: Windows 7 & Raspberry Pi B/B+/Pi 2/Pi 3
1.1 Open up the Network and Sharing Center settings and navigate to Change Adapter Setting
1.2 Right click on the Wireless Adapter and hit Properties
1.3 Navigate to the Sharing Tab and select the Allow other network users to connect through this computer’s Internet connection checkbox
1.4 Now right click the Lan Adapter and hit Properties. Double click the IPV4 option and verify that some dynamic IP is populated (192.168.137.1 in my example)
1.5 Now Power ON the Raspberry Pi (ignore if already powered ON :P) and connect one end of the LAN Cable to the Raspberry Pi and the other end to the PC. You should be able to see status messages Identifying… and eventually Unidentified network
1.6 Open up cmd prompt and type in:
You should be able to ping the Raspberry Pi:
1.7 Open up Putty and set the Host Name as: raspberrypi.mshome.net and hit connect. (You can also use the IP address of the Pi revealed in the above ping prompt: 192.168.137.149)
1.8 You should be able to see the login prompt. Hit pi and raspberry and Enter
1.9 You can now
(or any other website) from within the Shell and you’ll have response messages. Congratulations! Your Pi now is connected to the World Wiiiiiiide Web😉
Big Thanks to Danny Striner, who shared this method in a comment and tested it out. Full credit goes out to Striner. I’ve named this method as the “Striner’s Method” to honor him
P.S: If you run into issues trying out this method, please disable windows firewall and try again (as pointed out by some users in the comments).
Method 2: Using Network Bridging
Edit: [12:58AM IST, 1 Feb, 2016]: I just stumbled upon a super simple process of Bridging the connections and directly ping and access Internet on the Raspberry Pi without having to edit anything on the SD Card’s cmdline.txt file.
Tested On: Windows 7 & Raspberry Pi 2
Known to work on: Windows 7/8/8.1 & Raspberry Pi B/B+/Pi 2/Pi 3
Not tested (yet) on: Windows 10 & Raspberry Pi B/B+/Pi 2/Pi 3
This process worked flawlessly for me and I’ve wrote a detailed tutorial here: https://www.hackster.io/Anwaarullah/sharing-wifi-with-raspberry-pi-using-a-lan-cable-ae1f44
If this doesn’t work, please follow Method 3 below.
Method 3: Editing cmdline.txt file of Raspberry Pi SD Card
Tested On: Windows 7 & Raspberry Pi B/B+/Pi 2/Pi 3
Known to work on: Windows 8/8.1 & Raspberry Pi B/B+/Pi 2/Pi 3
Not tested (yet) on: Windows 10 & Raspberry Pi B/B+/Pi 2/Pi 3
Edit: 2nd Jan, 2015. Added Video Tutorial:
A large part of this post assumes you’ve read the earlier post on directly accessing the shell on Raspberry Pi through a Ethernet/LAN connection. In this post, we’ll go about setting up the Raspberry Pi to access internet through the RasPi’s Ethernet/LAN port from a Laptop/PC’s shared WiFi connection.
Method 3 Steps:
- Firstly, enable the WiFi adapter of the PC/Laptop and make sure it’s connected to a WiFi hotpspot. Open any Internet Browser and confirm internet access by opening any website.
Note: I’m using my Android device (Nexus One) configured as a WiFi hotspot J
- Now, go to Network and Sharing Center (Network Settings in Win XP) and then head to the Change Adapter Settings page. As shown below, we’re connected to ‘Wireless Network Connection’ on ‘Android 4’. Do remember the ‘Local Area Connection’ to which we’ll eventually share this connection
- Now, right click the above Network → Properties and then select the Sharing tab
- From the drop down list, choose ‘Local Area Connection’ and enable both the checkboxes and hit OK. Once done, head back to the Adapter Settings page and you should now see the Shared info message on the Wireless Network Connection
- Now, right click ‘Local Area Connection’ → Properties and then select Internet Protocol Version 4 and then click the Properties Button
Once the properties tab pops up, make sure that the ‘Obtain IP address automatically’ checkbox is selected. If not, check it and hit OK
- Now, power up the Raspberry Pi (making sure that the Ras-Pi and the Laptop/PC are connected to each other through the LAN/Ethernet cable) and wait a minute or two while the Ras-Pi boots. Now, repeat step 5 (previous one) to make sure ‘Obtain IP Address Automatically’ is still checked.
- Open up command prompt using the hotkey Windows Key + R and then typing in cmd or simply keying in cmd in the start menu (Win 7)
- In the command prompt, key in ipconfig and scroll to the top of the info shown
Note the IPv4 address which is 169.254.39.68 in this example. Please make a note of what you see as this will be required further.
- Now, power off the Raspberry Pi and plug the Ras-Pi’s SD card into a card reader and connect it to the PC. Once the disk opens up, open the cmdline.txt file in any editor
You’d probably have an entry as ip=169.254.39.71 which we set up in our previous post
- Now, to this entry, append the IPv4 which we got earlier preceded by two colons as shown below:
where the first half is the static IP for Raspberry Pi (169.254.39.71) and the other half is the IP of the IPV4 or Ethernet Adapter (169.254.39.68) which we obtained earlier.
- Save this file and plug the SD card back into the Raspberry Pi. Power up the Raspberry Pi and wait for a min or two. Establishg a direct SSH connection with the Raspberry Pi as explained in the previous post.
- Now, to verify if our Ras-Pi is Internet-Connected, type in this command in the Shell (PuTTY terminal connected to the Ras-Pi)
and you should see response from the servers as shown below:
Voila!!! Your Raspberry Pi is now connected to the World Wide Web
- Going one step further, lets direct access the Raspberry Pi’s desktop and open up the midori browser. Verify Internet connectivity on the Ras-Pi by opening any website.
Note (Edited: 5th Feb, 2015): Midori browser is no longer coming pre-installed with the latest Raspbian version and has been replaced with Epiphany Browser. Please use that instead to verify internet connectivity.
Check out the comments. Many users have shared their own techniques which work on Win 8/10 flawlessly.
Please let me know your feedback or questions through comments.
P.S: Did this post help you? Please leave your feedback. If you’ve tried some additional steps that helped you in getting this working, please share so we all can benefit from.
If you’ve benefited from this post, please consider donating and help me buy new development stuff and resources. Thanks!