0

This link https://stackoverflow.com/a/25601662/5536829 tells how to delete interface in BSD operating system.

struct ifreq ifr;
memset(&ifr, 0, sizeof(ifr));
strcpy(ifr.ifr_name, "tun0");
int fd = socket(PF_INET, SOCK_STREAM, 0);
ioctl(fd, SIOCIFDESTROY, &ifr);

But how to do it in Linux? cuz Linux does not have SIOCIFDESTROY.

Gary Allen
  • 385
  • 1
  • 3
  • 11
  • 1
    Is it required to use `ioctl`? You could check the source code of the `ip` command (`ip link delete tun0`), but it uses netlink sockets instead of `ioctl`, see https://unix.stackexchange.com/a/383761/330217 – Bodo Jul 17 '23 at 09:33

0 Answers0