Connecting to a Raspberry Pi Using Mac's "Internet Sharing" (For External Connections)

Raspberry-Pi
2014-06-22 22:08 (10 years ago) ytyng

Recently, I had an opportunity to handle (practice with) a Raspberry Pi with an acquaintance in a location without well-equipped facilities, outside of home or the office.
By using the "Internet Sharing" feature on a Mac, you can set up your equipment with minimal gear.

Normally, to SSH into a Raspberry Pi from a PC, both the Raspberry Pi and the PC need to be on the same LAN.
They obtain IP addresses from a DHCP server, such as the one on your internet router, and communicate within that network.
However, carrying around an internet router can be a bit cumbersome.

The Mac's "Internet Sharing" feature also runs a DHCP server, so it can be used as a substitute for an internet router.

If you have a Mac equipped with both wired Ethernet and wireless capabilities, you can connect to the Raspberry Pi either via wired or wireless connection.

1. Setting Up the Raspberry Pi (Wired)

In the default state with Raspbian installed, the Raspberry Pi is set to obtain an IP address from DHCP for a wired connection, so no additional configuration is needed.

2. Setting Up the Raspberry Pi (Wireless)


When connecting the Raspberry Pi via wireless,

Raspberry Pi Wireless LAN Setup Notes - Ag Blog
this site is extremely helpful.

Beforehand, decide on the SSID and passphrase you plan to set up on the Mac.
# sudo wpa_passphrase ESSID pass | sudo tee -a /etc/wpa_supplicant/wpa_supplicant.conf

Run this command to append to the wpa_supplicant configuration.

You can have multiple network sections, so it is a good idea to set it up like this:
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
# For using Mac's "Internet Sharing"
network={
	ssid="ESSID"
	#psk="pass"
	psk=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
	proto=RSN
	pairwise=CCMP
	group=CCMP
}
# For connecting to the home network
network={
	ssid="ESSID-HOME"
	#psk="pass"
	psk=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
	proto=WPA
	pairwise=CCMP
	group=CCMP
}
When connecting to the Mac's wireless LAN, configure it like this:
	proto=RSN
	pairwise=CCMP
	group=CCMP
(This setting is for connecting to "WPA2 Personal")

3. Setting Up the Mac


Apple Menu → System Preferences → Sharing

Click on "Internet Sharing" within this menu.

Connect the iPhone 5s and use it as a modem via USB.

Set "Share your connection from" to "iPhone USB".

For "To computers using", check both "Ethernet" (if available) and "Wi-Fi".

Click on Wi-Fi Options and set the "Network Name" and "Password".
Finally, click "Internet Sharing" and click "Start" in the dialog that appears to start internet sharing.

4. Connecting and Restarting the Raspberry Pi


For a wired connection, connect the Mac's wired port to the Raspberry Pi.
You can connect directly with a straight cable, or if connecting multiple devices, use a small LAN hub.

For wireless, simply restart the Raspberry Pi with a wireless LAN dongle attached, and it should automatically connect to the Mac.

▲Practicing with the Raspberry Pi in an extreme manner at a certain rental space.
Current rating: 5

Comments

Archive

2024
2023
2022
2021
2020
2019
2018
2017
2016
2015
2014
2013
2012
2011