Ethernet Shield + Apple iMac + Connection Problems

Hello,

I have been trying to discover why I can't connect my ethernet shield to my iMac and have a simple sketch connect to the internet. My setup is pretty simple. My Arduino has an ethernet shield which I have connected to my iMac via an ethernet cable. The iMac is connected to WiFi with internet sharing enabled (Share Airport with Ethernet) and the Arduino is running the example web client sketch. I keep getting the connection... disconnected... message as it can't seem to use the iMac internet sharing. My router is running on 192.168.2.1 and I understand that the Macs use this 2.x range for the internet sharing (com.apple.nat.plist)

Has anyone managed to get this working before. I's impractical for me to plug the ethernet shield directly into the router (this works fine). Here are my settings:

Sketch:

byte mac[] = {  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = {192,168,2,18};
byte gateway[] = {192,168,2,16};
byte subnet[] = {255,255,255,0};
byte server[] = {209,85,146,106}; // google.co.uk

Mac:

Wifi: 192.168.2.6
Subnet Mask: 255.255.255.0
Router: 192.168.2.1

Ehernet (IPv4 configured manually):

IP: 192.168.2.16
Subnet Mask: 255.255.255.0
Router: 192.168.2.1
DNS Server: 192.168.2.1
Search Domains: *blank*

Router:

DNS: 192.168.2.1

It's incredibly frustrating as I am normally pretty happy configuring network settings. I have Wireshark and also an Ubuntu laptop if that helps with testing. I'd really appreciate some help.

Thank you

Can you connect normally if you used ICS to connect another computer to the network? You might want to see what IP address is assigned, as well.

From what I remember, you usually need a crossover ethernet patch cable to connect from one computer's ethernet port to another's - not sure if the ICS on Mac accounts for that at all.

I's impractical for me to plug the ethernet shield directly into the router (this works fine).

But, it is practical to connect the Arduino with ethernet shield to the PC? If that is the case, put the ethernet shield back in it's box. You clearly don't need it.

Sorry, I should explain more. My iMac is setup upstairs and my router is downstairs and I don't have a long enough network cable to have it plugged into the router and also connected to my Mac via USB.

I also don't see why it would be a problem anyway if I wanted to just have it connecting via my Mac? Saying I "Clearly don't need it" is a bit blunt.

Anyway, after much searching, I found that I need to change the default sharing adress on the Mac's internet sharing (com.apple.nat). If it helps anyone else, the command is "defaults write /Library/Preferences/SystemConfiguration/com.apple.nat NAT -dict-add SharingNetworkNumberStart 192.168.10.0"

The IP at the end can be anything you want to not conflict with the router (mine was 192.168.2.1 which is the same as apple's internet sharing pool)

Saying I "Clearly don't need it" is a bit blunt.

If you come in here saying you need help with a project, and it appears that you are going about the project all wrong, don't get upset when the suggestion is made that you are doing something useless/unnecessary/far more complicated than necessary.

I don't have a long enough network cable to have it plugged into the router and also connected to my Mac via USB.

If you have to have the Arduino connected to the Mac anyway, I fail to see why you can't just send data to the Mac, and let it do whatever needs to be done with the data. Pressing the Mac into service as a router is unnecessarily complex.

Perhaps you are not going about your project all wrong. If not, then explain why the Arduino needs to be connected to the internet AND to the Mac at the same time.

I just assumed that I wouldn't be patronised as I only asked for a bit of help.

I have it plugged into the Mac whilst I develop the code, and then it can be plugged into the network properly once I am happy everything is working. I am happy with most network configuration (I look after the servers at work) so "Pressing the Mac into service as a router" isn't really all that complex at all - it's just internet sharing. My problem was simply the conflicting addresses between my router and my mac.

As I said, the solution is in my previous post so I hope it helps someone else silly enough to use their ethernet shield with an Arduino!!

I have it plugged into the Mac whilst I develop the code, and then it can be plugged into the network properly once I am happy everything is working.

This statement is quite a bit different from this statement:

I's impractical for me to plug the ethernet shield directly into the router (this works fine).

If you had said, in the beginning that the Arduino was connected to the Mac only for debugging purposes, I wouldn't have said anything.

I still that that you should be debugging a production configuration. Plug the Arduino with Ethernet shield into the router, and move the Mac closer to the Arduino if needed, for debugging purposes.

But, if you want to debug something else, instead, that's fine with me.

Yeah, sorry about that. I guess I was just more concerned with trying to fix the problem than go into specifics about what I was doing with it.

Apologies for getting snappy with you.

Buy a 4 port network switch and plug it in at the computer, problem solved... 8)