Thursday, August 5, 2010

tun module fails in Ubuntu 10, install fake tun

Problem: In Ubuntu 10.04, tun fails. while running the command
$ sudo modprobe tun
results into
tun module failed

The tun module is used in several VPN softwares like hamachi

Resolution:

Install fake tun in Ubuntu. Then run the command 'sudo modprobe tun'
Note: You need to be one of the admins (in sudo group).

To install fake tun, copy/paste and then run each command (below) separately. Make sure there is no line-breaks within a command

$ sudo apt-get install build-essential linux-headers-`uname -r`
$ mkdir faketun
$ cd faketun
$ echo -e "#include \nstatic int start__module(void) {return 0;}\nstatic void end__module(void){return;}\nmodule_init(start__module);\nmodule_exit(end__module);">tun.c
$ echo -e "obj-m += tun.o\nall:\n\tmake -C /lib/modules/\$(shell uname -r)/build/ M=\$(PWD) modules\nclean:\n\tmake -C /lib/modules/\$(shell uname -r)/build/ M=\$(PWD) clean\nclean-files := Module.symvers">Makefile
$ make
$ sudo install tun.ko /lib/modules/`uname -r`/kernel/net/tun.ko
$ sudo depmod -a
$ sudo modprobe tun
Incase, you get an  error, check tun.c and Makefile files (in the faketun folder) are created correctly. You may download the files from the address below, into the faketun folder, and then start from the 'make' command again:

File: tun.c download link


File: Makefile download link

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.