4

You have probably seen a similar question somewhere.

I have a laptop connected to my Internet with a Wireless router and I want to share my Internet Connection with my RPi via crossover Ethernet network cable. At this point, I have already set up a Bridged Network between my Wireless adapter and the Ethernet adapter of my laptop (Windows 7.) Unfortunately every time I connect my RPi to my laptop, the connection in my laptop gets lost! And when I unplug my RPi from my laptop, I get the internet connection again. I don't know why I'm getting this behavior.

I suppose the only way to connect to my Pi is via SSH, so I can't reconfigure a file to set a static IP address.

  • Why you can't reconfigure? Can you explain what you did? – gurcanozturk Aug 25 '13 at 6:30
  • I can't login to my RPi because is not getting one via DHCP. I scanned the entire network using Advanced Ip scanner and my RPi is not listed, so is not getting DHCP. – Mr_LinDowsMac Aug 25 '13 at 6:41
  • I presume that the network configuration on my RPi is default (DHCP) because I usually connect at my work with a Ethernet cable. I don't want to set any static IP on my RPi. – Mr_LinDowsMac Aug 25 '13 at 6:47
  • @gurcanozturk I got a keyboard and connected my RPi to a TV. I figured out that my Pi HAVE internet connection but my laptop doesn't! is weird because if i unplug the network cable i recover internet in my laptop. – Mr_LinDowsMac Aug 25 '13 at 8:45
  • @Mr_LinDowsMac You're doing the connection sharing backwards on your PC. – Andrew Larsson Dec 17 '13 at 17:47
5

First off, I couldn’t create a bridge between Ethernet and my WiFi. So I am goin’ to tell you how I got internet using Internet Connection Sharing and Crossover Cable.

  1. In order to SSH to the RPi you need to set an IP address in your subnet in the RPi by editing the /boot/cmdline.txt file
  2. Share Internet in your windows Machine and take note of the Ethernet IP.
  3. SSH into the RPi and change IP to static in same subnet and add DNS(if it not already there) and Change the cmdline.txt to its previous version
  4. Ping to see if it works

Changing the cmdline.txt according to the Machine Subnet:

From http://pihw.wordpress.com/guides/direct-network-connection/

Before we power up our Raspberry Pi, we can have a look at the network settings of the computer we are planning on connecting to and determine if the address is automatically allocated or fixed.

Hopefully, the IP Address will be set to “Obtain an IP address automatically”. If not don’t worry, just take a note of the IP address and Subnet Mask set here or you can change this setting to automatic.

Setting the Raspberry Pi’s IP address

Edit your cmdline.txt file: You can edit it directly on the Raspberry Pi:

$ sudo nano /boot/cmdline.txt

Or use an SD-Card reader on your computer (the file is in the root of the visible partition on the card – if you aren’t using NOOBS).

You will need to add the ip=x.x.x.x value to the end of the line (ensure you do not add any extra lines).

It is recommended you use a Linux compatible editor such as Notepad++ (http://notepad-plus-plus.org/) to make the change.

For network settings where the IP address is obtained automatically, use an address in the range 169.254.X.X (169.254.0.0 – 169.254.255.255):

ip=169.254.0.2

For network settings where the IP address is fixed, use an address which matches the laptop/computers address except the last one (assuming your netmask is at least 255.255.255.0 / 255.255.0.0).

ip=192.168.0.2

Ensure you take note of this IP address (you will need it every time you want to directly connect to the Raspberry Pi, although you might be able to use the hostname).

Share Internet in your windows Machine and take note of the IP

From Network Setting in your computer open Change Adapter settings and Open the properties of the adapter providing you with internet (in my case my WiFi adapter)

Click sharing and Check the “Allow other users to connect through this computers Internet Connection” and if there is a Drop Down Box Select the Wired Adapter (my case Ethernet)

Now, again check the IP address of the Wired Adapter (Ethernet in my case) and take note of the ip and subnet

SSH in the RPi and Change Interface Settings

Quoting @gurcanozturk

Rpi can't get dynamic IP address from your Windows7 laptop, because there are no DHCP server running on Windows 7. You have to set static IP address on Rpi which is in same network with Windows7 laptop.

Step by step instructions. 1) Connect your Windows7 laptop to network via wireless ethernet adapter. Note the IP address. (Let's say its 192.168.1.10)

2) Give a static IP address to Windows7 wired ethernet adapter. This IP address should be on different subnet than wireless adapter. (Let's say it should be 10.0.0.10)

3) If you haven't monitor or TV that connected to Rpi, you should connect Rpi to your router temporarily to set static IP address on it. Let's say it should be 10.0.0.20)

Connect Rpi to your router through wired ethernet, Login as root or use sudo to change IP address settings, Edit /etc/network/interfaces file as root, Your /etc/network/interfaces file should look like this,

auto lo

iface eth0 inet static
address 10.0.0.20
netmask 255.255.255.0
network 10.0.0.0 //I didn't enter this line
broadcast 10.0.0.255 //I didn't enter this line
gateway 10.0.0.10

And also you have to edit /etc/resolv.conf file to add nameservers for Rpi. Remove all lines in the file and append line below.

nameserver 8.8.8.8

After doing that run /etc/init.d/networking restart command or reboot your Rpi. After setting up unplug Rpi from router than plug it into Windows7 wired ethernet. At this step you can try ping the Rpi from Windows7. If it pings everything is ready.

4) Bridge wired and wireless adapters in Windows7.

5) SSH into Rpi from Windows7 and test if Rpi connects to internet.

Now change the /boot/cmdline.txt to it's previous version, i.e remove ip=xx.xx.xx.xx part

  • Whoa. This is a phenomenal, amazingly formatted answer coming from a newer user! Keep up the good work! – syb0rg Feb 2 '14 at 3:20
2

Rpi can't get dynamic IP address from your Windows7 laptop, because there are no DHCP server running on Windows 7. You have to set static IP address on Rpi which is in same network with Windows7 laptop.

Step by step instructions.
1) Connect your Windows7 laptop to network via wireless ethernet adapter. Note the IP address. (Let's say its 192.168.1.10)

2) Give a static IP address to Windows7 wired ethernet adapter. This IP address should be on different subnet than wireless adapter. (Let's say it should be 10.0.0.10)

3) If you haven't monitor or TV that connected to Rpi, you should connect Rpi to your router temporarily to set static IP address on it. Let's say it should be 10.0.0.20)

  • Connect Rpi to your router through wired ethernet,
  • Login as root or use sudo to change IP address settings,
  • Edit /etc/network/interfaces file as root,

Your /etc/network/interfaces file should look like this,

auto lo

iface eth0 inet static
address 10.0.0.20
netmask 255.255.255.0
network 10.0.0.0
broadcast 10.0.0.255
gateway 10.0.0.10

And also you have to edit /etc/resolv.conf file to add nameservers for Rpi. Remove all lines in the file and append line below.

nameserver 8.8.8.8

After doing that run /etc/init.d/networking restart command or reboot your Rpi. After setting up unplug Rpi from router than plug it into Windows7 wired ethernet. At this step you can try ping the Rpi from Windows7. If it pings everything is ready.

4) Bridge wired and wireless adapters in Windows7.

5) SSH into Rpi from Windows7 and test if Rpi connects to internet.

  • No, i don't have physical access to the wireless router., – Mr_LinDowsMac Aug 25 '13 at 7:33
2

There is a much simpler way, that doesn't involve setting up anything at all on your RPi. The reason why Raspberry isn't connecting to your PC is because Windows lacks a DHCP server when sharing the internet connection. Here's how to fix that.

First, enable internet sharing on your Windows machine:

  1. start menu > search for "view network connections"
  2. right click your wifi connection > properties > sharing
  3. enable sharing and select the ethernet adapter in the dropdown
  4. switch to networking tab and set your IPv4 address to static like: 192.168.42.1

Now, for the interesting part:

  1. download DHCP server - it's tiny, free and doesn't require installation
  2. run dhcpwiz, select your ethernet adapter, then enable DNS in additional protocols (use 8.8.8.8), next select IP range that corresponds to your static IP, in our case it would be 192.168.42.2 - 255, save settings
  3. run dhcpsrv, continue as tray app

Now all you need to do is plug in your RPi and the connection should work. DHCP server should show a balloon tooltip with IP address that was assigned to your Raspberry. You can SSH to it if you like or just browse the internet from your RPi.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.