]> www.opopop.net Git - reminder/blob - Mixing_virtual_machines_and_bridging.mdwn
attachment upload
[reminder] / Mixing_virtual_machines_and_bridging.mdwn
1 The various steps to bridge a virtual machine on your LAN will be explained below with graphics. 
2
3 We will use the following representation of a network interface called ethx:
4
5 [[!img interface.png size=200x]]
6
7 and I will take the case of UML for the virtual machine.
8
9 The initial state after starting our host is the following, where:
10
11 * the local lo interface is not represented for simplicity
12 * host has one network interface eth0, which is not connected to the LAN
13
14 [[!img host-alone.png size=600x]]
15
16 When we plug eth0 in the LAN, we represent it as follows:
17
18 [[!img host-alone2.png size=600x]]
19
20 To proceed, we must ensure:
21
22 * host kernel has been built with support for UML networking; Debian kernels have that feature 
23 * host has one preconfigured tap0 interface; this can be done for example with the command:
24  
25         tunctl -u [user running UML] -t tap0
26         # if not already done:
27         chown root:uml-net /dev/net/tun
28         chmod 660 /dev/net/tun
29
30     Nota: tunctl is to be found in the package uml_utilities
31
32 * the UML is started **without** a eth1=tuntap,tap0 argument, and we configure inside the UML some eth1 interface
33
34 After that, we get that picture:
35
36 [[!img uml-up.png size=600x]]
37
38 The dangling virtual eth1 interface is of no use, so if we start the UML instead **with** a eth1=tuntap,tap0 argument, we get the following:
39
40 [[!img uml-up2.png size=600x]]
41
42 There is now a virtual ethernet network between tap0 and eth1. If tap0 and eth1 are assigned IP addresses, we could communicate between host and UML. Routing between eth0 and tap0 could be added to give full connectivity between the UML and the outside. We will instead use the same prefix between host and UML than on our LAN, so UML will appear as a genuine new host on the LAN. To do that, we will create a bridge interface br0, then execute 
43
44     brctl addif br0 eth0
45     brctl addif br0 tap0
46
47 [[!img bridge.png size=600x]]
48
49 The effect of these commands is to insert
50 eth0 and tap0 interfaces host endpoints inside the virtual LAN already connected to br0, which leads to the following final picture:
51
52 [[!img bridge2.png size=600x]]
53
54 You need only to assign an IP to eth1 in the above setup to allow full connectivity of the UML with the outside. Assigning an IP to tap0 is a no-op when tap0 is bridged and the IP address assigned to eth0 at startup is now gone. You will assign an IP to br0 only if you want network admin access to the host.