[En-Nut-Discussion] Change the IP/gateway

Sigurd Kleppan sigurd at wlink.no
Wed Nov 24 17:46:17 CET 2004


Oki, thank you Ole!

Is it on this code you configure the IP then...??
F.eks:

 confnet.cdn_ip_addr = 192.168.1.2;
 confnet.cdn_ip_mask = 255.255.255.0;
 confnet.cdn_gateway = 192.168.1.2;


Is it possible to configure a DNS server adress?

Regards
Sigurd Kleppan


----- Original Message -----
From: "Ole Reinhardt" <ole.reinhardt at kernelconcepts.de>
To: "Ethernut User Chat (English)" <en-nut-discussion at egnite.de>
Sent: Wednesday, November 24, 2004 5:37 PM
Subject: Re: [En-Nut-Discussion] Change the IP/gateway


> Hello,
>
> > I want to change the IP from a webpage, then reboot the board with the
new
> > IP.
>
> Yes, why not? The IP address will be configured in your initialisation
> code. You can store the new IP address in the eeprom and restart the
> board by using the whatchdog timer. Not read back the ip value from
> eeprom and configure your board with the new address...
>
> I do it like this:
>
>     if (sysconfig.network.usedhcp) {
>         fprintf_P(uart, PSTR("Initialize Network. Sending DHCP
> request..." NL));
>         confnet.cdn_ip_addr = 0;
>         confnet.cdn_ip_mask = 0;
>         confnet.cdn_gateway = 0;
>
>         if (NutDhcpIfConfig("eth0cs", sysconfig.network.mac, 10000)) {
>             fprintf_P(uart, PSTR("no DHCP found. Using configured
> defaults..." NL));
>             NutNetIfConfig2("eth0cs", sysconfig.network.mac,
> sysconfig.network.ip_addr, sysconfig.network.netmask,
>                             sysconfig.network.gateway);
>             NutIpRouteAdd(0, 0, sysconfig.network.gateway, &devEth0cs);
>             NutNetSaveConfig();
>         }
>     } else {
>         fprintf_P(uart, PSTR("Initialize Network..." NL));
>
>         confnet.cdn_ip_addr = 0;
>         confnet.cdn_ip_mask = 0;
>         confnet.cdn_gateway = 0;
>
>         NutNetIfConfig2("eth0cs", sysconfig.network.mac,
> sysconfig.network.ip_addr, sysconfig.network.netmask,
>                         sysconfig.network.gateway);
>         NutIpRouteAdd(0, 0, sysconfig.network.gateway, &devEth0cs);
>         NutNetSaveConfig();
>     }
>
>
> Bye,
>
> Ole
>
> --
> kernel concepts    Tel: +49-271-771091-14
> Dreisbachstr. 24   Fax: +49-271-771091-19
> D-57250 Netphen    E+ : +49-177-7420433
> --
>
>
> _______________________________________________
> En-Nut-Discussion mailing list
> En-Nut-Discussion at egnite.de
> http://www.egnite.de/mailman/listinfo.cgi/en-nut-discussion
>





More information about the En-Nut-Discussion mailing list