gateway

Dear friends, is it mandatory to provide GATEWAY in the ethernet settings of orduino board along with mac address ,subnetmask,ip address? What to do if my gateway is dynamic and changing ie. not fixed?

THANKS

The gateway parameter is only required if you need to use the subnet parameter. From https://www.arduino.cc/en/Reference/EthernetBegin:

Ethernet.begin(mac);
Ethernet.begin(mac, ip);
Ethernet.begin(mac, ip, dns);
Ethernet.begin(mac, ip, dns, gateway);
Ethernet.begin(mac, ip, dns, gateway, subnet);

So those are your options of which parameters you can use.

If you do not use a gateway parameter in the begin call, it will use your IP with the last octet set to 1 as the default. So if you use an IP of 192.168.0.3, the begin call sets your gateway to 192.168.0.1.

If your gateway changes, maybe you should consider using DHCP to get your network settings.