Building a Virtual Ipv6 Lab Using User-Mode Linux
Total Page:16
File Type:pdf, Size:1020Kb
building a virtual IPv6 lab using user-mode Linux I Virtual hosting: With UML, a single physical machine can by Salah M.S. host a number of UML machines, depending on the avail- Al-Buraiky able processing power and memory. Each UML machine Salah M.S. Al-Buraiky can be dedicated to a user to run whatever services he or she is a data network engi- neer working for the needs. Communication Solu- I Honeypot building: A UML machine can be used as a hon- tions Engineering Group of Saudi eypot for hackers, where it offers a sandbox for them to play Aramco. He is also an around in without causing any harm, while providing secu- electrical engineering graduate student at rity experts with the opportunity to study their techniques. King Fahd University I Virtual networking: UML machines running on the same of Petroleum and Min- erals. He is specializing host can be networked together and with the host machine. in data communication They can also be connected to the rest of the world, using and machine learning. the host machine as a gateway. [email protected] Being a data network engineer, I am mostly interested in virtual networking; in fact, the original motivation for me to explore The function of an operating system is to provide users UML was my need for IPv6 routers and servers to experiment and applications with a high-level abstraction of the with as part of an IPv6 migration study I am working on. In the underlying hardware architecture, isolating them from lab, UML provides me with a cost-effective and space-conserv- the complexity of such architecture and providing them ing method of constructing an IPv6 network to test routing and with a simple and consistent view of system resources. serving with the new network layer protocol. Outside the lab, Applications running within a certain operating system UML provides me with a “virtual portable lab” in my laptop, allowing me to carry my experimental IPv6 network with me actually deal with a “virtual machine” composed of the while I move around. physical hardware and the layer of abstraction superim- posed on it by the operating system. User-mode Linux In this article, I’ll present a method for creating UML machines for experimenting with the IPv6 protocol. The procedure pre- (UML) is a port of the Linux kernel to the virtual sented, however, can be used for other data-networking experi- machine composed of the physical hardware and the ments. The article assumes that the reader is familiar with IPv6 Linux kernel. In simple terms, UML is a kernel patch that and will show how to create an IPv6 network consisting of three allows users (even unprivileged users) to run an instance IPv6 routers connected with point-to-point links. One of the of the Linux kernel as a user-land process. UML was routers is the host machine (called alpha) and the other two are introduced by Jeff Dike and is available for the 2.4 ker- UML machines, ghost and shadow (see Figure 1). Although the standard Linux kernel contains an IPv6 stack, it is recom- nel series as a patch, while being a standard part of the mended to use the USAGI Linux stack. The USAGI (UniverSAl 2.6 kernel series. playGround for IPv6) implementation has better performance, In this article, the kernel running as a user process will be called better standard conformance, and fewer bugs compared to the the UML kernel, while the “real” kernel will be called the Linux IPv6 stack of the standard kernel. The home page of the USAGI kernel. Similarly, the virtual machine consisting of the UML ker- project is http://www.linux-ipv6.org. In our project, we’ll use the nel, its root file system and the processes created by it will be standard Linux kernel for ghost and the USAGI kernel for called the UML machine, while the “real” machine will be called shadow, just to illustrate the procedure for both kernels. The the host machine. routing software we’ll be using is GNU Zebra (http://www. zebra.org). Having the ability to run a Linux kernel as a user-space process has many practical applications. Some of the uses of UML are: The article will show the reader what software components are needed, how to customize and create a UML kernel, how to cre- I Kernel development: With UML, familiar user-space debug- ate a root file system for the UML machine, and how to config- ging and performance profiling tools can be used for kernel ure networking. Using pre-built components all the way makes development. A misbehaving UML kernel can be just killed the process much easier but leads to a rigid configuration, while like a normal process – no need to reboot if your experi- building all components from scratch may be difficult and time- mental kernel crashes. consuming. Therefore, the procedure presented tries to adopt a 42 Vol. 29, No. 1 ;login: hybrid approach to achieve a balance between customizability rpm -i umlbuilder-1.40-5.i386.rpm and ease of implementation. Second, copy all RPM files in the distribution CDs to a direc- The Building Software Blocks tory on the host machine (alpha). In my case, that directory is ETWORKING /tmp/redhat/rpm. On the CDs, the binary RPM files are kept in N The needed software components are: G /mnt/cdrom/RedHat/RPMS (assuming the CD is mounted on I A fresh source tree for a recent kernel obtained from any /mnt/cdrom). Those RPM files will be used by UMLBuilder. kernel source repository mirror. The kernel source I’ll be Now create a directory for the project (/home/usenix in my using for this article is http://www.kernel.org/pub/linux/ case) and copy the kernel tarballs and the UML patches to it. kernel/v2.4/linux-2.4.20.tar.bz2. I A USAGI-patched kernel. This can be obtained from Building the Root File System ftp://ftp.linux-ipv6.org/pub/usagi/stable/kit/ or any other The root file system for a Linux system is usually hosted by a USAGI mirror. I had some trouble compiling the USAGI hard disk or a hard disk partition. It is more convenient, how- kernel with the UML patch, but the following USAGI pack- ever, to use an ordinary file as the root file system for a UML age worked for me: machine. Linux uses a special device called the loopback device usagi-linux24-stable-20021007.tar (not to be confused with the network loopback interface) to with patch: uml-patch-2.4.19-51.bz2 enable dealing with an ordinary file as if it were a block device, allowing a file to host a file system and a directory tree. Obtain- I The UML patch to be applied to the kernel. Choose a patch that matches the version of the kernel source tree you have ing a root file system for our UML machine can be done by downloaded. The patches I’ll be using here are http:// downloading a pre-built one from the UML home page, by cre- prdownloads.sourceforge.net/user-mode-linux/uml-patch- ating it from scratch using basic Linux tools, or by using UML- 2.4.20-6.bz2, for the standard kernel, and http://prdownloads. Builder. The approach chosen here is to rely on UMLBuilder. sourceforge.net/user-mode-linux/uml-patch-2.4.19-51.bz2 Start by launching the UMLBuilder GUI from within the X win- for the USAGI kernel. dow system launching and xterm and typing: UMLBuilder_gui. I The user_mode_linux package. This package contains a Press “next” and you’ll be presented with a number of distribu- pre-built UML kernel and a number of utilities to be used tions to choose from. Choose RedHat 8.0. When asked about with UML. The pre-built UML kernel contained in the the location of the RPMs, enter /tmp/redhat/rpm. package will only be used initially and will be replaced by a customized kernel once the root file system is built. The Now, you’ll be presented with a selection of packages to choose version used for this article is from. Choose “Various Network Server Daemons (network- http://prdownloads.sourceforge.net/user-mode-linux/ server)” and press “next.”In the file system settings window, user_mode_linux-2.4.19.5um-0.i386.rpm. specify the mount point for device udb0 as “/”,the size of the file system as 400MB, and the file system type as ext2. Leave the I The UMLBuilder package. The root file system of a UML kernel is created within an ordinary file structured like a filename as rootfs. In the Miscellaneous Settings window, set the file system rather than on a disk partition, as is usually the hostname as ghost and the IP address as 10.20.0.1. Set root’s case with “real” kernels. We’ll call that file the rootfs file. A password and press “next.”You’ll be asked about the location relatively easy way to create a customized rootfs file is to where the files pertaining to the UML instance should be use UMLBuilder, a graphical application for creating rootfs stored. Enter /home/usenix/ghost and press “next.” All settings files from RPM-based distributions (e.g., RedHat and will be displayed so that you can review them. If all are correct, SuSE). UMLBuilder requires the user_mode_linux package proceed by pressing the relevant button. The creation of rootfs in order to work. The version used for this article is will start and might take a quite long time to finish.