Thanks for such a quick reply. On Wed, Mar 04, 2009 at 03:26:39PM +0300, Eugene B. Berdnikov wrote: > ioctl(,SIOCSIFFLAGS,) ?
I've just tried using SIOCSIFFLAGS to bring the device up but I'm not having any luck. I had a look at the source code for ifconfig and it sets the IFF_UP and IFF_RUNNING flags when it brings a device up. I've compiled ifconfig with debugging info. I've run it through ddd as: ifconfig eth1 up And it looks like it's doing the same thing as me. I must just be doing something stupid. strace ifconfig tun1 down shows the result of the SIOCGIFFLAGS call it does before it brings the device down (i.e. when the device is still up) and that shows IFF_UP and IFF_RUNNING are set. This is what I have: ifr.ifr_flags = IFF_TUN | IFF_NO_PI; /* Create a TUN device */ if ( *dev ) strncpy(ifr.ifr_name, dev, IFNAMSIZ); if ( (err = ioctl(fd, TUNSETIFF, (void*) &ifr)) < 0 ) return err; /* Set no check sum - from the example */ ioctl(fd, TUNSETNOCSUM, 1); /* Get the flags that are set */ err = ioctl(fd, SIOCGIFFLAGS, (void*) &ifr); if ( err < 0 ) return err; /* Set the flags that bring the device up */ ifr.ifr_flags |= ( IFF_UP | IFF_RUNNING ); err = ioctl(fd, SIOCSIFFLAGS, (void*) &ifr); if ( err < 0 ) return err; As far as I can tell this is what ifconfig does, but it doesn't work. Any help would be great, I really am stuck on this. Thanks all, Nick Martin ------------------------------------------------------------------------------ Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise -Strategies to boost innovation and cut costs with open source participation -Receive a $600 discount off the registration fee with the source code: SFAD http://p.sf.net/sfu/XcvMzF8H _______________________________________________ VTun-devel mailing list VTun-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/vtun-devel