06 July 2014

Connecting Raspberry Pi to the Internet Using Mac Internet Connection Sharing

If you get a Raspberry Pi without the Wi-Fi dongle, a Mac connected to interned via Wi-Fi or mobile phone and can get ethernet cable from your closet then you can easily connect your Pi to the internet (and your Mac of course) without buying anything else. Please find below the instruction of how to do it.

Setup internet sharing on your Mac

Go to System Preferences -> Sharing. Choose Internet Sharing (do not check the checkbox itself!). Select what internet connection you want to share (Wi-Fi in my case) and check Ethernet option:
Now check Internet Sharing checkbox and confirm starting of internet sharing.

Connect Raspberry Pi

Connect Raspberry Pi to your Mac with ethernet cable, THEN connect Raspberry Pi to the power (or reboot it if it's already connected). Give it some time to boot completely.
Note that you can use either normal or cross type of ethernet cable. Thanks to Mac's auto-switching option!

Find Raspberry Pi IP address

If Raspberry Pi is default configured, its address is assigned by Mac's DHCP server. In this case Raspberry Pi address will be 192.168.2.2. It is so in most cases. Otherwise you can find its address as described below.

Open terminal.

Get the list of all interfaces: ifconfig
Find interface bridgeX having member: en0. It's bridge100 in my case:
Find all known IP addresses related to this interface: arp -a -i bridgeX (Note to replace bridgeX with your interface name you found on previous step)
You will get the list of IP addresses. Skip x.x.x.1 (your Mac) and x.x.x.255 (broadcast). The rest one is your Raspberry Pi!. It is 192.168.2.2 in my case:

Check Raspberry Pi internet connection

Connect to Raspberry via SSH: ssh address (Note to replace address with your Raspberry Pi address you found on previous step)

Check internet is accessible from Raspberry Pi: sudo apt-get update
Getting no errors means everything works OK.

Enjoy!