How to: change ip address of arduino at user's command

in this library arduino has been given a default ip address. Now I want a system so that when anyone changes the ip in the url like in the image, arduino is assigned with the new ip. What codes should I add in the library to achieve this? I must do this on the library (.cpp) ; NOT in sketch (.ino)

#include <inttypes.h>
#include <Wire.h>
#include <Arduino.h>
#include <SHT2x.h>
#include <Ethernet.h>
#include <SPI.h>
#include "testlib.h"

void testlib::setup_system()
  IPAddress ip(192, 168, 1, 129);
  EthernetClient client;
  EthernetServer server(80);

  byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //Setting MAC Address

  if (Ethernet.begin(mac) == 0)

    Ethernet.begin(mac, ip);


  // delay(1000);

void testlib::looping_system()

  float humidityData;
  float temperatureData;

  IPAddress ip(192, 168, 1, 129);
  EthernetServer server(80);
  EthernetClient client = server.available();

  humidityData = (SHT2x.GetHumidity());

  temperatureData = (SHT2x.GetTemperature());

  // listen for incoming clients

  if (client) {

    // an http request ends with a blank line
    boolean currentLineIsBlank = true;
    while (client.connected()) {
      if (client.available()) {
        char c =;
        // if you've gotten to the end of the line (received a newline
        // character) and the line is blank, the http request has ended,
        // so you can send a reply
        if (c == '\n' && currentLineIsBlank) {
          // send a standard http response header
          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: text/html");
          client.println("Connection: close");  // the connection will be closed after completion of the response
          client.println("Refresh: 5");  // refresh the page automatically every 5 sec
          client.println("<!DOCTYPE HTML>");
          // output the value of sensor data

          client.print("temperature value is: ");
          client.println("humidity value is: ");

        if (c == '\n') {
          // you're starting a new line
          currentLineIsBlank = true;
        } else if (c != '\r') {
          // you've gotten a character on the current line
          currentLineIsBlank = false;
    // give the web browser time to receive the data
    // close the connection:



usually you would let the router decide which IP address the device gets, not assign an arbitrary address to the system.

The router could be configured to recognize this device from its MAC address and you could statically assign an address in the router configuration.

I don't see the image, but maybe try to find an arduino ethernet example with the keyword 'static IP address'. You can't just invent one wildly and may find that the chosen one has already been taken. As has been said it is best to work with the dynamic IP address allocated by the router (using DHCP).