The Linux Channel

Videos :: Online Course - Linux TUN/TAP virtual network interfaces

Written by: Kiran Kankipati - Published: 25-Jan-2017


Watch Video: 354 Linux TUN/TAP virtual network interfaces - Debugging VTUN Tunnels - Configuration and Settings - Ep4

* Click the image above to watch this video on Youtube ↗

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:

root@xubuntu-desktop:/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
root@xubuntu-desktop:/etc# 


vtund :: Server Side error:

root@1TBWDBlueMobile:/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
root@1TBWDBlueMobile:/etc#


Watch Video: 341 Linux TUN TAP virtual network interfaces - VTUN Project Source Code Walk - Ep3

* Click the image above to watch this video on Youtube ↗

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/Documentation/networking/tuntap.txt
-----------
Intel DPDK Stack - http://www.dpdk.org

Watch Video: TAP Interface sample access - Linux TUN/TAP virtual network interfaces - Episode2

* Click the image above to watch this video on Youtube ↗

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

Watch Video: Linux TUN/TAP virtual network interfaces - Introduction Episode1

* Click the image above to watch this video on Youtube ↗


Suggested Topics:


Linux (user-space), Systems Architecture and Networking :: Video Episodes
 IPUtils - Source Code Walk ↗
21-Aug-2017


 Oracle VM VirtualBox ↗
27-Mar-2017


 Online Course - Networking Protocols ↗
04-Jul-2016


 Networking and Q&A ↗
27-Aug-2016


 Online Course - Linux TUN/TAP virtual network interfaces ↗
25-Jan-2017


 VRF - Virtual Routing and Forwarding ↗
24-Feb-2018


 Data Visualization and Analytics ↗
07-Apr-2018


 net-tools - Source Code Walk ↗
09-Sep-2017


 Online Course - Linux CLI Scripting ↗
04-Jul-2016


 Quagga Routing Suite - OSPF, RIP, RIPng BGP4 | GNU Zebra fork | ZebOS ↗
16-Oct-2018


 Ethtool - Source Code Walk ↗
30-Sep-2017


 Wireshark Packet Capture ↗
27-Oct-2016


 Linux (user-space) RAW Socket Programming ↗
27-Aug-2016


 Code Snippets ↗
16-Mar-2017


 NAS (Network Attached Storage) Operating Systems - FreeNAS, OpenZFS, etc ↗
01-Nov-2018


 CPU Performance and Benchmarks ↗
13-Mar-2017


 CUDA GPU Distributed Parallel Computing ↗
02-Aug-2018


 Systems Architecture ↗
05-Jul-2016


 

Join The Linux Channel :: Facebook Group


Join a course:

💎 Linux Kernel and Systems Software: PDF Brochure

💎 Linux and Network Software Developer: PDF Brochure


💗 Help shape the future: Sponsor/Donate


Recommended Topics:
Featured Video:

* Click the image above to watch this video on Youtube ↗


Trending Video:

* Click the image above to watch this video on Youtube ↗

TUTORIALS :: Research Socket overhead in Linux vs Message Queues and benchmarking:


Linux Kernel Programming - Device Drivers:


Research :: Content Delivery Networks (CDN):
CDN Networks


Recommended Video:

* Click the image above to watch this video on Youtube ↗

The TOFFEE Project - v10.7 :: Updated: 10-Nov-2018 :: © 2018 :: Author: Kiran Kankipati
Your IP: 54.163.20.57 :: Browser: CCBot/2.0 (https://commoncrawl.org/faq/)