Unless you plan on doing some modification to the ethernet library, you will need to restart the Arduino. There is a register function that allows the IP to be changed, but I have not tried it, and do not know if it will take effect without a reset.
I would store the values in EEPROM, then let the user change them. When complete, save and then hit the reset button.
Add: The register function is in a part of the code that the casual user/programmer does not use. You would need to add a routine to the user modules (ethernet.cpp or client.cpp) to access that register function.
There may be a way to test if it will work without a reset. Give me a few minutes to check.
Add2: Lucky you! It works! Change the ip and gateway to your localnet, but leave the last digit a '2'. This routine will change the IP from 192.168.1.2 to 192.168.1.3.
Compile and upload this code. Open the IDE serial window, and you will see the new ip as the second line of the output. Then try to ping the new ip.
#include <SPI.h>
#include <Ethernet.h>
#include <utility/w5100.h>
byte mac[] = { 0x90, 0xA2, 0xDA, 0x00, 0x59, 0x66 };
byte ip[] = { 192, 168, 1, 2 };
byte gateway[] = { 192, 168, 1, 1 };
byte subnet[] = { 255, 255, 255, 0 };
byte ipBuf[4];
char outBuf[18];
void setup()
{
Serial.begin(9600);
Ethernet.begin(mac, ip, gateway, subnet);
delay(1000);
W5100.getIPAddress(ipBuf);
sprintf(outBuf,"%u.%u.%u.%u\r\n",ipBuf[0],ipBuf[1],ipBuf[2],ipBuf[3]);
Serial.write(outBuf);
ipBuf[3] = 0x03;
W5100.setIPAddress(ipBuf);
delay(1000);
W5100.getIPAddress(ipBuf);
sprintf(outBuf,"%u.%u.%u.%u\r\n",ipBuf[0],ipBuf[1],ipBuf[2],ipBuf[3]);
Serial.write(outBuf);
}
void loop()
{
Serial.println("Tick");
delay(1000);
}
I don't usually recommend using the low level functions on the ethernet shield, but you could probably get away with it using the "#include <utility/w5100.h>" and the W5100.setIPAddress() function in your code.
And before you ask, there are a few other routines in there you might need.
W5100.setGatewayIp(ipBuf)
W5100.getGatewayIp(ipBuf)
W5100.setSubnetMask(ipBuf)
W5100.getSubnetMask(ipBuf)
If you have to ask what those functions do, you probably shouldn't be doing this.