[ECOS] Change IP during run-time

Daniel Lidsten Daniel.Lidsten@combitechsystems.com
Thu Mar 11 15:20:00 GMT 2004


Hi,

I want to change the IP address of my "eth0" interface during run-time.
Is that possible? I tried to do it using ioctl but encountered some
problems:

1. First i tried to just change the current IP with the below calls but
the old IP address still answers ping calls toghether with the new IP
address. I could successfull ping two addresses. That's not goos since i
want to old address to stop responding.

struct sockaddr_in *inaddr = (struct sockaddr_in *)&ifreq.ifr_addr;
inet_aton("111.22.33.444", &inaddr->sin_addr  );
ioctl( sock, SIOCSIFADDR, &ifreq );


2. The next thing to try was to delete the interface and then
change/create the new one:

if (ioctl(sock, SIOCDIFADDR, &ifreq)) { /* delete IF addr */
inet_aton("111.22.33.444", &inaddr->sin_addr  );
ioctl( sock, SIOCSIFADDR, &ifreq );

With this code i only get ping responses from the new IP address
(good...) but when creating a new socket and sending out data then the
package source (i logg all ethernet traffic) are set to the OLD IP
address.

Any ideas how to change IP address of the board during run-time?

Regards, Daniel Lidsten

--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss



More information about the Ecos-discuss mailing list