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

Oracle VM VirtualBox ↗
Saturday' 26-Sep-2020

Online Course - Linux TUN/TAP virtual network interfaces ↗
Saturday' 26-Sep-2020

NAS (Network Attached Storage) Operating Systems - FreeNAS, OpenZFS, etc ↗
Saturday' 26-Sep-2020

Online Course - Networking Protocols ↗
Saturday' 26-Sep-2020

Online Course - Linux CLI Scripting ↗
Saturday' 26-Sep-2020

Data Visualization and Analytics ↗
Saturday' 26-Sep-2020

CPU Performance and Benchmarks ↗
Saturday' 26-Sep-2020

OpenWRT - BusyBox and Embedded Linux ↗
Saturday' 26-Sep-2020

Linux (user-space) RAW Socket Programming ↗
Saturday' 26-Sep-2020

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

VRF - Virtual Routing and Forwarding ↗
Saturday' 26-Sep-2020

Systems Architecture ↗
Saturday' 26-Sep-2020

net-tools - Source Code Walk ↗
Saturday' 26-Sep-2020

Wireshark Packet Capture ↗
Saturday' 26-Sep-2020

Building my own Userspace Network Stack - Platform/OS and Hardware Independent ↗
Saturday' 26-Sep-2020

Code Snippets ↗
Saturday' 26-Sep-2020

IPUtils - Source Code Walk ↗
Saturday' 26-Sep-2020

Ethtool - Source Code Walk ↗
Saturday' 26-Sep-2020

Networking and Q&A ↗
Saturday' 26-Sep-2020

CUDA GPU Distributed Parallel Computing ↗
Saturday' 26-Sep-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 - x20f Code with Kiran - Live Coding | Linux Kernel Programming | Kernel Libraries | Part 1 ↗

Multi-Client TCP Server with pthreads Mutex Synchronized - Code-walk of viewer code - Sekhar Pariga ↗
Saturday' 26-Sep-2020
Here is a code-walk of a git-hub source submitted by a viewer Sekhar Pariga, which is a Multi-client TCP Server with pthreads Mutex synchronized. Basically it is a Directory Listing Server, that serves ls, cd, pwd of directory functions to connecting TCP clients which are remotely (locally) executed by the server. Server is implemented using multi-thread pthread library, to serve multiple clients simultaneously. Server keeps the each accepted client session details in the queue data structure. Client session queue contains each clients socket-fd and present working directory as a queue node.

Adding your own Kernel Modules into Linux Kernel Source | Linux Kernel Programming ↗
Saturday' 26-Sep-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.

Roadmap - How to become Linux Kernel Developer - Device Drivers Programmer and a Systems Software Expert ↗
Saturday' 26-Sep-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 ↗
Saturday' 26-Sep-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

IP-in-IP Tunneling Demystified - VPN Tunnels ↗
Saturday' 26-Sep-2020
There can be many ways one can architect VPN Networks. The end objective is to tunnel private IP (typically LAN subnets) within public IP Networks (such as Internet). You can establish such a tunnel in various creative ways, such as Transport Mode, Tunnel Mode, IP-in-IP tunneling, etc. Also you can choose any transport layer protocol of your choice such as send VPN traffic via TCP, or via UDP and so on.

Linux and Open-Source Communities across the world ↗
Saturday' 26-Sep-2020
Here is a small list of Linux (Kernel, Linux Users Group) and Open-Source Communities across the world.

Nmap Network Scanning ↗
Saturday' 26-Sep-2020

Management ↗
Saturday' 26-Sep-2020

Linux Kernel Network Programming - Transport Layer L4 TCP/UDP Registration - Protocol APIs ↗
Saturday' 26-Sep-2020

Slow RGB Fade via Arduino UNO ↗
Saturday' 26-Sep-2020


Trending Video:
Watch on Youtube - x20f Code with Kiran - Live Coding | Linux Kernel Programming | Kernel Libraries | Part 1 ↗

Linux Kernel Programming ↗
Saturday' 26-Sep-2020



Recommended Video:
Watch on Youtube - x20f Code with Kiran - Live Coding | Linux Kernel Programming | Kernel Libraries | Part 1 ↗