Sharing internet connection through ethernet from Mac to Pi


4 posts
by adamagogobaby » Sat Jul 07, 2012 12:45 pm
Hi all,
I've managed to get the Pi mostly set up without much help, but I'm struggling with what I gather is quite a simple thing, due to the lack of posts about it.
I want to share the wireless internet connection of my macbook through it's ethernet port to the Pi. I have enabled internet sharing in the macbook's settings and connected the ethernet cable between the two. No joy on the Pi end though. Am I missing something? I had a little google and some people are mentioning IP addresses, subnet masks and the like, but I'm not entirely sure where I have to go on the mac to change these things.

Thanks
Posts: 3
Joined: Sun May 27, 2012 8:03 pm
by geezbeez » Sun Jul 08, 2012 6:43 pm
It might be the PI is expecting the MAC to provide Web access, where inf act its your router

I fixed a similar problem, look at my notes under "Raspberry PI on the move"
Problem in part was the /etc/resolv.conf file

Add this at the bottom of /etc/dhcp/dhclient.conf (where 192.168.0.1 is your router IP and reboot:

interface "eth0" {
prepend domain-name-servers 192.168.0.1;
}

Test with
$ ping www.google.com
from command line see if its resolved.
Posts: 28
Joined: Mon Jul 02, 2012 9:19 pm
by timothy3592 » Sun Jul 08, 2012 7:04 pm
Are you sure the mac isn't trying to share the wired connection through a wireless ad-hoc network. Generally, I've found that the default for Internet connection sharing is often to take a more reliable wired connection and share it. Check this on the mac before modifying config files on the pi as that line would add 192.168.0.1 on all ethernet connections on the pi. If the router gives a different dns then you'd be waiting 60 seconds or more for 192.168.0.1 to time out before a page loads... best to just modify /etc/resolv.conf directly if you need to.

echo 'nameserver 192.168.0.1' | sudo tee -a /etc/resolv.conf

would do the same thing as the modification to dhclient.conf without being permanent
Posts: 64
Joined: Wed Jun 13, 2012 6:06 am
by geezbeez » Sun Jul 08, 2012 10:48 pm
If the router gives a different dns then you'd be waiting 60 seconds or more for 192.168.0.1 to time out before a page loads... best to just modify /etc/resolv.conf directly if you need to.

Good point timothy,
I guess I should have said your DNS server
Problem I found was if you have a subnet with just your RaspPi The Rasp PI does not know what the DNS server is.

echo 'nameserver 192.168.0.1' | sudo tee -a /etc/resolv.conf

Above is just as bad as if there's a duff entry in resolv.conf possibly created by DHCP client you put the correct nameserver after the bad one and you still get delays.
If you change to static IP the resolv.conf may still have this wrong information.
Posts: 28
Joined: Mon Jul 02, 2012 9:19 pm