Ethernetshield automatic connect with every lan

Dear all.
I am noop .. sorry.. dut i try to do my best..:slight_smile: :frowning:
Only hope you can help me. where is this forum otherwise for... :confused:

I will try to make a universal part of the sketch for the ethernet shield.
Now i need to set the shield to work with:

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

Only when i use the board in a other lan where i need internet i need to set every time the ip and the gateway etc,

Is there no solution to start the shield with a Dhcp option.
So the board always connect the lan and get internet, from DHCP.
something like:
Ethernet.begin(mac,dhcp);???

I now thet there is then no static ip..
No problem, when the shield get internet automatic

Hope you have a sketch example for me.

Thanks!!

if(!Ethernet.begin(mac))
{
   Serial.println("No dhcp. Setting static");
   Ethernet.begin(mac,ip,dnserver,gateway,netmask);
}
else
{
   Serial.print("DHCP IP ");
   Serial.println(Ethernet.localIP());
}