HOMECOURSESSTUDENTSDONATIONSVIDEOSEVENTSTUTORIALSLINKSNEWSCONTACT


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

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

Refer:
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 192.168.0.88 -n
vtund[2054]: VTun client ver 3.X 02/05/2018 started
vtund[2054]: Connecting to 192.168.0.88
vtund[2054]: Use SSL-aware challenge/response
vtund[2054]: Remote Server sends <TuK>
.
vtund[2054]: Session my_tunnel[192.168.0.88] opened
vtund[2054]: Input/output error (5)
SIOCDELRT: No such process
vtund[2054]: Session my_tunnel[192.168.0.88] 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[192.168.0.88:44936] 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#


Refer:
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;

failed:
    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; }

signal(SIGHUP,signal_handler);
signal(SIGTERM,signal_handler);
signal(SIGKILL,signal_handler);
signal(SIGSTOP,signal_handler);
signal(SIGINT,signal_handler);

repeat:	
	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]);
	printf("\n\n");
   
	goto repeat;	

	close(tapfd);
	return 0;
}



Suggested Topics:


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

Online Course - Linux CLI Scripting ↗
Saturday' 13-Mar-2021

Data Visualization and Analytics ↗
Saturday' 13-Mar-2021

NAS (Network Attached Storage) Operating Systems - FreeNAS, OpenZFS, etc ↗
Saturday' 13-Mar-2021

Code Snippets ↗
Saturday' 13-Mar-2021

Linux (user-space) RAW Socket Programming ↗
Saturday' 13-Mar-2021

Ethtool - Source Code Walk ↗
Saturday' 13-Mar-2021

CUDA GPU Distributed Parallel Computing ↗
Saturday' 13-Mar-2021

Systems Architecture ↗
Saturday' 13-Mar-2021

Networking and Q&A ↗
Saturday' 13-Mar-2021

Online Course - Linux TUN/TAP virtual network interfaces ↗
Saturday' 13-Mar-2021

VRF - Virtual Routing and Forwarding ↗
Saturday' 13-Mar-2021

Quagga Routing Suite - OSPF, RIP, RIPng BGP4 | GNU Zebra fork | ZebOS ↗
Saturday' 13-Mar-2021
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.

Oracle VM VirtualBox ↗
Saturday' 13-Mar-2021

Online Course - Networking Protocols ↗
Saturday' 13-Mar-2021

Building my own Userspace Network Stack - Platform/OS and Hardware Independent ↗
Saturday' 13-Mar-2021

OpenWRT - BusyBox and Embedded Linux ↗
Saturday' 13-Mar-2021

Wireshark Packet Capture ↗
Saturday' 13-Mar-2021

net-tools - Source Code Walk ↗
Saturday' 13-Mar-2021

IPUtils - Source Code Walk ↗
Saturday' 13-Mar-2021

CPU Performance and Benchmarks ↗
Saturday' 13-Mar-2021

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 - x22f Linux Kernel Network Drivers - Classification ↗

Raspberry Pi OS with PIXEL ↗
Saturday' 13-Mar-2021

Programming Language Performance and Overheads ↗
Saturday' 13-Mar-2021
A detailed Youtube video series of various programming language performance and overheads - a big picture

What is a Linux Kernel Module - a Big Picture ↗
Saturday' 13-Mar-2021
Learning Linux Kernel Programming is always fascinating and yet challenging. So generally you may tend to learn Kernel Module programming, since such a module can be dynamically plugged into running Linux Kernel. But this will lead to confusion, and many assume kernel source is mostly a collection of these modules. Which in reality is not. Not just that, when we say Kernel Module, its a vaguely defined term. The term Module (as we know) is nothing but a collection of APIs, bunch of variables and associated data-structures. Which may or may not be a plugable kernel module. If you ask me, I am a fan of wiring Linux Kernel Modules, which may not be necessarily a pluggable kernel module. It all boils down to the address space at which these modules function inside a monolithic Linux Kernel. Which is nothing but Linux Kernel's address space. Hence here is my detailed multi-episode Youtube video series on Linux Kernel modules, a big picture and the significance of the

Linux Kernel Programming | with or without Kernel Modules | Device Drivers ↗
Saturday' 13-Mar-2021
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.

Weekly News Digest - Week 03 - June 2020 ↗
Saturday' 13-Mar-2021
The Linux Channel :: Weekly News Digest - Week 03 - June 2020 > KimĪ‡ Micro: A powerful alternative to the Raspberry Pi that supports PCIe cards > Linux Lands And Then Reverts Usage Of Flexible Array Members > AMD Ryzen 4000-Powered Asus Mini PC Challenges Intel's NUC > Aaeon's Raspberry Pi-like Board Bears An Intel 8th Gen Core i7 CPU and 16GB of DDR4 > Linus Torvalds Announces Massive Linux Kernel 5.8 Update > New Cisco Cloud Scale ASIC & 400G Line Card Announced > Key Differences of PoE vs PoE+ vs PoE++ Switches a STH Guide

CEO, CTO Talk ↗
Saturday' 13-Mar-2021

TCP vs UDP an Expert Opinion ↗
Saturday' 13-Mar-2021

Weekly News Digest - Week 5 - February 2018 ↗
Saturday' 13-Mar-2021
> Mini-ITX board fosters flexibility and fights obsolescence > You Can Do Better Than Arduino: Try These Microcontrollers > Open source is 20: How it changed programming and business forever > Since computer technology evolves so rapidly, does it matter if you have 5 or 15 years of experience as e.g. software developer? > Linux Kernel net_device data-structure - possible_net_t nd_net - Network namespace and Linux Containers - Ep7 > New Wave of Mini Satellites Could Boost Climate Research > Here come all the AI deployments; Now how do we manage AI? > Imagination announces neural network acceleration push

How to start Open-Source Project ↗
Saturday' 13-Mar-2021

Weekly News Digest - Week 8 - February 2018 ↗
Saturday' 13-Mar-2021
> Asymmetric Processor Cores > Using QCT Quanta LB6M 10GbE Switch for Container Networking > Using SSE Instead Of WebSockets For Unidirectional Data Flow Over HTTP/2 > Why IPv6 networks create DNS configuration problems > Hypervisor or containers: Which solution is right for you? > Blockchain for 2018 and Beyond: A (growing) list of blockchain use cases > Raw sockets backdoor gives attackers complete control of some Linux servers


Trending Video:
Watch on Youtube - x22f Linux Kernel Network Drivers - Classification ↗

Layer-2 (L2) Multicast Frame Deep Analysis ↗
Saturday' 13-Mar-2021



Recommended Video:
Watch on Youtube - x22c Linux Kernel Programming | likely() & unlikely() ↗