Finding the IP and MAC address for Ethernet shield

Hello,

I am a decent C programmer but I am trying to set up the Ethernet shield for a project. I am unsure after reading several tutorials how the individuals found the IP address of the device. I have an ATT wireless internet hub at my place. I'd like to eventually get it wireless but for now I'll stick with hard wired. when we set the device up how do we find, get, create the IP address?

Thanks

There are different ethernet shields, so you probably need to say which one you have. With the w5100 shield and standard ethernet library, you assign the ip and mac addresses to be used in the code you are going to load into the arduino.

I too have just received the W5100 Ethernet device from Adafruit. I was led to beleive that they had their MAC adress hard-coded in the chip, and that this was displayed on a sticker on the unit ... not true - I 'think' all we can do is take a WAG at a unique adress, and just use it.

Charles

If I assign it an IP address how do I go about finding out which ones are noi used. I have to "Ping" the address so to speak? How do I go about doing this?

Thank you

You can open a command box under windows and type : ping /? <return> and it gives the help. As you probably have a standard subnet defined at home you can try

ping 192.168.1.1 ( probably your router)
it will reply with some statistics about reachability.

then you could just try all numbers until you find one that is free
ping 192.168.1.2
etc

a more interesting command is : arp -a
ARP stands for Address Resolution Protocol, the -a flag shows all the addresses your PC knows about, so that are ones you don’t need to test :slight_smile:

Finally you could download tools like - http://www.radmin.com/products/previousversions/portscanner.php - which automatically checks a complete subnet for free and used IP addresses.

Succes
Rob

Thanks very much Rob, I am all set with the 192.168.1.80 - pings o.k., and I can see the activity leds on the ethernet shield responding.

What I don't understand (among a lot of other things ;-) ) is the MAC - I thought this was unique for each device manufactured - evidently not ... but this works, so I will leave it alone !

Charles

The arduino shield I have is the one made in Italy, and designed by tinker.it. I bought it from sparkfun.com and it should be the "endorsed" version that the makers of arduino created. it has a sticker on the bottom which is the MAC address. I am going to try pinging some IP addresses close to the one I have. If i get no reply after 4 tries is that then considered an open ip address?

Thanks much

Bill

Rob, You're awesome: )

If i get no reply after 4 tries is that then considered an open ip address?

In theory no, in practice yes. If no one replies it is free unless not all computers are switched on.

some theory: It is not mandatory for devices to reply on a ping [ICMP echo request], from security point of view it is even disapproved, there was a time one could "kill" some computers by a "ping of death". See - http://en.wikipedia.org/wiki/Ping

@psppb - just download and use "portscanner" as Rob mentioned a few posts back - works like a charm .

Charles

the MAC - I thought this was unique for each device manufactured

The Mac is allocated by the manufacturer, they have to buy a block of unique addresses. If one was included on a label then use that in the software as it will be unique. There is nothing to stop you making one up or using the Mac address of something you already have but there is the potential to get into trouble if you are on a network with a device with the same one. A more likely scenario is that you win the lottery.

Ha, ha - thanks Mike. I have already ‘won’ the lottery several times (if I am to beleive all the e-mails I get :wink: )

Charles

One more question:

Seeing as I am starting to learn about networking. If I find a suitable IP address for the device. Can I use the same IP address anywhere I plug it into a network?

Thanks

psppb: One more question:

Seeing as I am starting to learn about networking. If I find a suitable IP address for the device. Can I use the same IP address anywhere I plug it into a network?

There are two classes of IP addresses, public and private. Public addresses are unique over the entire Internet and private addresses are unique just for your local network. Most likely what you'll get is a private IP address that is only valid for your network.

The solution is DHCP, which allows you to have the network assign you an address. I think there's a DHCP library for arduino out there.

I think there's a DHCP library for arduino out there.

Now I didn't think there was because there is not enough room to implement it. Interested to see anyone who has managed to squeeze it in.

You might try the below library if you have a w5100 ethernet shield.

http://kegger.googlecode.com/files/Ethernet.zip