Here is hassle-free, simple way to share an internet connection. Spent a lot of time to enable an internet on my Raspberry Pi through my Windows 7 based PC. Unfortunately didn't found the easiest guide on internet.
This post simplifies all. This post is also written for my future reference if I need to re-set the settings on my Pi.
So here is the list of what we need, and what not.
I assume that you have followed
this post. (Meaning your Pi is having expanded root_fs)
What we need:
1. Windows 7 based PC/Laptop with ethernet port
2. Internet Connectivity
3. Putty
(Download)
4. SD Card Reader (either inbuilt or an add-on SD Card reader)
5. Raspberry Pi (Obviously!)
6. An Ethernet cable (Must)
7. Editing of cmdline.txt in /boot file.
What we DO NOT need:
1. DHCP Server for Windows
2. No need to set Fixed IP address on adapter settings in Computer
3. USB Keyboard/mouse (we will use desktop/laptops's peripherals indirectly)
4. HDMI/RCA enabled Display
Here we go!
Step1:
Follow this link if you are setting up Rasperry Pi first time.
If you have already expanded Root_FS go to Step 2.
Step 2:
1. Remove SD card from the Raspberry Pi.
2. Insert SD Card to the PC's inbuilt or add-on SD card slot.
3. Upon opening, You will see multiple file's on the Disk.(The size of the Removable Media may be upto 20MB)
4. Open cmdline.txt you will be able to see this text.
5. Modify this file by putting the static IP of Raspberry Pi at the end of the line:
This is the static IP we provided for the Raspberry Pi. All the time from now onward, you have to access your Pi using this address.(you can have range of IP : 169.254.0.2.to 169.254.255.255 )
6. Save this cmdline.txt file and safely remove the SD card from computer and insert it into the Raspberry Pi.
7. Power-ON the Raspberry Pi, meanwhile connect the Ethernet cable to the Pi and Windows 7 computer.
- You will see the multiple status LED's ON now; which indicates the Ethernet cable connected to it.
8. Easy Tweak
You can also check weather you Pi is connected with your PC or not by opening your command prompt on Windows PC by "ping 169.254.0.2"
9.Open Network Sharing center from Window's Control Panel > Change Adapter Settings > Right click on the Adapter where you are getting internet connection.(In my case it's wifi adapter, where I am getting an Internet connectivity.)
Click on Sharing Tab > Set to the "Allow other...." > Press OK
10. Open Network Sharing center from Window's Control Panel > Change Adapter Settings > Right click on Local Area Connection/Ethernet adapter > Properties > IPv4 Settings and Set to "Obtain an IP address automatically".
11. Open Command Prompt of Windows.
- Run > type cmd > Enter
- Enter "ipconfig"
- Check the IP of the "ethernet connection."
- Note Down the IP address. Mine it is showing 169.254.121.232 (Your's will differ)
- Close Command Prompt.
12. Open Putty (
Download) and make these changes
Select Session :
Select "Selection"
Select X11:
13. Save the Configuration on Raspberry Pi. Now Load the Configuration.
14.Now you will be able to See the Login of Raspberry Pi
- Enter The ID and Password of Raspberry.
- Default ID, password are respectively : pi and rapberry
15. Type this command
sudo su
This will take you in the root user.
enter the command "poweroff" to shutdown the Raspberry Pi.
16. Now we need to again edit the cmdline.txt to enter the PC's ethernet address we got after connecting the raspberry pi.
17. Remove SD card from Raspberry Pi and Insert that in to the PC. Using same method open cmdline.txt and modify the code like this.
In a simple language the :: between two IP states the interface and data sharing between these two IP's.
18. Save the cmdline.txt and insert the SD card back to the Pi.
19. Power-ON the raspberry Pi and do the Procedure as specified in Step 13 and Step 14.
20. Check whether the internet connection is active or not.
Enter this command:
ping -c 4 www.google.com
Success!!!
now you first type these command to make your Pi up-to-date.
sudo apt-get update
sudo apt-get upgrade
That's all.!!
Thank you!! Share the Link!!