A Question about Ethernet.begin()

In the Language Reference:

"Using Ethernet.begin(mac) ...., the Ethernet shield will automatically obtain an IP address" (presumably via DHCP). So you won't actually know what it is without an ipscanner.

With Ethernet.begin(mac, ip) we have "ip: the IP address of the device".
The example plucks an address out of thin air.
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
//the IP address for the shield:
byte ip[] = { 10, 0, 0, 177 };
void setup()
{
Ethernet.begin(mac, ip);

Am I correct in saying that, within a given range, the ip address is completely arbitrary(like the mac address)?

I am not an expert on all the correct terminology but your IP address has to be on the same subnet as the rest of your network. If your gateway is say 192.168.1.2 with a subnet mask of 255.255.255.0 then your Arduino IP address must start with 192.168.1 and be unique from all the other devices on your network.

For my system I get my ADSL modem to assign a fixed IP address to my Arduino of 192.168.1.177 using DHCP and based on the MAC address that my Arduino supplies at connection time.

I found that I could not define the fixed IP address within the Arduino program code because something (I think UDP) would not recognise it - perhaps it was querying DHCP on the ADSL Modem and asking for the IP Address - but not getting a response when the IP address was not assigned by DHCP.

Anyway this all allows me to forward all external http: port 80 traffic coming to my ADSL modem to be routed to the Arduino. The Arduino runs as a web server and publishes a full public web site of what it is doing. You can see it at www.2wg.co.nz.

Yes, you can select any IP address within the relevant subnet - so long as the number will never be used by another device. My DHCP setup assigns IP addresses starting at 192.168.1.240 for new devices that do not have fixed IP addresses. That lets me use all the numbers between 192.168.1.3 and 192.168.1.239 for fixed IP address assignments - either within the devices themselves or within the DHCP setup based on device MAC addresses.

Catweazle NZ