Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bridge Wifi to Raspberry Pi using Ethernet Cable

I am not finding this question in SF history, which was a surprise, so I'll go ahead and ask it.

I am working on an IoT Raspberry Pi project with Windows 10 and need to connect it to the internet via an Ethernet/USB adapter. The adapter itself is made by Belkin. Using this, I can see an ip of 169.stuff get generated for my Pi, which is a private ip. I can deploy code to that from my connected box, however other devices are not able to reach it, and it is not able to make connections out to any servers.

I'm wondering if anybody knows how to bridge the connection.

I am attempting to use the new Azure IoT Hub and the SDK with this in case that makes any differences as that is not a simple rest interface and I believe is some form of socket connection.

Additional Notes: I have installed a DCHP Server and the Pi gets the ip address: 192.168.0.3 assigned to it. Unfortunately the Pi still can not ping external sites, such as google.com

Latest Discoveries: I am on a corporate box, which has internet sharing disabled by the system admin. Following these instructions: http://zizhujy.com/blog/post/2013/07/07/Solved-Internet-Connection-Sharing-has-been-disabled-by-the-Network-Administrator.aspx Fails. It shuts down all connectivity to my box and I cannot ping anything or reach the internet or anything.

Thanks, ~David

like image 864
David Crook Avatar asked Nov 02 '15 17:11

David Crook


People also ask

Can a Raspberry Pi Bridge WiFi to Ethernet?

A Raspberry Pi WiFi bridge is one of the best ways of providing internet access to a device that only supports an Ethernet connection. In this tutorial, we will show you how to setup a WiFi bridge, and how to setup dnsmasq correctly to allow any device to connect through your Pi without issues.

How do you bridge wlan0 and eth0?

The way the bridging works is that you create a virtual interface (the "bridge", usually called br0) and give it an IP address. Then you add interfaces to the bridge. The order isn't important. So you don't "bridge eth0 to wlan0" or "bridge wlan0 to eth0" as such, you just "add wlan0 and eth0 to the bridge".

How do I connect my Raspberry Pi to Ethernet router?

The computer can be connected to the router using an Ethernet cable as well, or using wireless. To physically connect the Pi to the router you'll need an Ethernet cable that has male RJ45 connectors on both ends. Plug one end into the computer and the other end into the Pi. Ethernet cable with male RJ45 connectors.


2 Answers

The 169 address means it isn’t getting a DHCP address assigned.

Since you don't have a router for the Ethernet, you can use Internet Connection Sharing, however we will need to run the following commands against the Pi to set a static IP, gateway, and dns server, since internet connection sharing botches this up a bit at times:

Set-Item WSMan:\localhost\Client\TrustedHosts -Value 192.168.137.2
Enter-PSSession -ComputerName 192.168.137.2 -Credential 192.168.137.2\Administrator

set-executionpolicy unrestricted

netsh int ip set address "Ethernet" static 192.168.137.2 255.255.255.0 192.168.137.1

netsh int ip set dns "Ethernet" static 8.8.8.8            
netsh interface ipv4 show config

set-executionpolicy remotesigned

You may need to reboot the Pi at this point then test pinging 8.8.8.8 and google.com to make sure resolution is working. You should be all set!

One other thing, if you have a group policy on the machine that is restricting Internet Connection Sharing then take a look at this article to fix the issue. Note if your organization is constantly sending down the policy then you may have to re-enable Internet Connection Sharing often which is aggravating but at least it will work. http://zizhujy.com/blog/post/2013/07/07/Solved-Internet-Connection-Sharing-has-been-disabled-by-the-Network-Administrator.aspx

like image 150
Tommy Patterson Avatar answered Sep 19 '22 19:09

Tommy Patterson


I do this by creating a DHCP server on my laptop and connecting the Pi directly to it. I followed these instructions to get it working:

  1. Download DHCP Server for Windows. It is a 100kB download.
  2. Go to the IPv4 properties page of the Ethernet adapter and set a fixed IP address, say 192.168.2.1
  3. Run the DHCP Server Wizard (downloaded above)
  4. Select the Ethernet adapter from the list shown
  5. Save the configuration file and start up the DHCP Server
  6. Click the 'Continue as tray app' button in the server control panel.
  7. Boot up the Raspberry Pi
  8. A popup notification shows the IP address assigned by the DHCP server to the Raspberry Pi.
  9. Use a SSH client, like PuTTy, to connect to the IP address shown

Hope this works!

like image 20
Joe Raio Avatar answered Sep 20 '22 19:09

Joe Raio