Accessing Internet and SSH through Ethernet from Windows


4 posts
by abilashkollara » Sun Apr 07, 2013 12:12 am
This guide explains how to access RPi using ssh and share the internet of your windows machine using the same ethernet terminal. (Assuming Windows has wifi internet access)

Advantages:

[*] No need of a monitor or TV, HDMI cable, keyboard etc
[*] Can use your laptop to access the RPi terminal using Putty (SSH)
[*] Can access ssh and internet through one single ethernet connection

Notes:

[*]this guide assumes that you have windows 8 as your development platform. But the steps should be similar to other windows versions.
[*]This post assumes that you have access to your raspbian filesystem and you are able to edit files in RPi either using ssh terminal / using a usb keyboard or using your sdcard on a linux laptop (windows can't read raspbian file system)
[*] Requires "putty" to be installed on your windows system.

Step 1. First share your existing wifi internet on windows. For this go to Network and Sharing center -> Change adapter settings ->Right click on wifi network -> properties -> click sharing tab -> check “allow users to access the internet”. That completes the configuration on windows side. Now we can start configuring the RPi connection.

Important Note :

On most of the machines when you click OK after checking the “allow users to access the internet you...” option, Windows will automatically assign an ip to the ethernet port and will display it to you as an alert. In my case it was 192.168.137.1. In case Windows assigns your IP to 192.168.137.1 please understand that all the “192.168.0” corresponds to “192.168.137” in rest of this document. Otherwise go ahead with a static IP of 192.168.0.1


Step 2. Set up a static ip for the Ethernet Connection in your machine for eg: 192.168.0.1 ( or the ip assigned by windows as mentioned in step 1) For this go to Network and Sharing center -> Change adapter settings -> Right click on Ethernet -> Properties -> Select IPv4 -> Properties -> and configure a static ip. See screenshot below
screenshot.jpg
screenshot.jpg (55.65 KiB) Viewed 5140 times


3. SSH to RPi and edit the /etc/network/interfaces file using following command
Code: Select all
sudo nano /etc/network/interfaces   

Configure it as shown below:

screenshot2.jpg
screenshot2.jpg (52.39 KiB) Viewed 5140 times


Press Ctrl+O and then enter to save. This file is where all the network configurations are made. Ignore first 2 lines. It is the configuration for loop back adapter. The next two paragraphs configures the Ethernet and wifi of the Rpi. Here Ethernet uses static ip 192.168.0.2 (or 192.168.137.2 if windows assigned 192.168.137.1 to PC) and netmask 255.255.255.0 and gateway 192.168.0.1 (which is the ip that we configured for the machine) . Similarly wifi is configured in the next paragraph. Ignore the wifi configuration too. We are just interested in the ethernet (eth0) paragraph.

If you have the Ethernet configuration like this, you can ssh to your raspberry pi using any laptop through Ethernet provided the Ethernet ip on the laptop is set as 192.168.0.1

4. Now comes the part where RPi access the internet of our machine. We know the gateway is 192.168.0.1. We should let RPi know this ip (the nameserver). For this edit the /etc/resolv.conf file using the command below.

Code: Select all
sudo nano /etc/resolv.conf


Change your nameserver to 192.168.0.1.
That is it. Now if we restart our RPi and ssh to it (192.168.0.2) via windows, we will have the internet shared from your laptop to RPi. This is a big step as we can now install all the softwares using
Code: Select all
sudo apt-get install <package name>
or update raspbian using
Code: Select all
sudo apt-get update
as well as ssh to the Rpi using the same ethernet connection. Now to check if the RPi has internet we can use the following command, basically it downloads the webpage which is not possible without internet connection.

Code: Select all
wget http://www.google.com


If this command copies the website to your home page.... cout<< "mission accomplished :D"

If you want to do the same with a Linux (Ubuntu) machine follow this link
http://www.raspberrypi.org/phpBB3/viewtopic.php?f=26&t=13211
Posts: 2
Joined: Fri Apr 05, 2013 7:16 pm
Location: NC, USA
by Zvanochek » Tue Apr 23, 2013 11:51 am
This works fine for Win7 as well.

Just a point of note to anyone who cannot see the sharing tab (see step 1): make sure that internet sharing is not enabled for the ethernet connection already. If it is, you will not be able to enable it for the wifi connection (in my experience).
Posts: 10
Joined: Thu Jan 05, 2012 1:56 pm
by geoji » Tue Aug 27, 2013 2:49 pm
I think assigning static ips to the ethernet connection on the PC and to the raspberry Pi makes it unnecessarily complicated. Instead of assigning static ips, just install samba on the PI.

Code: Select all
sudo apt-get install samba


With samba installed, you can find the IP of your PI anytime using the ping command from windows command line

Code: Select all
ping raspberrypi


where raspberrypi is the hostname of your PI.

The ping would return the IP address assigned to PI using DHCP. Now you can ssh into PI using the IP address returned.
Posts: 6
Joined: Thu Aug 22, 2013 7:18 pm
by Ripsi » Sat Jan 04, 2014 6:36 pm
Tried this, doesn't work .The default gateway is the same as the IP address. This does not make sense. Please advise.
Posts: 2
Joined: Fri Dec 13, 2013 6:10 am