SSH and Internet connection sharing over crossover ethernet cable from OS X (Mac) to Raspberry PI (model B)

These days I am testing a Raspberry PI (model B) with 3.5" TFT LCD screen.  Since I have another Rasp. PI (model B+) to be setup and to remember these steps I wrote this with the thinking that any other person can also use this info. But I have only USB mobile broadband stick (dongle) and crossover Ethernet cable. So, I must connect to Raspberry PI via SSH (VNC) and I need Internet connection to the Rasp. PI as well. Since I have no Internet connection to Rasp. PI initially I cannot install anything on Rasp. PI in order to make VNC, apt-get update and install other necessary software.

So, Finally I got through and now I have VNC with shared Internet connection over Ethernet cable from OS X.

This is what I wanted at the end.
Rasp. PI VNC view with Internet

Rasp. PI setup:
Rasp. PI with crossover Ethernet cable




Though I share Internet connection of mobile broadband to Wi-fi (bridge0 has en1 as a member), in this document I am not using shared Wi-fi connection. I connect to Rasp. PI using ssh and Internet connection over by crossover Ethernet cable alone.


I post here, only the steps I took in the last successful attempt. 1st I ran "ifconfig" and networksetup -listallhardwareports on my Mac (10.8.5), I got this:
ifconfig and network device list on OS X terminal


So, do not worry about the bridge0, I will explain that. Initially I got IPs for en0, en1 and en3 (crossover Ethernet, Wi-fi endpoint, USB mobile broadband stick - Ethernet adapter) and all these 3 network endpoint were marked as status: active. In this case USB mobile broadband stick is not an network endpoint to have IP. this Ethernet adapter is created by my OS when I connect it to Internet. So, when you share Internet connection in later of this document do not choose mobile broadband device as Internet connection (from) source. If you have all the network endpoints with IPs from ISP DHCP like mine then it is easier. Or otherwise assign some static IPs and make sure all are in same IP network range.

2nd step is go to System preferences -> Sharing (under Internet & wireless section) and share Internet connection as you want. In my case it is Wi-fi and Ethernet.
OS X Internet sharing USB mobile broadband to Ethernet and Wi-fi




Then you will get bridge0 when you run "ifconfig". The bridge0 will have IP, netmask, broadcast address assigned to it. This work as internal VPN. So, to connect any network device you have to use IPs from this network range. Most of the time it is C class range. And if you go through "ifconfig" line-by-line you will see that only en3 (mobile broadband Ethernet adapter) has IP assigned to the network endpoint and other en0 and en1 do not have IPs  after Internet connection sharing. But still those endpoints must be active state.

Now go to Rasp. PI and run "sudo vim.tiny /etc/network/interfaces" and give static IP to eth0 endpoint., This must be in the same network range as the bridge0 of the PC (Mac).

Rasp. PI /etc/network/interfaces file:
auto lo
iface lo inet loopback

iface eth0 inet static
address 192.168.2.3
netmask 255.255.255.0
gateway 192.168.2.1

In here the gateway is important. The gateway IP is the bridge0 IP as well as Rasp. PI DNS IP. So, run "sudo vim.tiny /etc/resolv.conf" and set "nameserver 192.168.2.1". Now run "sudo reboot".

Done :)

After you restart the Rasp. PI go to Rasp. PI terminal and ping google.com. If it is responding ICMP then you are in good condition.

Follow the sources as courtesy. But following each document fully did not configured my Rasp. PI.

Sources:
1. https://galem.wordpress.com/2014/10/14/configuring-the-raspberry-pi-to-share-a-macs-internet-connection/
2. http://lastplaceonthe.net/set-mac-wireless-hotspot/

Comments

Popular posts from this blog

Stubbing Netflix OSS Eureka for local development of microservices

marketing through marketing and non-marketing materials for small and medium organizations