2

I have a Raspberry pi and I have connected it to my laptop via LAN cable in order to remote it, on the other side I want to use my WiFi to use internet.

When I connect to both of them one of them become disconnected after a while, is there any way to handle this?

If yes can I share my internet over eth0 in order to use internet in Raspberry Pi?

thanks

Yashar
  • 430

2 Answers2

0

You can do this by forwarding packets from wireless card to ethernet.

Do this on your Ubuntu machine

 ifconfig wlan0 192.168.1.1 (or whatever you want)

Enable ip_forward by 

 echo 1 > /proc/sys/net/ipv4/ip_forward

Enable forwarding in IPTABLES by

 iptables -A FORWARD --in-interface eth0 -j ACCEPT

Enable NAT mode to connect to internet by

 iptables --table nat -A POSTROUTING --out-interface wlan0 -j MASQUERADE

On your RPI set IP to 192.168.1.x and gateway to 192.168.1.x (ubuntu wlan0 ip address)

You might want to invest in a USB WiFi adapter. You can find them on Amazon for as low as $7. Just search Raspberry Pi Wifi

geoffmcc
  • 1,334
0

You can access internet via wlan0 and share it eth0. Don't need to do any changes. Just share eth0 over wlan0.

You can access rpi and surf internet.

akikara
  • 797
  • 1
  • 12
  • 28
  • How can I share it? Cause I tried to access internet but I could not – Yashar Feb 02 '15 at 11:27
  • You can check here http://askubuntu.com/questions/3063/share-wireless-connection-with-wired-ethernet-port?lq=1 and http://askubuntu.com/questions/169473/sharing-connection-to-other-pcs-via-wired-ethernet – akikara Feb 02 '15 at 11:40