VIDEOS 》 Online Course - Linux TUN/TAP virtual network interfaces

Download this episode my sample code - http://the-linux-channel.the-toffee-project.or ...

Linux Kernel Source - Documentation/networking/tuntap.txt - Universal TUN/TAP device driver - https://elixir.bootlin.com/linux/latest/source ...
Wiki TUN/TAP - https://en.wikipedia.org/wiki/TUN/TAP

For example: you may get vtund client-server daemon errors like these !
You can kindly watch my video above and learn how you can debug, avoid and address the same.

vtund :: Client Side error:

[email protected]:/etc# vtund -f /etc/vtund-client.conf my_tunnel -n
vtund[2054]: VTun client ver 3.X 02/05/2018 started
vtund[2054]: Connecting to
vtund[2054]: Use SSL-aware challenge/response
vtund[2054]: Remote Server sends <TuK>
vtund[2054]: Session my_tunnel[] opened
vtund[2054]: Input/output error (5)
SIOCDELRT: No such process
vtund[2054]: Session my_tunnel[] closed
vtund[2054]: Exit
[email protected]:/etc# 

vtund :: Server Side error:

[email protected]:/etc# vtund -f /etc/vtund-vm-setup-server.conf -s -n
vtund[11981]: VTUN server ver 3.X 02/05/2018 (standalone)
vtund[12213]: Use SSL-aware challenge/response
vtund[12213]: Session my_tunnel[] opened
vtund[12213]: Connection closed by other side
SIOCADDRT: Network is down
SIOCDELRT: No such process
vtund[12213]: Session my_tunnel closed
vtund[11981]: Terminated
[email protected]:/etc#

VTUN Sourceforge.net Project (Virtual Tunnel) - http://vtun.sourceforge.net
TUN/TAP Wiki - https://en.wikipedia.org/wiki/TUN/TAP
VTUN Setup - official documentation - http://vtun.sourceforge.net/setup.html
VTUN Setup - Linux Journal - https://www.linuxjournal.com/article/6675
Universal TUN/TAP device driver - Linux Kernel Source Doc - https://elixir.bootlin.com/linux/latest/source ...
Intel DPDK Stack - http://www.dpdk.org

Download this episode my entire kernel module sample code, make file, clean script HERE. And here is the source code for a quick reference.

/* tap_access.c - tap interface demo access
 * The Linux Channel
 * Author: Kiran Kankipati
 * Updated: 25-jan-2017
#include <unistd.h>
#include <fcntl.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <syslog.h>
#include <errno.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <netinet/ip.h>
#include <netpacket/packet.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <getopt.h>
#include <string.h>
#include <arpa/inet.h>
#include <stdio.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <malloc.h>
#include <net/ethernet.h>
#include <sys/ioctl.h>
#include <net/if.h>
#include <string.h>
#include <sys/types.h>
#include <time.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <linux/if.h>
#include <linux/if_tun.h>
#include <signal.h>

static int tap_open(char *dev)
{   struct ifreq ifr;
    int fd;

    if ((fd = open("/dev/net/tun", O_RDWR)) < 0) { return -1; }

    memset(&ifr, 0, sizeof(ifr));
    ifr.ifr_flags = IFF_TAP | IFF_NO_PI;
    if (*dev) strncpy(ifr.ifr_name, dev, IFNAMSIZ);
    if (ioctl(fd, TUNSETIFF, (void *) &ifr) < 0) { goto failed; } 

    strcpy(dev, ifr.ifr_name); return fd;

    close(fd); return -1;

int tapfd;
void signal_handler(int sig) { close(tapfd); exit(1); }

int main()
{	unsigned char buf[2000];
	unsigned char name[20];
	int i;
	int numbytes=0;
	strcpy(name,"tapint"); tapfd=tap_open(name); 
	if(tapfd<0) { printf("port open error!\n"); return 0; }


	numbytes=read(tapfd, buf, 2000);
	if(numbytes<=0) { usleep(100); goto repeat;}
	printf("\tTAP Data:");
	for (i=0; i<numbytes; i++) printf("%02x:", buf[i]);
	goto repeat;	

	return 0;

Suggested Topics:

Video Episodes :: Linux (user-space), Systems Architecture and Networking

Linux (user-space) RAW Socket Programming ↗
Thursday' 13-Aug-2020

Online Course - Linux CLI Scripting ↗
Thursday' 13-Aug-2020

Wireshark Packet Capture ↗
Thursday' 13-Aug-2020

Oracle VM VirtualBox ↗
Thursday' 13-Aug-2020

Online Course - Linux TUN/TAP virtual network interfaces ↗
Thursday' 13-Aug-2020

Networking and Q&A ↗
Thursday' 13-Aug-2020

NAS (Network Attached Storage) Operating Systems - FreeNAS, OpenZFS, etc ↗
Thursday' 13-Aug-2020

Quagga Routing Suite - OSPF, RIP, RIPng BGP4 | GNU Zebra fork | ZebOS ↗
Thursday' 13-Aug-2020
GNU Zebra is one of the oldest open-source Dynamic Routing Protocol suite stack developed by Kunihiro Ishiguro. Zebra supports features such as RIPv1/RIPv2 for IPv4 and RIPng for IPv6, OSPFv2 and OSPFv3, BGPv4+ and so on. Zebra is an active project for many years. After many years of active support Zebra is discontinued, and sometime down the lane a new fork is created from Zebra called Quagga which is now maintained by a separate independent open-source community. Quagga is a routing software suite, providing implementations of OSPFv2, OSPFv3, RIP v1 and v2, RIPng and BGP-4 for Unix platforms, particularly FreeBSD, Linux, Solaris and NetBSD. Quagga is a fork of GNU Zebra which was developed by Kunihiro Ishiguro. The Quagga architecture consists of a core daemon, zebra, which acts as an abstraction layer to the underlying Unix kernel and presents the Zserv API over a Unix or TCP stream to Quagga clients.

Building my own Userspace Network Stack - Platform/OS and Hardware Independent ↗
Thursday' 13-Aug-2020

Online Course - Networking Protocols ↗
Thursday' 13-Aug-2020

OpenWRT - BusyBox and Embedded Linux ↗
Thursday' 13-Aug-2020

Systems Architecture ↗
Thursday' 13-Aug-2020

CPU Performance and Benchmarks ↗
Thursday' 13-Aug-2020

Code Snippets ↗
Thursday' 13-Aug-2020

VRF - Virtual Routing and Forwarding ↗
Thursday' 13-Aug-2020

CUDA GPU Distributed Parallel Computing ↗
Thursday' 13-Aug-2020

Data Visualization and Analytics ↗
Thursday' 13-Aug-2020

net-tools - Source Code Walk ↗
Thursday' 13-Aug-2020

IPUtils - Source Code Walk ↗
Thursday' 13-Aug-2020

Ethtool - Source Code Walk ↗
Thursday' 13-Aug-2020

Join The Linux Channel :: Facebook Group ↗

Visit The Linux Channel :: on Youtube ↗

💗 Help shape the future: Sponsor/Donate

Recommended Topics:
Featured Video:
Watch on Youtube - [139//0] 0x1fb a Riddle for viewers | You can participate ↗

Adding your own Kernel Modules into Linux Kernel Source | Linux Kernel Programming ↗
Thursday' 13-Aug-2020
Whenever you do custom kernel modules, you can optionally make it a part of existing Linux Kernel source. This does not mean you are submitting your kernel module to the mainline kernel source (i.e kernel.org Linux Kernel Foundation). What I meant is, you can make your kernel module(s) part of Linux Kernel source so that when you compile your kernel you can automatically compile your kernel module(s) too. As well when you create/modify kernel .config configuration file (such as via make menuconfig, etc), you can enable or disable your kernel module(s) too.
To do the same you have to register (and include) your custom Kernel Module's Kconfig and Makefile to the existing Kconfig and Makefile of the Linux Kernel source Here is a detailed multi-episode video of mine which gives the overall idea and the big-picture.

Linux Kernel Programming | with or without Kernel Modules | Device Drivers ↗
Thursday' 13-Aug-2020
When learning Linux Kernel programming, often I notice my students and viewers gets confused and they start with learning writing Linux Kernel modules. And so they develop the common misconception about Kernel Programming in general. They assume writing code in Linux Kernel means writing kernel modules. Which is absolutely not. Kernel modules are an optional choice and are part of Linux Kernel. But besides modules, Linux Kernel has lot of other mainstream code. Hence if anyone wants to be a Kernel Developer, you should be aware that sometimes you add new code via modules, sometimes without them. And if you ask me, I am not much in favor of writing Kernel modules. Instead in my code, I try to integrate and make them a part of Linux Kernel so that they all get initialized during boot time. Here is an extensive Youtube video of mine on Linux Kernel Programming, with and without Kernel Modules.

Roadmap - How to become Linux Kernel Developer - Device Drivers Programmer and a Systems Software Expert ↗
Thursday' 13-Aug-2020
Many viewers and even sometimes my students ask me how I can become a kernel programmer or just device driver developer and so on. So I shot this video (and an add-on video) where I summarized steps and a roadmap to become a full-fledged Linux Kernel Developer.

Weekly News Digest - Week 03 - July 2020 ↗
Thursday' 13-Aug-2020
The Linux Channel :: Weekly News Digest - Week 03 - July 2020
> Linux founder tells Intel to stop inventing 'magic instructions' and 'start fixing real problems'
> QNAP launches its first 2.5GbE network switch - QSW-1105-5T
> Japan's ARM-based Fugaku is the world's fastest supercomputer
> FreeBSD Back To Seeing Progress On 802.11ac WiFi Support, Ath10k Driver
> Sparkfun Launches the ZED-F9R GPS Dead Reckoning Raspberry Pi pHAT for Mobile Robots
> ODROID-N2 Plus SBC Gets Amlogic S922X Rev. C Processor Clocked at up to 2.4 GHz
> Rock Pi E SBC Comes with WiFi, Bluetooth, Two Ethernet Ports, and Optional PoE

Linux Software Development and Tools ↗
Thursday' 13-Aug-2020

Compiling a C Compiler with a C Compilter | Compile gcc with gcc ↗
Thursday' 13-Aug-2020
The fundamental aspect of a programming language compiler is to translate code written from language to other. But most commonly compilers will compile code written in high-level human friendly language such as C, C++, Java, etc. to native CPU architecture specific (machine understandable) binary code which is nothing but sequence of CPU instructions. Hence if we see that way we should able to compile gcc Compiler source code with a gcc Compiler binary.

Programming Language Performance and Overheads ↗
Thursday' 13-Aug-2020
A detailed Youtube video series of various programming language performance and overheads - a big picture

PyDelhi + PyData + ILUG-D + Linux Chix meetup mash @ Sarai on 17-Dec-2016 ↗
Thursday' 13-Aug-2020

C Programming Language Basics - Pointers in C ↗
Thursday' 13-Aug-2020

Software Programming Standards (Coding Standards) ↗
Thursday' 13-Aug-2020

Trending Video:
Watch on Youtube - [125//0] 0x1d4 Workplace Harassment is an offense #TheLinuxChannel #KiranKankipati ↗

Linux Kernel struct socket and struct sock data-structure ↗
Thursday' 13-Aug-2020

Recommended Video:
Watch on Youtube - [144//0] 0x1f4 Coping Recession | Coping Layoffs | Self Motivation #Career #KiranKankipati #TheLinuxChannel ↗