Ethernet - Ethernet.setGatewayIP()

Description

Set the IP address of the network gateway. Not for use with DHCP.

Syntax

Ethernet.setGatewayIP(gateway)

Parameters

  • gateway: the IP address of the network gateway (IPAddress)

Returns

Nothing

Example

#include <SPI.h>
#include <Ethernet.h>

byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
IPAddress ip(10, 0, 0, 177);
IPAddress myDns(192, 168, 1, 1);
IPAddress gateway(192, 168, 1, 1);

void setup() {
  Ethernet.begin(mac, ip, myDns, gateway);
  IPAddress newGateway(192, 168, 100, 1);
  Ethernet.setGatewayIP(newGateway);  // change the gateway IP address
}

void loop () {}