// Adapt values for your card
const byte mac[] = { 0x90, 0xA2, 0xDA, 0x10, 0x1F, 0x62 };
// Adapt values for your network (if static address)
const byte _ip[]  = { 192, 168, 1, 177 };
const byte _dns[] = { 192, 168, 1, 1 };
const byte _gw[] = { 192, 168, 1, 1 };
const byte _snet[] =  { 255, 255, 255, 0 };
const byte _server = 80; // Default for HTTP
const byte _telnet = 23; // Default for telnet

// IP adresses
IPAddress ip(_ip[0], _ip[1], _ip[2], _ip[3]);
IPAddress dnServer(_dns[0], _dns[1], _dns[2], _dns[3]);
IPAddress gateway(_gw[0], _gw[1], _gw[2], _gw[3]);
IPAddress subnet(_snet[0], _snet[1], _snet[2], _snet[3]);

// Initialize the Ethernet server library
EthernetServer server(_server);

void setup() {
  // You can use Ethernet.init(pin) to configure the CS pin
  //Ethernet.init(10);  // Most Arduino shields
  //Ethernet.init(5);   // MKR ETH shield
  //Ethernet.init(0);   // Teensy 2.0
  //Ethernet.init(20);  // Teensy++ 2.0
  //Ethernet.init(15);  // ESP8266 with Adafruit Featherwing Ethernet
  //Ethernet.init(33);  // ESP32 with Adafruit Featherwing Ethernet

  // start serial port:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }

  // start the Ethernet connection:
  Serial.print("Initialize Ethernet adapter, ");
  if (Ethernet.begin(mac) == 0) {
    Serial.println("failed to configure Ethernet using DHCP, using static configuration");
    // Check for Ethernet hardware present
    if (Ethernet.hardwareStatus() == EthernetNoHardware) {
      Serial.println("Ethernet shield was not found.  Sorry, can't run without hardware. :(");
      while (true) {
        delay(1); // do nothing, no point running without Ethernet hardware
      }
    }
    if (Ethernet.linkStatus() == LinkOFF) {
      Serial.println("Ethernet cable is not connected.");
    }
    // try to congifure using IP address instead of DHCP:
    Ethernet.begin(mac, ip, dnServer, gateway, subnet);
    Serial.println("static IP configuration");
  } else {
    Serial.println("DHCP assigned IP");
  }
  // Print IP configuration
  Serial.print("IP      : "); Serial.println(Ethernet.localIP());
  Serial.print("Subnet  : "); Serial.println(Ethernet.subnetMask());
  Serial.print("DNS     : "); Serial.println(Ethernet.dnsServerIP());
  Serial.print("Gateway : "); Serial.println(Ethernet.gatewayIP());
  Serial.print("MAC     : ");
  for (int i=0; i<6; i++) {
    Serial.print(mac[i], HEX);
    if (i < 5) Serial.print(':');
  } 
  Serial.println("\n");

  // Other initialisation you need
}