Dynamic Uml Mesh Modeler » History » Version 15
Martin Willi, 14.10.2008 11:12
1 | 1 | Martin Willi | = Dynamic Uml Mesh Modeler = |
---|---|---|---|
2 | 1 | Martin Willi | ''Dumm'' is a framework to set up a virtual network using user mode linux guests. |
3 | 1 | Martin Willi | It cleverly glues together some nice technologies to build networks dynamically. |
4 | 1 | Martin Willi | To change the network topology, hosts are not required to reboot, changes apply |
5 | 1 | Martin Willi | instantly and configuration can be done on the host (no network connection |
6 | 1 | Martin Willi | required to change anything). |
7 | 1 | Martin Willi | |
8 | 1 | Martin Willi | == Status == |
9 | 11 | Martin Willi | ''Dumm'' is experimental and [source:trunk/src/dumm in developement]. |
10 | 11 | Martin Willi | Along with the ''dumm'' library, two frontends are currently usable: |
11 | 11 | Martin Willi | * A graphical GTK client |
12 | 11 | Martin Willi | * A console client with Ruby bindings to script scenarios in Ruby |
13 | 1 | Martin Willi | |
14 | 10 | Martin Willi | The graphical client is incomplete. It is missing: |
15 | 10 | Martin Willi | * Removal of added switches |
16 | 1 | Martin Willi | * Disconnecting guests from switches |
17 | 10 | Martin Willi | * Scenario management |
18 | 10 | Martin Willi | |
19 | 11 | Martin Willi | The Ruby console client also misses a surrounding testing infrastructure which |
20 | 11 | Martin Willi | will be built with ruby in the near future. |
21 | 10 | Martin Willi | |
22 | 1 | Martin Willi | == Why UML? == |
23 | 1 | Martin Willi | UML is a senior in vitualization technologies, and there is a lot of new |
24 | 1 | Martin Willi | hyped stuff about virtualization around. However, UML is lightweight, easy to |
25 | 1 | Martin Willi | set up and allows dynamic reconfiguration (e.g. add/remove interfaces at |
26 | 1 | Martin Willi | runtime), allows access to the hosts filesystem through hostfs and has some |
27 | 1 | Martin Willi | other neat features. |
28 | 1 | Martin Willi | Performance is not critical for our needs, and maybe we get hardware |
29 | 1 | Martin Willi | virtualization support soon in UML. |
30 | 1 | Martin Willi | It is free and fits perfectly. |
31 | 1 | Martin Willi | |
32 | 1 | Martin Willi | == Requirements == |
33 | 1 | Martin Willi | * Host: |
34 | 1 | Martin Willi | * Kernel: |
35 | 1 | Martin Willi | * A recent 2.6 kernel |
36 | 1 | Martin Willi | * [http://www.user-mode-linux.org/~blaisorblade/patches/skas3-2.6/ SKAS3 patch] recommended |
37 | 1 | Martin Willi | * [http://fuse.sourceforge.net/ FUSE] enabled |
38 | 1 | Martin Willi | * support for TAP devices |
39 | 1 | Martin Willi | * Userland: |
40 | 10 | Martin Willi | * [source:trunk/src/libstrongswan libstrongswan] |
41 | 1 | Martin Willi | * libbridge from [http://linux-net.osdl.org/index.php/Bridge bridge-utils] |
42 | 11 | Martin Willi | * using the GTK client: |
43 | 11 | Martin Willi | * GTK+2 with developement headers |
44 | 11 | Martin Willi | * Gnome !VteTerminal with developement headers |
45 | 11 | Martin Willi | * using the Ruby client: |
46 | 11 | Martin Willi | * Ruby 1.8 with developement headers |
47 | 11 | Martin Willi | * IRB |
48 | 10 | Martin Willi | * Guest: |
49 | 1 | Martin Willi | * Kernel: |
50 | 1 | Martin Willi | * hostfs |
51 | 1 | Martin Willi | * tuntap networking |
52 | 11 | Martin Willi | * our extended [source:trunk/src/dumm/patches mconsole exec patch] |
53 | 1 | Martin Willi | * Userland: |
54 | 11 | Martin Willi | * ip from iproute2 |
55 | 1 | Martin Willi | |
56 | 1 | Martin Willi | == Architecture == |
57 | 1 | Martin Willi | |
58 | 1 | Martin Willi | === Working set === |
59 | 1 | Martin Willi | Dumm needs a directory to store all its files, guest configurations and other |
60 | 1 | Martin Willi | stuff. Inside that working directory, you'll find: |
61 | 1 | Martin Willi | |
62 | 2 | Martin Willi | {{{ |
63 | 1 | Martin Willi | workingdir/ - root folder containing a set of hosts and scenarios |
64 | 2 | Martin Willi | guests/ - contains all created guests |
65 | 2 | Martin Willi | alice/ - subdirectory for host "alice" |
66 | 2 | Martin Willi | alice/ - UML created folder (named umid) containing UML runtime files |
67 | 2 | Martin Willi | mem - memory configuration file (contains amount of guest memory in MB) |
68 | 11 | Martin Willi | pid - PID file if guest is running, handy to attach gdb to kernel |
69 | 2 | Martin Willi | linux - symlinked UML kernel this host uses |
70 | 2 | Martin Willi | master/ - symlinked master root file system for this host |
71 | 2 | Martin Willi | diff/ - copy-on-write overlay to master this host uses |
72 | 1 | Martin Willi | union/ - mounted unified filesystem (master + diff + optional scenario) |
73 | 2 | Martin Willi | bob/ |
74 | 2 | Martin Willi | ... - same stuff as in alice |
75 | 11 | Martin Willi | templates/ - contains all scenario templates |
76 | 3 | Martin Willi | test1/ - a scenario folder |
77 | 3 | Martin Willi | diff/ - copy-on-write overlays for each guest's union folder |
78 | 3 | Martin Willi | alice/ - COW for alice |
79 | 3 | Martin Willi | bob/ - COW for bob |
80 | 1 | Martin Willi | }}} |
81 | 1 | Martin Willi | |
82 | 1 | Martin Willi | === Networking === |
83 | 1 | Martin Willi | Network connectivity is realized through tap devices. When creating a ''eth0'' |
84 | 1 | Martin Willi | network device on ''alice'', a ''alice-eth0'' tap device appears on the host. These |
85 | 1 | Martin Willi | are directly connected, when ''alice'' sends traffic to ''eth0'', it appears on the |
86 | 1 | Martin Willi | host at ''alice-eth0''. You can see that as a small network segment (or just a |
87 | 1 | Martin Willi | cable), where these interfaces are attached directly. |
88 | 1 | Martin Willi | To build larger network segments, linux bridging on the host comes into play. |
89 | 1 | Martin Willi | Segments are created by creating a bridge (as with brctl), and then attaching |
90 | 1 | Martin Willi | our tap devices to that bridge. Routing can be done on a UML guest, or even on |
91 | 1 | Martin Willi | the host. |
92 | 1 | Martin Willi | This setup has some advantages over the ''uml_switch'' solution. Bridging works |
93 | 1 | Martin Willi | more reliable in the kernel, and as we see every network interface on the host, |
94 | 1 | Martin Willi | we can sniff at every interface to get some clue what the guests are doing. |
95 | 1 | Martin Willi | |
96 | 1 | Martin Willi | == Howto == |
97 | 1 | Martin Willi | In this mini-howto, we build and boot a minimalistic debian guest on a ubuntu host. |
98 | 4 | Martin Willi | We do everything as root here to simplify things! |
99 | 10 | Martin Willi | |
100 | 1 | Martin Willi | === Host setup === |
101 | 10 | Martin Willi | * install required packages: |
102 | 7 | Tobias Brunner | {{{ |
103 | 11 | Martin Willi | aptitude install libfuse-dev libgtk2.0-dev libvte-dev ruby1.8-dev irb1.8 |
104 | 1 | Martin Willi | }}} |
105 | 4 | Martin Willi | * install libbridge: |
106 | 4 | Martin Willi | {{{ |
107 | 4 | Martin Willi | git clone git://git.kernel.org/pub/scm/linux/kernel/git/shemminger/bridge-utils.git |
108 | 4 | Martin Willi | cd bridge-utils |
109 | 4 | Martin Willi | autoconf |
110 | 4 | Martin Willi | ./configure |
111 | 1 | Martin Willi | cd libbridge |
112 | 1 | Martin Willi | make |
113 | 1 | Martin Willi | make install |
114 | 8 | Tobias Brunner | }}} |
115 | 4 | Martin Willi | * Build and install strongSwan from SVN sources. |
116 | 4 | Martin Willi | {{{ |
117 | 4 | Martin Willi | svn co www.strongswan.org/ikev2/trunk strongswan |
118 | 4 | Martin Willi | cd strongswan |
119 | 1 | Martin Willi | less HACKING |
120 | 4 | Martin Willi | ./autogen |
121 | 10 | Martin Willi | ./configure --enable-dumm [other options] |
122 | 1 | Martin Willi | make |
123 | 1 | Martin Willi | make install |
124 | 1 | Martin Willi | }}} |
125 | 1 | Martin Willi | |
126 | 1 | Martin Willi | * Ubuntu kernels almost fit our needs, they have FUSE and TAP device support. However, |
127 | 1 | Martin Willi | SKAS3 mode is missing. Build your own kernel based on the |
128 | 1 | Martin Willi | [https://wiki.ubuntu.com/KernelCustomBuild Ubuntu Howto], patched with the |
129 | 10 | Martin Willi | [http://www.user-mode-linux.org/~blaisorblade/patches/skas3-2.6/ SKAS3 patch]. SKAS3 is |
130 | 10 | Martin Willi | not required, but guests run much faster with SKAS3 enabled on the host. |
131 | 1 | Martin Willi | |
132 | 10 | Martin Willi | === Guest master filesystem setup === |
133 | 1 | Martin Willi | * create a clean directory and a directory for our master filesystem in it: |
134 | 1 | Martin Willi | {{{ |
135 | 1 | Martin Willi | mkdir umldir |
136 | 1 | Martin Willi | cd umldir |
137 | 1 | Martin Willi | mkdir master |
138 | 1 | Martin Willi | }}} |
139 | 10 | Martin Willi | * bootstrap a debian sid system into master: |
140 | 1 | Martin Willi | {{{ |
141 | 10 | Martin Willi | debootstrap sid master http://mirror.switch.ch/ftp/pub/debian/ |
142 | 1 | Martin Willi | }}} |
143 | 10 | Martin Willi | * enter chroot |
144 | 10 | Martin Willi | {{{ |
145 | 10 | Martin Willi | chroot master |
146 | 10 | Martin Willi | }}} |
147 | 10 | Martin Willi | * enable login on tty0 |
148 | 10 | Martin Willi | {{{ |
149 | 10 | Martin Willi | echo "0:2345:respawn:/sbin/getty 38400 tty0" >> /etc/inittab |
150 | 10 | Martin Willi | echo "tty0" >> /etc/securetty |
151 | 10 | Martin Willi | }}} |
152 | 10 | Martin Willi | * Enable main repository |
153 | 10 | Martin Willi | {{{ |
154 | 10 | Martin Willi | echo deb http://mirror.switch.ch/ftp/pub/debian sid main contrib > /etc/apt/sources.list |
155 | 1 | Martin Willi | aptitude update |
156 | 1 | Martin Willi | }}} |
157 | 1 | Martin Willi | * Install proper locales support |
158 | 10 | Martin Willi | {{{ |
159 | 1 | Martin Willi | aptitude install locales |
160 | 10 | Martin Willi | dpkg-reconfigure locales |
161 | 10 | Martin Willi | }}} |
162 | 10 | Martin Willi | * Install some packages for strongSwan |
163 | 10 | Martin Willi | {{{ |
164 | 10 | Martin Willi | aptitude install libgmp3c2 libsqlite3-0 libcurl3 dropbear gdb binutils |
165 | 10 | Martin Willi | }}} |
166 | 10 | Martin Willi | * leave chroot |
167 | 10 | Martin Willi | {{{ |
168 | 10 | Martin Willi | exit |
169 | 10 | Martin Willi | }}} |
170 | 4 | Martin Willi | * build a vanilla UML kernel (using [http://trac.strongswan.org/attachment/wiki/DynamicUmlMeshModeler/.config my config]): |
171 | 4 | Martin Willi | {{{ |
172 | 14 | Martin Willi | wget http://kernel.org/pub/linux/kernel/v2.6/linux-2.6.27.tar.bz2 |
173 | 14 | Martin Willi | tar jxvf linux-2.6.27.tar.bz2 |
174 | 14 | Martin Willi | cd linux-2.6.27 |
175 | 1 | Martin Willi | make mrproper |
176 | 14 | Martin Willi | wget -O - http://trac.strongswan.org/browser/trunk/src/dumm/patches/mconsole-exec-2.6.27.patch?format=txt | patch -p1 |
177 | 1 | Martin Willi | wget http://trac.strongswan.org/attachment/wiki/DynamicUmlMeshModeler/.config?format=raw -O .config |
178 | 1 | Martin Willi | ARCH=um make menuconfig |
179 | 1 | Martin Willi | ARCH=um make |
180 | 1 | Martin Willi | }}} |
181 | 4 | Martin Willi | |
182 | 4 | Martin Willi | === Start a network === |
183 | 4 | Martin Willi | You'll have to run the tools as root. Make sure you have a DISPLAY set, e.g. by starting it under ''sudo''. |
184 | 4 | Martin Willi | * Invoke the graphical client |
185 | 4 | Martin Willi | {{{ |
186 | 6 | Martin Willi | sudo ipsec dumm |
187 | 6 | Martin Willi | }}} |
188 | 10 | Martin Willi | Add guests, select our master filesystem and the compiled kernel. Add a bridges and connect your guests to it. |
189 | 10 | Martin Willi | Start your guests and configure them. |
190 | 10 | Martin Willi | |
191 | 11 | Martin Willi | * Using the ''irdumm'' ruby client |
192 | 10 | Martin Willi | {{{ |
193 | 11 | Martin Willi | sudo ipsec irdumm |
194 | 14 | Martin Willi | irb> sun = Guest.new("sun", "path/to/linux-2.6.27/linux", "path/to/master/", "mem=64M con0=xterm") |
195 | 11 | Martin Willi | irb> sun.start |
196 | 11 | Martin Willi | irb> sun.exec("echo sun > /etc/hostname") |
197 | 11 | Martin Willi | irb> sun.add("eth0").connect(Bridge.new("br0")).add("192.168.0.1") |
198 | 12 | Martin Willi | irb> sun.exec("ifconfig") { |line| puts line } |
199 | 11 | Martin Willi | irb> quit |
200 | 4 | Martin Willi | }}} |
201 | 10 | Martin Willi | |
202 | 10 | Martin Willi | == Installing strongSwan on guests == |
203 | 10 | Martin Willi | As we have full access to the master filesystem on the host, we can build strongSwan on the host and install it to the guests |
204 | 1 | Martin Willi | {{{ |
205 | 10 | Martin Willi | cd path/to/strongswan/ |
206 | 10 | Martin Willi | DESTDIR=/full/path/to/master make install |
207 | 1 | Martin Willi | }}} |